# Set up the serial port # 9600, 81N on the USB ftdi driver $port = Device::SerialPort->new("/dev/ttyUSB0"); $port->databits(8); $port->baudrate(9600); $port->parity("none"); $port->stopbits(1); $port->read_const_time(100); # const time for read (milliseconds) $port->read_char_time(5); # avg time between read char $port->lookclear; # empty buffers $count_interval = 0; while (1) { readXML; sleep for the time interval before polling for data $e = $data->{Weather_Data_Interval}; $interval = $e->{value}; # Poll to see if any data is coming in $values = $port->lookfor(); # If we get data, then print it if ($values) { $values =~ s/#//g; $values =~ s/\$//g; $values =~ s/\r//g; @vars = split(/,/,$values); # high frequency logging writeValueXML; $count_interval++; # for displaying in website in the requested time interval if($count_interval == $interval){ appendLoggedFile; $count_interval = 0; } #print "$values\n"; } }