I'm have a few issues with CodeSys and serial ports not working correctly. I have 3x serial ports 1x RS232 and 2x RS485. The ports work fine out of CodeSys and using CuteCom serial tool. I can send raw Modbus RTU frames and receive them fine with CuteCom.
In my /etc/CODESYSControl_Users.cfg I have ( also tried in /etc/CODESYSControl.cfg )
[SysCom]Linux.Devicefile.1=/dev/ttyAMA2
ttyAMA2 Is my first RS485 port and is linked to COM1 in CodeSys. This is all working correctly as the Modbus_Com and the Modbus_Master_Com_Port indicate green when online. The Modbus_Slave_Com_Port shows an orange triangle next to it ( checking that status it's not an Error and indicates UNDEFINED ) now when I try to send a trigger to turn on an coil this triangle goes red (This is an Error and indicate RESPONSE TIMEOUT)
I have a port sniffer(analyzer) on the RS485 lines checking for data and nothing comes through at all from CodeSys and if I open CuteCom and open the port and send the data the analyzer picks it all up and can read all the bytes in HEX and decodes the Modbus frame. I have made sure I close the port again after using CuteCom. I have tried uninstalling the runtime and reinstall again. I tried the Pixtend Serial test program where you can send raw data via SysCom and that also does not work. Connects fine with no errors, but just no data.
The hardware I'm using is a CHIPSEE RPI HMI with CM4 compute module. I'm using CodeSys v17.2 and Runtime 4.2.0.0. The OS is bullseye and I know there is a few issues with latest version and runtime shutting down. Could there also be other underlying issues? I think it's an issue with CodeSys accessing the serial ports rather than OS issue or hardware.
Edit: The fact I can open CuteCom serial port while the CodeSys runtime is running indicates CodeSys has not taken control of the port. If I run 2x instances of CuteCom and open the serial port and then try to open the same serial port I get an error, so I should get this same error if CodeSys had the port correctly opened and available.
Edit: I have also tried the SerialComVisu Demo and it shows no errors... If I try to write data it sends but can't see anything on the analyzer at all, or if I try to send something from another terminal it can't read any data either. As soon as I use CuteCom I can receive that data and send it and analyzer picks it up. So defiently an issue within in CodeSys. I have tried other com ports in CodeSys and they don't connect and show an error.
Thanks,
Matthew
Last edit: matthew 2022-02-11
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure, but the only reason could be - CODESYS does only support RS-485 adapters which are suporting to determine send/receive direction in hardware.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think it might be a bug. If I change back to windows runtime and use my USB to RS485 the project and code works and everything is good. If I try the same USB adapter on the RPI ( now ttyUSB0 and I use ttyUSB in the config ) I get the exact same behavior as the hardware RS485. Both show as green and the same orange and red triangle. I have now tried different version of RaspbianOS ( buster and bullseye and my own custom RT patched versions ) none of these work and have the exact same issue. Would this indicate and runtime issue on the RPI? The USB to RS485 adapter works fine on the pi using CuteCom also. What else can I try to figure out where the issue is?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi,
I'm have a few issues with CodeSys and serial ports not working correctly. I have 3x serial ports 1x RS232 and 2x RS485. The ports work fine out of CodeSys and using CuteCom serial tool. I can send raw Modbus RTU frames and receive them fine with CuteCom.
In my /etc/CODESYSControl_Users.cfg I have ( also tried in /etc/CODESYSControl.cfg )
ttyAMA2 Is my first RS485 port and is linked to COM1 in CodeSys. This is all working correctly as the Modbus_Com and the Modbus_Master_Com_Port indicate green when online. The Modbus_Slave_Com_Port shows an orange triangle next to it ( checking that status it's not an Error and indicates UNDEFINED ) now when I try to send a trigger to turn on an coil this triangle goes red (This is an Error and indicate RESPONSE TIMEOUT)
I have a port sniffer(analyzer) on the RS485 lines checking for data and nothing comes through at all from CodeSys and if I open CuteCom and open the port and send the data the analyzer picks it all up and can read all the bytes in HEX and decodes the Modbus frame. I have made sure I close the port again after using CuteCom. I have tried uninstalling the runtime and reinstall again. I tried the Pixtend Serial test program where you can send raw data via SysCom and that also does not work. Connects fine with no errors, but just no data.
The hardware I'm using is a CHIPSEE RPI HMI with CM4 compute module. I'm using CodeSys v17.2 and Runtime 4.2.0.0. The OS is bullseye and I know there is a few issues with latest version and runtime shutting down. Could there also be other underlying issues? I think it's an issue with CodeSys accessing the serial ports rather than OS issue or hardware.
Edit: The fact I can open CuteCom serial port while the CodeSys runtime is running indicates CodeSys has not taken control of the port. If I run 2x instances of CuteCom and open the serial port and then try to open the same serial port I get an error, so I should get this same error if CodeSys had the port correctly opened and available.
Edit: I have also tried the SerialComVisu Demo and it shows no errors... If I try to write data it sends but can't see anything on the analyzer at all, or if I try to send something from another terminal it can't read any data either. As soon as I use CuteCom I can receive that data and send it and analyzer picks it up. So defiently an issue within in CodeSys. I have tried other com ports in CodeSys and they don't connect and show an error.
Thanks,
Matthew
Last edit: matthew 2022-02-11
Not sure, but the only reason could be - CODESYS does only support RS-485 adapters which are suporting to determine send/receive direction in hardware.
Hi Eschwellinger,
Just done some research on the Chipsee HMI panel and it states it is done automatically via hardware and no no need for software.
The RS485 circuit controls the Input and Output direction automatically, thereβs no need to control it from within the software.
Is there anything else I can try or test within CodeSys?
Thanks,
Matthew
I think it might be a bug. If I change back to windows runtime and use my USB to RS485 the project and code works and everything is good. If I try the same USB adapter on the RPI ( now ttyUSB0 and I use ttyUSB in the config ) I get the exact same behavior as the hardware RS485. Both show as green and the same orange and red triangle. I have now tried different version of RaspbianOS ( buster and bullseye and my own custom RT patched versions ) none of these work and have the exact same issue. Would this indicate and runtime issue on the RPI? The USB to RS485 adapter works fine on the pi using CuteCom also. What else can I try to figure out where the issue is?
Is there any solution because we have the same problem with other hardware?