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!

In reply to Device:SerialPort 0.20 Parity by gary kuipers

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.