gary kuipers has asked for the wisdom of the Perl Monks concerning the following question:
The device with which I am communicating has an odd serial protocol:
1 start bit
8 data bits
1 "wakeup bit"
1 stop bit
The commands sent to this device can be of arbitrary length. The first byte of the command must have the wakeup bit "set" and the remaining bytes of the command should have the wakeup bit as 0.
Device::SerialPort does not have "wakeup bit" (and does not implement parity "mark" or parity "space") but the task is not difficult: For each character to be sent switch the parity to even or odd as required. Device::SerialPort's documentation even tells one how to change and reset with "save" and "restart" methods. It looks like paramenters can be changed on the fly. So far so good. Looks like a 30 minute project.
To start with I chose command 81 hex (129 dec) which, when sent with the wakeup bit set (by my calculations 81 hex has 2 bits on and the parity should be set to odd for this command to emulate a "wakeup bit").
Sending this command has no effect. The device remains mute. (I do have another program written in C that makes the device respond correctly on the same hardware I am developing this perl program on).
1
Next step: Tie off the transmit and receive lines. Looks good as what I am sending (129 decimal) is what I am receiving (129 decimal). But here's the catch: When I read I am reading with no parity, when I write I am writting with odd parity: yet the Device::SerialPort gives no parity error or warning. The parity_enable method does not get unhappy when called, so presumably I am in control of the parity, yet both the device and the loopback are behaving as if the parity settings are being ignored.
This is not as far-fetched as it might seem. In the C program (mentioned earlier) the serial devices "supposedly" can change settings on the fly. In practice I had to shutdown and restart the ports in order for the settings to change. (I also tried doing that in the perl implementation but the behaviour did not change. The parity looks like it is ignored).
Is there a Monk out there with some experience with Device::SerialPort on RH 9.0 that might tell me which way to go next? Does parity actually work in Device::SerialPort 0.20??
Thanks!