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

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

Update Copyright, fix encoding issue

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