byte array index out of range - python PLC #391
Unanswered
Matthewgallo77
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I am communicating data between PLCs using python snap7. the data in the PLC is byte.bit addressable. I am trying to read a boolean with an address of M110.7. M meaning internal memory byte=110 bit=7. I am using the mb_read function to get the byte array of internal memory. So, I am passing start = 110, and size = S7WLBit (0x01). Which indicates the data type (boolean). This returns a byte array = b'\x00'. After this, I use the get_bool function to retrieve the value. Where I am passing the byte array I achieved. The byte index (110) and the bit index (7). I am expecting the value to be read but receive this error message.
byte_value = bytearray_[byte_index]
IndexError: bytearray index out of range
To clarify, I recognized when start = 0, I do not receive the out-of-range error. How can I achieve this but for values other than 0?
Beta Was this translation helpful? Give feedback.
All reactions