Invisible Airs, CCTV Camera, Chamber Room, Bristol, UK

bnr#38 => Invisible Airs, CCTV Camera, Chamber Room, Bristol, UK

test_arduino.pl

#!/usr/bin/perl

use warnings;
use strict;
use Device::SerialPort;

$|++;

my $port = init_serial();

my $lines = 0;
while(1) {

$port->write("a");

my $str = $port->lookfor();
print "start $str\n";
sleep 10;

$port->write("b");
$str = $port->lookfor();
print "stop $str\n";
sleep 11;

$port->write("c");
$str = $port->lookfor();
print "start $str\n";
sleep 10;

$port->write("d");
$str = $port->lookfor();
print "start $str\n";
sleep 10;

}

sub init_serial {
my @devs = qw(/dev/ttyUSB0 /dev/ttyUSB1);

my $port = undef;
for my $port_dev (@devs) {
$port = Device::SerialPort->new($port_dev);
last if $port;
}
if(!$port) {
die "No known devices found to connect to serial: $!\n";
}

$port->databits(8);
$port->baudrate(9600);
$port->parity("none");
$port->stopbits(1);

return $port;
}