views:

105

answers:

3

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

+2  A: 

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.

Michael Kohne
+2  A: 

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.

Cade Roux
+3  A: 

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.

starblue