Linux -Blue forest free software | Return to home page | Site Map | Search WWW | Contact Us |
Your current position : Homepage > Free Software > Technological exchanges >Application Programming


    

Blue Forest http://www.lslnet.com at 10:18 on June 6, 2006


Reading from a serial port to ask the question of characters including space

I now read from the other end of a serial data (specifically, the length did not know in advance, since data packets from many areas, but some areas are variable length), some of those data compression BCD use of the data transmission mode (with a decimal bytes said two characters). If the compressed data before compression after two consecutive 0 exists, then reduced to zero after the characters into ASCII, which is at the end of the string.
The question now is, how I drive, including air from the serial data packets to read out all the characters? Read characters function in the face of the air time will automatically end?

Reading from a serial port to ask the question of characters including space

Transferred agreement with the best.
Another read '\0' characters is not the problem.

Reading from a serial port to ask the question of characters including space

I now write is a process with the banks adapter, where the data is compressed over traditional BCD format, the lack of agreements with other tropes.
You mean as if from the other end made up 10 serial characters, the last one is' \0 'if read (fd, buf,100), the return value should be read 100? 10 characters themselves to read the data is read from the serial port, the total premium is back, the '\0' filled?

Reading from a serial port to ask the question of characters including space

-->
Installed into nonblocking mode reception.
If this sent the other 10 bytes, 100 bytes will not receive your return value is 10.

Reading from a serial port to ask the question of characters including space

Thank you for your excellent suggestion, I suddenly see the light spot you benefit so much, but a lot of testing time can be saved.



 Privacy Policy  Copyright © 1999-2000 LSLNET.COM. All rights reserved. Blue Forest website owners. E-mail : Webmaster@lslnet.com