in reply to Re: Re: Re: Com and Serial Ports
in thread Com and Serial Ports
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Com and Serial Ports
by BrowserUk (Patriarch) on Sep 26, 2003 at 19:20 UTC | |
by nofernandes (Beadle) on Sep 29, 2003 at 10:06 UTC | |
by BrowserUk (Patriarch) on Sep 29, 2003 at 15:31 UTC |