Missing Flow Control Data (0x13) From Reading Device Data Stream

Just browsing Stack Overflow? Help us improve your experience. Sign up for research
    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Try Teams for free Explore Teams
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs Missing flow control data (0x13) from reading device data stream Ask Question Asked 13 years ago Modified 13 years ago Viewed 3k times 1

I have written a Linux app to read & write binary data to a remote device over a USB port that is emulating a serial port.

When I read data from the device, I have a USB sniffer that shows a binary data stream like this (0x01, 0x0A......0x13), but when my program reads the bytes, the 0x13 is not in the byte stream - this is the XOFF char, but I am not using XON/XOFF flow control (I think).

Tried both open read and write, as well as fopen fread and fwrite in binary mode, same result. Any ideas?

Share Improve this question Follow edited Nov 10, 2011 at 6:36 glglgl's user avatar glglgl 90.9k13 gold badges154 silver badges228 bronze badges asked Nov 9, 2011 at 19:42 user1038375's user avatar user1038375user1038375 211 silver badge3 bronze badges 1
  • could it be a checksum byte that the serial-over-USB protocol adds? – David Winant Commented Nov 10, 2011 at 0:03
Add a comment |

2 Answers 2

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 1

Thanks for any responses, like the website. Turns out stty showed:

# stty -F /dev/ttyUSB0 speed 115200 baud; intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; flush = ^O; min = 0; time = 10; -brkint -imaxbel -opost -isig -icanon -echo -echoe

Even though it looked like flow control was off, The solution was to use cfmakeraw settings to see ALL characters and ignore nothing.

cfmakeraw() sets the terminal to something like the "raw" mode of the old Version 7 terminal driver: input is available character by character, echoing is disabled, and all special processing of terminal input and output characters is disabled. The terminal attributes are set as follows:

termios_p->c_iflag &= ~(IGNBRK | BRKINT | PARMRK | ISTRIP | INLCR | IGNCR | ICRNL | IXON); termios_p->c_oflag &= ~OPOST; termios_p->c_lflag &= ~(ECHO | ECHONL | ICANON | ISIG | IEXTEN); termios_p->c_cflag &= ~(CSIZE | PARENB); termios_p->c_cflag |= CS8;

Can see all my data now :)

Share Improve this answer Follow answered Nov 10, 2011 at 15:43 user1038375's user avatar user1038375user1038375 211 silver badge3 bronze badges Add a comment | 0

Maybe it's better to avoid control characters being sent through serial port at all, and instead slightly modify app on Linux and remote device to encode/decode them into/from two bytes. For example:

0x00 0x00 -> 0x00 0x00 0x01 -> 0x13 (escape XOFF) 0x00 0x02 -> 0x11 (escape XON)

Considering the probability of appearing of these 3 bytes in a binary stream this shouldn't decrease the overall throughput I think.

And by the way, XON/XOFF is a software flow control and basic function of serial/terminal drivers. Actually this function can be useful in your case too - to avoid buffers overflow and missing some valuable bytes you can pause (XOFF) or resume (XON) transmission.

Share Improve this answer Follow edited Nov 10, 2011 at 6:12 answered Nov 10, 2011 at 6:04 pmod's user avatar pmodpmod 11k1 gold badge39 silver badges56 bronze badges Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • The Overflow Blog
  • Your docs are your infrastructure
  • Featured on Meta
  • More network sites to see advertising test [updated with phase 2]
  • We’re (finally!) going to the cloud!
  • Call for testers for an early access release of a Stack Overflow extension...

Linked

-1 code won't run after compilation on kali 2 Read() function doesnt read the entire data on serial communication 4 Serial communication: 0x0D is replaced by 0x0A during transmission 0 Debugging of a simple char driver failing on container_of when reading from device attribute 1 Receive extra null byte when using serial port 0 Linux serial read() extraneous data 2 Serial communication on Linux with flow control enabled - bad behaviour 3 Reading data from different UART drivers 0 Linux Serial Port: missing data on input 2 Linux device driver called with wrong count 2 Fail to get data struct from serial port

Hot Network Questions

  • Is Holy Terra Earth?
  • Why is Ukraine's conscription age (still) so high (25)?
  • What powers do police have to force people onto trains?
  • What is 擦边 as in the case of the athlete champion turned dancer?
  • Is it possible to add arbitrary amounts of quantum resistance cheaply?
  • Is there a symbol for the Hyper key?
  • Is Isaiah's suffering servant the prophet Jeremiah?
  • Why didn't Steve Zahn receive a credit for Silo?
  • Wouldn't the ban of TikTok violate freedom of speech?
  • Configure Linux to regularly sync cached data to disk
  • How important is storytelling when submitting a grant application (or even a science paper)?
  • In GR, what is Gravity? A force or curvature of spacetime?
  • Student is almost always late, and expects me to re-explain everything he missed
  • Should sudo ask for root password?
  • Weapon Mastery and Weapon Cantrips
  • Table structure with multiple foreign keys and values
  • How do I go about rebranding a fully deleted project that used to have a GNU General Public License v3.0 but is now fully inaccessible
  • "Elegant" conditions on two quadratics (with positive real roots) to ensure that the larger root of one is less than the smaller root of the other
  • What is this insect found in an apartment in Brazil?
  • It will not last
  • Is there any advantage to using gifts to avoid estate tax?
  • A novel about Earth crossing a toxic cloud of cosmic size
  • Can you make 5 x 3 “magic” rectangles?
  • Does length contraction "break the speed limit"?
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-c

Từ khóa » C 0x13