jamesbunner777
Member
Hello all,
I'm working with TwinCAT3 and using RS232 communication via a CX5120 CPU with the optional RS232 port. I'm able to send and receive data and have no issues with the RS232 setup. However, there are always characters in the FIFO register that are sent whenever I send my first byte to the connected hardware.
So I'm trying to do a ComReset to reset the hardware buffers. Does anyone have a clear example of how to do this? I have seen the Beckhoff example, but it doesn't seem to easy to follow, especially since pointers are used. See below:
VAR_INPUT
Execute : BOOL;
pComIn : POINTER TO BYTE <---(This doesn't tell me much)
pComOut : POINTER TO BYTE <---(Not sure I'm using pointer correctly)
SizeComIn : UINT;
END_VAR
VAR_OUTPUT
Done : BOOL;
Busy : BOOL;
Error : BOOL;
ErrorID : UDINT;
END_VAR
I have tried to use this example, but I'm definitely doing something wrong, because it never clears the hardware buffer. It certainly compiles ok, but there is still something I don't quite understand about how to use it correctly.
If there is anyone out there that could help me with a clear example, I would greatly appreciate it!
Thanks!
I'm working with TwinCAT3 and using RS232 communication via a CX5120 CPU with the optional RS232 port. I'm able to send and receive data and have no issues with the RS232 setup. However, there are always characters in the FIFO register that are sent whenever I send my first byte to the connected hardware.
So I'm trying to do a ComReset to reset the hardware buffers. Does anyone have a clear example of how to do this? I have seen the Beckhoff example, but it doesn't seem to easy to follow, especially since pointers are used. See below:
VAR_INPUT
Execute : BOOL;
pComIn : POINTER TO BYTE <---(This doesn't tell me much)
pComOut : POINTER TO BYTE <---(Not sure I'm using pointer correctly)
SizeComIn : UINT;
END_VAR
VAR_OUTPUT
Done : BOOL;
Busy : BOOL;
Error : BOOL;
ErrorID : UDINT;
END_VAR
I have tried to use this example, but I'm definitely doing something wrong, because it never clears the hardware buffer. It certainly compiles ok, but there is still something I don't quite understand about how to use it correctly.
If there is anyone out there that could help me with a clear example, I would greatly appreciate it!
Thanks!
Last edited: