source: core/trunk/client/test_readwrite.pl @ 292

Last change on this file since 292 was 280, checked in by smoser, 11 years ago

#156

  • Property svn:mime-type set to text/plain
File size: 822 bytes
Line 
1#!/usr/bin/perl -w
2
3use strict;
4use Device::SerialPort;
5
6
7my $PortObj = new Device::SerialPort ("/dev/ttyAMA0");
8$PortObj->baudrate(57600);
9$PortObj->parity("none");
10$PortObj->databits(8);
11$PortObj->stopbits(1);
12$PortObj->handshake("none");
13$PortObj->stty_igncr;
14$PortObj->are_match("\r\n");
15
16$| = 1;
17
18my $count = 0;
19while (1) {
20    my $char = $PortObj->lookfor();
21    chomp($char);
22    if ($char) {
23        print "Read " . $char . "\n";
24    } else {
25        sleep(1);
26        $count++;
27        if ($count % 3 == 0) {
28                my $cmd = "\$PFLAC,S,ACFT,0\r\n";
29                print "  Send $cmd";
30                my $count_out = $PortObj->write($cmd);
31                warn "write failed\n" unless ($count_out);
32                warn "write incomplete\n" if ( $count_out != length($cmd) );
33        }
34    }
35}
36
37exit 0;
Note: See TracBrowser for help on using the repository browser.