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

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

Release 1.2.0

  • Property svn:mime-type set to text/plain
File size: 1.8 KB
Line 
1#-------------------------------------------------------------------------------
2# This file is part of the FLARM®-Radar Project.
3#   
4#   Copyright by the Authors
5#
6# Licensed under the Apache License, Version 2.0 (the "License");
7# you may not use this file except in compliance with the License.
8# You may obtain a copy of the License at
9#
10#   http://www.apache.org/licenses/LICENSE-2.0
11#
12# Unless required by applicable law or agreed to in writing, software
13# distributed under the License is distributed on an "AS IS" BASIS,
14# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15# See the License for the specific language governing permissions and
16# limitations under the License.
17#
18#   Project Website: www.flarmradar.ch
19#   Email: info@flarmradar.ch
20#   Authors:
21#     2012-2014 Simon Moser
22#     2013-2014 Dominic Spreitz
23#     2014-2014 Giorgio Tresoldi
24#-------------------------------------------------------------------------------
25#!/usr/bin/perl -w
26
27use strict;
28use Device::SerialPort;
29
30
31my $PortObj = new Device::SerialPort ("/dev/ttyAMA0");
32$PortObj->baudrate(57600);
33$PortObj->parity("none");
34$PortObj->databits(8);
35$PortObj->stopbits(1);
36$PortObj->handshake("none");
37$PortObj->stty_igncr;
38$PortObj->are_match("\r\n");
39
40$| = 1;
41
42my $count = 0;
43while (1) {
44    my $char = $PortObj->lookfor();
45    chomp($char);
46    if ($char) {
47        print "Read " . $char . "\n";
48    } else {
49        sleep(1);
50        $count++;
51        if ($count % 3 == 0) {
52                my $cmd = "\$PFLAC,S,ACFT,0\r\n";
53                print "  Send $cmd";
54                my $count_out = $PortObj->write($cmd);
55                warn "write failed\n" unless ($count_out);
56                warn "write incomplete\n" if ( $count_out != length($cmd) );
57        }
58    }
59}
60
61exit 0;
Note: See TracBrowser for help on using the repository browser.