#------------------------------------------------------------------------------- # This file is part of the FLARMĀ®-Radar Project. # # Copyright 2012-2014 Simon Moser # Copyright 2013-2014 Dominic Spreitz # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Project Website: www.flarmradar.ch # Email: info@flarmradar.ch #------------------------------------------------------------------------------- #!/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;