Leser: 17
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
#!/usr/bin/perl use warnings; use strict; use Device::SerialPort; my $port = Device::SerialPort->new( "/dev/ttyUSB0" ); $port->baudrate(57600); $port->databits(8); $port->stopbits(1); $port->parity("none"); my $bytestring =""; my $status =0; while(1) { my $byte=$port->read(1); if ($byte =~ /L/) { $bytestring=""; $status=1; } if ($status==1) { $bytestring=$bytestring.$byte; } if ($byte =~ /;/) { my @data = split(/=/, $bytestring); if ($data[0] =~ /L/) { if (scalar(@data)>3) { } else { if (($data[scalar(@data)-1]=~ /20/)) { print "Check Okay"; } } } $status=0; } else { print "Failure"; open (FILE, '>statusrf12.txt'); print FILE "0"; close FILE; } sleep(3); }