0

Ok so I am trying to communicate with an Omron plc using a raspberry pi running the latest version of raspbian (bullseye in this case). I have been trying to keep it simple, so the only thing else is that I am using Python3 (3.8) and pyModbusTCP.

The trouble I am having is that when I try to communicate through the default Modbus port (502) the client will not connect. When I select a port higher than port 1023, (which port numbers 0 - 1023 apparently seem to be reserved) the client will connect, but then I get an MBAP error which per Modbus.org documentation, relates to a server failure.

Now I have tried utilizing Uncomplicated FireWall using

sudo ufw allow 502
sudo ufw enable
sudo reboot

then

sudo ufw status

to ensure UFW was enabling communication through the port.

I tried starting the python REPL with sudo in hopes of giving it root privileges to use port 502. Additionally I have put the individual pyModbusTCP commands into a python script and gave the file chown root privielges to no avail. I may be entirely off base by thinking it is an issue with the port 502 issue, but at this point I am at an impass. Any help, sugggestions, and or direction to better informational resources would be greatly appreciated TYIA

3
  • Which Omron PLC? Are you sure that Modbus is enabled on the PLC side? Have you tried reading Modbus via a commercial tool?
    – Ron Beyer
    Dec 1 '21 at 3:40
  • It's an Omron cj2m, it has a built in Ethernet port. I verified in cx programmer the IP address and that Ethernet/modbus is enabled. I initially had intended on changing the IP address of the plc because the default address for Omron is 192.168.250.1 and I was having issues trying to connect through a router that I was using. So I changed the static IP address of the pi and directly connected to the plc with a crossover cable. Based on everything I have read I am pretty sure it all comes down to not being able to communicate through port 502. Dec 1 '21 at 15:13
  • To answer your last question, no I have not tried to establish communication with any commercial tool. I have however used wire shark to monitor communication of the plc with it's attached field device's. As a side note, I couldn't change the IP address because in the IP address 192.168.250.1 the .1 relates to the node number/address and that would also have to be modified system wide as well. There are a few other things I have in mind to try, I will post more as I get the opportunity throughout the day. Dec 1 '21 at 15:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.