Weirdness! #218
Replies: 2 comments 4 replies
-
I think you've uncovered a bug (and a gap in my testing) with writing to individual BOOL array elements >32. BOOL arrays are a pain in the ass to get working, so this doesn't surprise me at all. The underlying datatype for a BOOL array is a DWORD array, which is why you can only make them in 32-element increments. It looks like that may be the issue, I'll try to replicate it and dig into it more tomorrow. |
Beta Was this translation helpful? Give feedback.
-
Awesome!! i can live with creating different groups of 32 bit array BOOLs. PLease note that its not just writing to the BOOL array elements > 32 but also reading them . if i dont try to write anything to the plc the plc.read function will read all BOOL array elements even greater than 32. However once i do 1 write, it seems to only READ the first 32 elements! I am not the best programmer however, if there is anything i can do to contribute to this project pleae let me know! I am truly mind blown that you are kind enough to share this utility with us for FREE. |
Beta Was this translation helpful? Give feedback.
-
Greetings,
First i would like to thnak whoever created this amazing utility! I was very excited to see that it worked when i tested it out! I am currently doing a project where i can historize alarm messages. I want to use this utility to read data from the plc and then create a log file with all the alarm messages that we have. Here is what i have and where my issue lies:
I have a seperate file with all the messages. lets call it alarms.py
i have the main python program that uses pycomm3. This program will listen to a specific bit in the plc and then incoke certain messages from alarms.py depending on what bit turns on in the plc.
In the plc i have created a boolean array variable called 'MESSAGE' of 224 bits.
I turned every bit ON and wanted to test to see if i can read the state of the bits in my program. I did a simple for loop and printed out the state
for x in range(199): print(x) print(plc.read('MESSAGE[{}]'.format(x)).value)
the output:
0 True 1 True 2 True 3 True 4 True 5 True 6 True 7 True 8 True 9 True 10 True 11 True 12 True 13 True 14 True 15 True 16 True 17 True 18 True 19 True 20 True 21 True 22 True 23 True 24 True 25 True 26 True 27 True 28 True 29 True 30 True 31 True 32 True 33 True 34 True 35 True 36 True 37 True 38 True 39 True 40 True 41 True 42 True 43 True 44 True 45 True 46 True 47 True 48 True 49 True 50 True 51 True 52 True 53 True 54 True 55 True 56 True 57 True 58 True 59 True 60 True 61 True 62 True 63 True 64 True 65 True 66 True 67 True 68 True 69 True 70 True 71 True 72 True 73 True 74 True 75 True 76 True 77 True 78 True 79 True 80 True 81 True 82 True 83 True 84 True 85 True 86 True 87 True 88 True 89 True 90 True 91 True 92 True 93 True 94 True 95 True 96 True 97 True 98 True 99 True 100 True 101 True 102 True 103 True 104 True 105 True 106 True 107 True 108 True 109 True 110 True 111 True 112 True 113 True 114 True 115 True 116 True 117 True 118 True 119 True 120 True 121 True 122 True 123 True 124 True 125 True 126 True 127 True 128 True 129 True 130 True 131 True 132 True 133 True 134 True 135 True 136 True 137 True 138 True 139 True 140 True 141 True 142 True 143 True 144 True 145 True 146 True 147 True 148 True 149 True 150 True 151 True 152 True 153 True 154 True 155 True 156 True 157 True 158 True 159 True 160 True 161 True 162 True 163 True 164 True 165 True 166 True 167 True 168 True 169 True 170 True 171 True 172 True 173 True 174 True 175 True 176 True 177 True 178 True 179 True 180 True 181 True 182 True 183 True 184 True 185 True 186 True 187 True 188 True 189 True 190 True 191 True 192 True 193 True 194 True 195 True 196 True 197 True 198 True
This is all good so far.
-I then wrote a function that see if the bit is true.. if it is then it invokes the message and logs it to a file. Once the log is written, i toggle the bit off.
Here is the output when i call the function:
0 True 1 True 2 True 3 True 4 True 5 True 6 True 7 True 8 True 9 True 10 True 11 True 12 True 13 True 14 True 15 True 16 True 17 True 18 True 19 True 20 True 21 True 22 True 23 True 24 True 25 True 26 True 27 True 28 True 29 True 30 True 31 True 32 False 33 False 34 False 35 False 36 False 37 False 38 False 39 False 40 False 41 False 42 False 43 False 44 False 45 False 46 False 47 False 48 False 49 False 50 False 51 False 52 False 53 False 54 False 55 False 56 False 57 False 58 False 59 False 60 False 61 False 62 False 63 False 64 False 65 False 66 False 67 False 68 False 69 False 70 False 71 False 72 False 73 False 74 False 75 False 76 False 77 False 78 False 79 False 80 False 81 False 82 False 83 False 84 False 85 False 86 False 87 False 88 False 89 False 90 False 91 False 92 False 93 False 94 False 95 False 96 False 97 False 98 False 99 False 100 False 101 False 102 False 103 False 104 False 105 False 106 False 107 False 108 False 109 False 110 False 111 False 112 False 113 False 114 False 115 False 116 False 117 False 118 False 119 False 120 False 121 False 122 False 123 False 124 False 125 False 126 False 127 False 128 False 129 False 130 False 131 False 132 False 133 False 134 False 135 False 136 False 137 False 138 False 139 False 140 False 141 False 142 False 143 False 144 False 145 False 146 False 147 False 148 False 149 False 150 False 151 False 152 False 153 False 154 False 155 False 156 False 157 False 158 False 159 False 160 False 161 False 162 False 163 False 164 False 165 False 166 False 167 False 168 False 169 False 170 False 171 False 172 False 173 False 174 False 175 False 176 False 177 False 178 False 179 False 180 False 181 False 182 False 183 False 184 False 185 False 186 False 187 False 188 False 189 False 190 False 191 False 192 False 193 False 194 False 195 False 196 False 197 False 198 False
As you can see it only read the first 32 bits as true and is not reading the other bits correctly. I was wondering if someone else ran into this issue. If so any help woul dbe highly appreciated!!
Thank you guys!
Beta Was this translation helpful? Give feedback.
All reactions