Closed Bug 2040379 Opened 3 months ago Closed 1 month ago

Detect WebSerial parity errors

Categories

(Core :: DOM: Web Serial, enhancement)

enhancement

Tracking

()

RESOLVED FIXED
155 Branch
Tracking Status
firefox155 --- fixed

People

(Reporter: gstoll, Assigned: gstoll)

References

Details

Attachments

(5 files)

Right now if the user sets ParityMode.even or ParityMode.odd Firefox doesn't actually detect parity errors. To implement this:

On Mac/Linux - we can set the PARMRK flag and then process the stream looking for the 0xff 0x0 pattern that indicates a parity error, and throwing a ParityError. This also means we have to look for 0xff 0xff (which is used to escape a 0xff byte that does not have a parity error) and remove one of the 0xff's. (Chrome does this with a CheckReceiveError decoder)

On Windows - we can call ClearCommError() to detect errors and throw a ParityError.

Assignee: nobody → gstoll
Status: NEW → ASSIGNED

Also do this for the new NS_ERROR_DOM_SERIAL_PARITY_ERROR nserror. This error
will get returned from parity decoders in parts 4 and 5.

This just passes the flag along - the actual parity checking will
be done in platform-specific code in parts 4 and 5.

On Windows, parity errors are reported through ClearCommError(), so add
a Win32SerialParityCheckStream stream wrapper that just calls that
and reports it when appropriate.

On Mac/Linux, setting the PARMRK flag on a serial port will cause it
to parity check by returning 0xff 0x00 (plus one additional byte) in
case of an error. "regular" 0xff bytes then have to be escaped by
returning 0xff 0xff. The PosixSerialParityDecodeStream handles both
of these cases.

Also add some gtests for PosixSerialParityDecodeStream (that run on all
platforms)

Component: DOM: Device Interfaces → Dom: Web Serial
QA Whiteboard: [qa-triage-done-c156/b155]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: