Fazecast / jSerialComm

Platform-independent serial port access for Java
GNU Lesser General Public License v3.0
1.35k stars 287 forks source link

Parity Detection #260

Closed chrisgward closed 4 years ago

chrisgward commented 4 years ago

G'day all, it seems there exists no API to either read the parity bit, or detect a parity error. (Parity bit could be read by setting parity no SPACE_PARITY and detecting an error).

I'm currently (mis)using the library to speak 9 bit serial - outputting serial is okay, as setting MARK_PARITY or SPACE_PARITY adds the additional bit, but there seems to be no way to receive it, or detect errors.

chrisgward commented 4 years ago

Perhaps adding some API to set PARMRK would be a good solution

hedgecrw commented 4 years ago

I've looked into this and unfortunately, there's not a uniform platform/OS-independent way to implement this as would be required by this library. For instance, your recommendation of setting PARMRK in Linux to prepend bytes containing parity errors with additional error prefix bytes would only work under Linux. On Windows, there is no mechanism to do this, but rather bytes with parity errors can be fully replaced by a single character (which is not uniform with the PARMRK method nor particularly helpful since the replaced character could easily just have been what was actually transmitted and not a parity error). I'm definitely open to further suggestions if you have any, but at the moment, I'm not sure how this would work across OSs.

hedgecrw commented 4 years ago

Closing this due to unable to implement in an OS-agnostic way. If anyone comes up with a solution, please re-open and post here.