Unable to run python OptoMMP Package

Below is the sample code that i am running

import optommp

ipaddr = ''
grvEpic = optommp.O22MMP(ipaddr)

value = grvEpic.GetDigitalPointState(1, 1)


initally i was using python3 and had a basic import error which i was able to solve by following this post LINK

But upon running it i get this error
Traceback (most recent call last):
File “optoMMPCheck.py”, line 6, in
value = grvEpic.GetDigitalPointState(1, 1)
File “C:\Users\Desktop\Development\git\optoMMP\optommp_init_.py”, line 59, in GetDigitalPointState
return int(self.UnpackReadResponse(data, ‘i’))
File “C:\Users\Desktop\Development\git\optoMMP\optommp_init_.py”, line 223, in UnpackReadResponse
raw = struct.unpack_from(‘>’+data_type, bytearray(data_block))
TypeError: unpack_from() argument 1 must be string or read-only buffer, not bytearray

i have tried installing python2.7 and have the same issue as above.
Would like to understand if it only works for linux? I am currently using windows

Doing a quick Google of ‘python byte array windows vs linux’ there does seem to be, well, differences between the two OS’s.
Let’s ping @torchard and see what he can suggest.
I know the optommp Python code was created to run on EPIC and RIO, but perhaps there is a tweak that can be made for Windows. I’m not sure; it’s out of my area of expertise.

I have not tested the package with Windows, so I’ll have to dig into this — with the changes from the other forum post I cannot imagine there’s a major difference between running it with 2.7 vs 3.X, so it is likely a Windows quirk.

I’ll reply again when I have more insight!

Thank you very much for quick response @Beno and @torchard .

I will be waiting for the update…

Dear @Beno @torchard ,

I have purchased a basic Raspberry Pi 3B+ and ran the same code using Python 3, but I am still encountering the same issue.

Could you please clarify whether OptoMMP for Python can only run on the PLC, or if it is compatible with any Linux-based system?

Thank you very much for your prompt response.

I can confirm that the Python OptoMMP library works on EPIC, RIO, Linux and Windows.
Just need a little more time to try and understand what is causing the error and why we are not seeing it here.

After testing the library with both Linux and Windows (11) I haven’t been able to reproduce your error.

The code I’m running:

import optommp

ipaddr = 'epic-dev'
grvEpic = optommp.O22MMP(ipaddr)

value = grvEpic.GetDigitalPointState(0,  1)

print (value)


With Python 3.12.3 and pip 24.0 running on my Windows desktop:

Are you seeing the exact same TypeError from your RPi that you are getting from Windows?

Thank you for the response @torchard and @Beno

Yes i am seeing the same response for raspberry pi as well.

Thank you @torchard for the insights. I was able to fix the issue by changing my python version to the one mentioned above and creating a new virtual environment