I am trying to interface to a device that accepts serial data signals, but the OS in the device only responds to very limited inputs and all the prefix and suffix stuff that goes with a typical serial port configuration is screwing it up.

The device accepts only data in a hex format....

for instance, I can send (using RealTerm 'Send Numbers' button): 0xc9

the device will respond with hex 'F401' which results in it not being processed at all by the receiving application (perl, hyperterm, etc). RealTerm will show the F401 response if I set the display settings to hex, but Perl does not register any response at all. If I send 0xC9 as ascii, the device cannot correct interpret all the ascii values of 0xC9 and all the prefix and suffix that goes with it.

So, I have two problems

1. How to limit the perl output to the port to be strictly the hex values I specify (not the ascii representation of the hex values)?

2. How to get perl to process back into my script the hex response?

any help at all is much appreciated. I am new this year to perl and so far am having a great time with it.

Cheers UPDATE: I think I am on to something...instead of

$pass=$PortOb->write($text);

I tried

$pass=$PortOb->transmit_char(0xc9);

and it sends only and exactly c9

now to find 'read_char'...but if there are other tips, happy to hear them, and thanks for the quick suggestions!


In reply to serial port hex only by ccherri

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.