#!/usr/bin/perl use warnings; use strict; use Device::SerialPort; my $ccnt; my $port = '/dev/ttyUSB0'; my $conf = '~/.conf-pasha'; my $ob = Device::SerialPort->new($port, 1) || die "Can't open $port: $!"; my $STALL_DEFAULT = 10; my $timeout = $STALL_DEFAULT; my $arb = $ob->can_arbitrary_baud; my $data = $ob->databits(8); my $baud = $ob->baudrate(19200); my $parity = $ob->parity("none"); my $hshake = $ob->handshake("rts"); my $stop = $ob->can_stopbits; my $rs = $ob->is_rs232; my $total = $ob->can_total_timeout; $ob->stopbits(1); $ob->buffers( 4096, 4096 ); $ob->can_baud; $ob->can_databits; $ob->can_dtrdsr; $ob->can_handshake; $ob->can_parity_check; $ob->can_parity_config; $ob->can_parity_enable; $ob->can_rtscts; $ob->can_xonxoff; $ob->can_xon_char; $ob->can_spec_char; $ob->can_interval_timeout; $ob->can_ioctl; $ob->can_status; $ob->can_write_done; $ob->can_modemlines; $ob->can_wait_modemlines; $ob->can_intr_count; $ob->write_settings; my ($count, $string, $name, $value); my @vals; while(1) { $ccnt++; $ob->lastline("\n"); ($count, $string) = $ob->read(255); print "$ccnt\n\n"; @vals = split("\n", $string); foreach (@vals) { $_=~ s/\t/\=/; $_=~ s/\r//; $_=~ s/\n//; ($name, $value) = split("=", $_); next unless ($name); $value = 0 unless ($value); $value = $value/1000 if $name =~ /I/g; print "$name=$value\n"; } sleep(1); } $ob->write_drain; $ob->close; undef $ob