in reply to Using Device::SerialPort

hardy004:

If I had to guess, looking at your data, I'm guessing that it's 7 bits, even parity. So the characters with an odd number of bits (a, k) are coming through looking fine, and the ones with an even number of bits (c) parity are coming in with the high bit set. Setting the high bit on 'c' gives 0xe3, and I'm betting some unicode translation is occurring to give you the gibberish where the 'c' should be.

I'd try dumping the individual bytes you get for $saw to see the actual bytes Device::SerialPort is giving you. You can also just try changing the parity and word size to see if it fixes things up for you.

Note: It's been a good few years since I had to deal with parity & such, so I may have even/odd mixed up in my head, so I'd suggest setting data bits to 7 and try both and see if one works the way you expect.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Replies are listed 'Best First'.
Re^2: Using Device::SerialPort
by Anonymous Monk on Feb 11, 2015 at 15:03 UTC

    Interesting idea - just for reference, here's what the bytes are assuming the output is Windows-1252:

    my @data = (0x61, 0xAE, 0x6B, 0x7D, 0x72, 0x2E, 0x17, 0x8A); printf "%08b\n", $_ for @data; print "---\n"; printf "%08b\n", $_ for map ord, split //, "ack"; __END__ 01100001 10101110 01101011 01111101 01110010 00101110 00010111 10001010 --- 01100001 01100011 01101011

    That's for the second example string, for the first, the last byte would be 0x2C.