I have this code that i got from here.

Iīve used as you said the binmode $ob->{LOG}, ':UTF8'; but the problem is that it canīt catch the correct format!

How can i change the format in order to save the data from the serial port to the file correctly?

#!/usr/bin/perl use warnings; use Device::SerialPort 0.22; $LOGDIR = "/home/neo/telex_lusa/log"; $LOGFILE = "geiger.log"; $PORT = "/dev/ttyS0"; $ob = Device::SerialPort->new ($PORT) || die "Can't Open $PORT: $!"; $ob->baudrate(2400) || die "failed setting baudrate"; $ob->parity("none") || die "failed setting parity"; $ob->databits(8) || die "failed setting databits"; $ob->stty_icrnl(1) || die "failed setting convert cr to new line"; $ob->handshake("none") || die "failed setting handshake"; $ob->write_settings || die "no settings"; open(LOG,">>${LOGDIR}/${LOGFILE}")||die "can't open smdr file $LOGDIR/ +$LOGFILE for append: $SUB $!\n"; binmode $ob->{LOG}, ':UTF8'; select(LOG), $| = 1; # set nonbuffered mode, gets the chars out NOW open(DEV, "<$PORT") || die "Cannot open $PORT: $_"; while($_ = <DEV>){ print LOG $_; } undef $ob;

Thank you very much!

Nuno Fernandes

In reply to Re: Re: Com and Serial Ports by nofernandes
in thread Com and Serial Ports by nofernandes

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.