Question

Can the application use set same char in the XON and XOFF? If yes, how my device driver should handle this situation

Was it helpful?

Solution

XON and XOFF are two distinct ASCII characters, so they can not be equal.

That said, using a toggle for XON/XOFF-style flow control is a bad idea because characters may be lost. I also don't see any advantage over using two characters.

OTHER TIPS

If your driver is solely responsible for handling xon/xoff, and the xon/xoff flag characters can be identical, then I'd say you need to have a small state machine (flag) for the xon/xoff state in your driver, and only look for xon when xoff has already been seen.

If you have hardware support for xon/xoff, then you're going to have to figure out whether this state is supported by the hardware and return appropriate errors if not.

Although perhaps it is allowed, I have never seen this. I would think this is a recipe for disaster if the two sides get their state machines out of sync with a dropped byte.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top