#!/usr/bin/perl
# Note this adaptor is for the sole use with Quasar 3145 temp module
require 'all_functions' ;
use Device
::SerialPort 0.12 ;
$index = &init_index ; # This will stop the adaptor reading in old messages
# on reboot, could be $index=0 if you want it to do this.
#Set up serial port
$PORT = "/dev/ttyS5" ;
$ob = Device
::SerialPort->new ($PORT) || die "Can't Open $PORT: $!";
$ob->baudrate(9600) || die "failed setting baudrate";
$ob->parity("none") || die "failed setting parity";
$ob->databits(8) || die "failed setting databits";
$ob->stopbits(1) || die "failed setting stopbits";
$ob->handshake("none") || die "failed setting handshake";
$ob->write_settings || die "no settings";
open(DEV
, "<$PORT") || die "Cannot open $PORT: $_";
$def_msg = "ha~dmx~lighting" ;
&print_banner ;
while(1)
{
@new = &find_new_messages($index) ;
#print $index ;
foreach $new (@new)
{
chomp ($new) ;
($index,$message)=split(/\|/,$new) ;
($type,$content)=split(/\~\~/,$message) ;
if ( $type eq "ha~dmx~lighting" )
{
#print $message . "\n";
($channel,$intensity)=split(/~/,$content) ;
#print $channel . " - channel \n" ;
#print $intensity . " - intensity \n";
# send data out
$ob->write( pack "C", $channel ) ;
$ob->write( pack "C", $intensity ) ;
}
}
&mini_sleep(10) ;
}