Heading from LDS UDP datagrams
A simple Perl app to listen for navigation data messages on the 'net; grab NMEA HDT messages and write them out a local serial port for intput to a SeaSpace Terascan or WDS (Weather Decision System)
First an app for testing the serial output stuff:
#!/usr/bin/perl
#
# $Id: test-serial.pl,v 1.1 2005/09/10 10:39:51 dale Exp $
# Dale Chayes
# Instrument Lab
# Lamont-Doherty Earth Observatory of Columbia University
#
# Created September 9, 2005
#
# This is intentend as a rapid prototype to figure out what the exact
# serial port parameters for output to the Terascan/WDS.
#
# $Log: test-serial.pl,v $
# Revision 1.1 2005/09/10 10:39:51 dale
# Rapid prototype for configuring serial output from Perl
#
#
use Device::SerialPort; # for the serial port, available from CPAN
# on a Windows box you would use Win32::SerialPort
# http://members.aol.com/Bbirthisel/SerialPort.html
# NOTE:
# 1) Paste a more or less correct string in here for testing
# 2) It's possible that the $IN part of the INHDT string will
# not be acceptable to the WDS/Terascan, it may be expecting
# $HDHDT instead.
#
# 3) It is very possible that the WDS is not looking at the checksum
# in which case you can simply change it. The "$" (dollar sign)
# is likely to be required as part of the NMEA spec.
#
# 4) the WDS is probably looking for a carriage return and a line feed
# at the end off each line so you may hav eto experiment with
# end of line characters.
$OutputString="\$INHDT,150.7,T*26\n";
$PortName="/dev/ttyS1"; # could be S0 (for built in)
$lockfile = "/tmp/serial_test.lck";
# Create the "port object"
#$PortObj = new Device::SerialPort ($PortName, $quiet, $lockfile)
$PortObj = new Device::SerialPort ($PortName)
|| die "Can't open $PortName: $!\n";
# @handshake_opts = $PortObj->handshake;
# print "The handshake options are: ", @handshake_opts ;
# Configure the serial port
$PortObj->baudrate(4800);
$PortObj->parity("none"); # or "odd" or "even"
$PortObj->databits(7);
$PortObj->stopbits(1);
$PortObj->handshake("none"); # or "xoff" or "rts" try "man stty"
# $PortObj->stty_ocrlf; # does not see to work
# probably carriage return and linefeed
$x=0;
while ($x < 10) {
$count_out = $PortObj->write($OutputString);
printf("Wrote (%d)\t%s", $x, $OutputString);
sleep(1);
$x=$x+1;
}
$PortObj->close || warn "close failed";
undef $PortObj; # returns memory (who cares?)
printf("That's all folks\n");