Serial port - Parity question - Printable Version +- Logic Machine Forum (https://forum.logicmachine.net) +-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1) +--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8) +--- Thread: Serial port - Parity question (/showthread.php?tid=570) |
Serial port - Parity question - Thomas - 20.01.2017 Hi I need to communicate via a serial line with a device which requires a special behavior of the parity bit. I've to send this strange structure: The communication is two bytes only. The first byte (address) must ends with parity bit always set to 1 The second byte (data) must ends with parity bit always set to 0 Fortunately the communication is 2 wires only. So I don't need to maintain signalling. Do you have any idea how to do it? Can I set parity setting to "Always 1" or "Always 0"? In this example I see none, even or odd. http://openrb.com/serial-port-communication-in-lm2/ Can I switch the parity settings after the port has already been opened? In case everything above fails. Can I: 1. Calculate parity for address 2. Open the serial port with the calculated parity setting 3. Send the address I want to set 4. close the port 5. Calculate parity for data 6. Open the serial port with the data calculated parity setting 7. Send the data 4. close the port I'm afraid about buffering. In case the sending won't be fast enough (or the script too fast) did the second port opening clear the sending buffer? Thank you for any ideas RE: Serial port - Parity question - admin - 20.01.2017 Sticky parity is not implemented because it's not standard and will not work on all supported platforms. Your approach should work, closing the port waits until all output has been transmitted. |