Needed newline byte to send that data
I am using C language and Linux as my programming platform. Right now I am learning some embedded programming. I am using a POS device for my practice session and my host is a Windows OS using a cygwin.
I created a simple application that will run in the target device that will read the data in the serial port and in the host side I created a simple application that will write the data in the serial port. Now my problem is when I am sending a data without 0x0a(LN) at the end of the buffe开发者_Python百科r the target device will not receive that data. But I am not sure if that was sent or not. But when I put a 0x0a(LN) at the end of the buffer to send then the target device will receive that data.
Did I missed some configuration of my application? Or putting a 0x0a byte at the end of the tx buffer is the correct way.
Thanks
It sounds like your serial port (actually the 'terminal device' as far as Linux is concerned) may be in line-buffered mode. When setting it up with tcsetattr
, be sure to clear c_lflag (you don't want ICANON). You should also check out the input/output flags that affect translation between CRLF and NL since you probably don't want that behavior either. Default terminal settings are oriented towards user/application interaction, not data transmission.
Sounds like it's doing line buffering. Do a flush after sending the data.
精彩评论