SUPPORT SYSLIBCOM LIBRARY
I use ABB plc with codesys software version 2.3. I use syscomlib library to receive data on serial networks. However, every scan receive buffer then i see it replace. I can't manager it. Example I sent a frame with structure : EOT 49 49 50 48 48 48 48 ENQ then every check SysComRead function then I see Receive Buffer as: + EOT 49 49 50 48 48 48 48 ENQ + or 50 48 48 48 48 ENQ EOT 49 49 + or 49 50 48 48 48 48 ENQ EOT 49 position these character change, I don't manager receive buffer so I can't process
I program command SysComRead: dwRead := SysComRead( dwHandle,ADR(abyRead),20,0); abyRead is array receive buffer Can you support for me about syslibcom library? Best Regard!
"However, every scan receive buffer then i see it replace"
So, I'm guessing that you are trying to read the COM port buffer every program scan ? Serial port communications don't quite work this way - the port is not syncronised with the execution of the PLC program.
SysComRead tries to get "x" number of bytes from the port - in your case 20 bytes. When there are 20 bytes ready, they will be returned to the application program. If there are less than 20 bytes you get whatever is sitting in the serial port buffer at the end of the timeout period. So in your case you are just pulling a random number of bytes less than 21 out of the serial port buffer every program scan and letting the block time out.
If you are receiving fixed length messages, then you should read the entire length of the message in one read and set the timeout period to some sensible value. ie ... dwRead := SysComRead( dwHandle,ADR(abyRead),message_length,sensible_timeout)
if you are receiving variable length messages then you probably need to read 1 character at a time, and look to see if that character is an "END OF MESSAGE" and if not add it to your current message.