#!/usr/bin/perl -w use strict; use Device::SerialPort; my $PortObj = new Device::SerialPort ("/dev/ttyAMA0"); $PortObj->baudrate(57600); $PortObj->parity("none"); $PortObj->databits(8); $PortObj->stopbits(1); $PortObj->handshake("none"); $PortObj->stty_igncr; $PortObj->are_match("\r\n"); $| = 1; my $count = 0; while (1) { my $char = $PortObj->lookfor(); chomp($char); if ($char) { print "Read " . $char . "\n"; } else { sleep(1); $count++; if ($count % 3 == 0) { my $cmd = "\$PFLAC,S,ACFT,0\r\n"; print " Send $cmd"; my $count_out = $PortObj->write($cmd); warn "write failed\n" unless ($count_out); warn "write incomplete\n" if ( $count_out != length($cmd) ); } } } exit 0;