visual c++ - Serial port programming - Recognize end of received data -
i writing serial port application using vc++, in can open port on switch device, send commands , display output. running thread read open port output of given command. main thread waits until read completes, problem how recognize command output ends, , should signal main thread.
almost serial port communication requires protocol. way receiver discover response has been received in full. simple 1 using unique byte or character can never appear in rest of data. linefeed standard, used modem example.
this needs more elaborate when need transfer arbitrary binary data. common solution send length of response first. receiver can count down received bytes know when complete. needs embellished specific start byte value receiver has chance re-synchronize transmitter. , includes checksum or crc receiver can detect transmission errors. further embellishments make errors recoverable ack/nak responses receiver. you'd on way in re-inventing tcp. ratp protocol in rfc-916 example, albeit ignored.
Comments
Post a Comment