non credo che sia un problema di codifica, ti posto il codice che ho fatto
è collegata una sonda che rileva valori come temperatura e variecodice:#!/usr/bin/perl -w use Device::SerialPort qw( :PARAM :STAT 0.07 ); $pass = ''; $out = ''; $PortName = "/dev/ttyS1"; #$port = new Device::SerialPort ($PortName); $port = new Device::SerialPort ("/dev/ttyS1") || die "Can't open $PortName: $!\n";; $port->baudrate(19200); $port->databits(8); $port->stopbits(1); $port->parity("none"); $i=1; while($i){ $pass = $port->write('S$') ; $j=0; while ( $j==0){ $out = $port->input; if ( $out ne '' ){ $_ = $out; if ( m/S:/ ){ $string = ''; $string = $_ ; }#end string start elsif ( m/:$/ ){ $string = $string + $out ; print $string; $j=1; $i=''; }#deal with the end stuff else { $string = $string + $out ; } }#end if for read out }#close while $j }#close while $i
devo solo intercettare cosa legge, cioè trasformare le stringhe che ho in dati che poi inserisco in un db
la difficoltà è leggere e successivamente scrivere (inviare) sulla porta rs232.
sai darmi qualche info, qualche dritta, ho sbagliato logica ?
grazie

Rispondi quotando