I tried different versions of Ubuntu. Now I have installed the actual image from volkszaehler.org
It runs on a raspberry pi
The "cat /dev/ttyUSB0&" makes no difference if started before or after the stty settings.

The stty arguments are from a documentation, I tried your style and it seems to be running the same as before.
The meter system giving the commands "/?!" and "000" back, when I send it to him.
Every line ends with "\r\n".

I changed my code:

use Fcntl qw/:DEFAULT/;<br> use IO::Termios ();<br> use IO::Stty ();<br> <br> sysopen my $fh, '/dev/ttyUSB0', O_RDWR or die "sysopen: $!";<br> my $handle = IO::Termios->new($fh) or die "IO::Termios->new: $!";<br> $handle->set_mode('300,7,e,1');<br> IO::Stty::stty($handle, qw/ cs7 parenb -parodd raw -echo /);<br> <br> my $raw = "\x2F\x3F\x21\x0D\x0A";<br> $handle->syswrite($raw) == length($raw) or die "syswrite";<br> my $raw = "\x06\x30\x30\x30\x0D\x0A";<br> $handle->syswrite($raw) == length($raw) or die "syswrite";<br> <br> while(1) {<br> my $toread = 1;<br> $handle->sysread(my $in, $toread) == $toread or die "sysread";<br> print $in;<br> }<br> <br> $handle->close;<br> <br> <br>
And you see in strace my problem: (only last lines of output)
read(4, "/", 1) = 1<br> read(4, "L", 1) = 1<br> read(4, "O", 1) = 1<br> read(4, "G", 1) = 1<br> read(4, "4", 1) = 1<br> read(4, "L", 1) = 1<br> read(4, "K", 1) = 1<br> read(4, "1", 1) = 1<br> read(4, "3", 1) = 1<br> read(4, "B", 1) = 1<br> read(4, "D", 1) = 1<br> read(4, "2", 1) = 1<br> read(4, "0", 1) = 1<br> read(4, "2", 1) = 1<br> read(4, "0", 1) = 1<br> read(4, "1", 1) = 1<br> read(4, "5", 1) = 1<br> read(4, "\r", 1) = 1<br> read(4, "\n", 1) = 1<br> write(1, "/LOG4LK13BD202015\r\n", 19/LOG4LK13BD202015) = 19<br> read(4, <br>

After "read(4," the script waits endless

The only way it works, when I send the sequence (stty setting, then /?!\r\n, then 000\r\n) directly into a shell
So I can not understand what the problem could be.

In reply to Re^4: r/w attached infrared head on /dev/ttyUSB0 by stoerti
in thread r/w attached infrared head on /dev/ttyUSB0 by stoerti

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.