Python OptoMMP - reading channels names and strings

I’m able to read via Python the channels string registers for named IO channels, but seem to only ever get one channel at a time (always returned a single byte array character string of 1 char.

I’m using this to read in python 3.9:

device = optommp.O22MMP(‘127.0.0.1’) #or a static IP when read remotely
RAW = device.ReadRawOffset(0xF0100030, 32, ‘s’) #reads the first modules first channel

My RAW response is always b’S’ no matter how many characters I set it to read (32).
I can read these in the OptoManage Webpanel under IOServices/GenericMMP
image

From python, I seem to only get 1 byte at a time, but it does read them correctly. How do I read the whole string at once?

Thanks for any help. My goal, is to synchronize some of channel config with our own app config so a user can modify from our API, but still have it show up in the IO list correctly, and visa versa.

Mike

OK, so seems the ReadRawOffset only ever returns one value, so I found out that the ReadBlock function can do this.

then, have to strip the results of whitespace at the end if the character string is empty.
I just run RAW = device.ReadBlock(memRegister, length)
result = RAW.decode(‘utf-8’)[16:].rstrip(‘\x00’)

Gets me what I needed!

1 Like

Thanks for the self-closing of the question < grin >
And yeah, that pesky white space at the end has caused a few head scratches.
Glad you got it sorted.
I think @torchard will be very interested in what you found.

1 Like