Move Packets from HCA to Arduino

This Perl program is called by HCA, using three parameters to format and send a packet to the appropriate Arduino.  The 3 parameters are command, IP address and data.  HCA sends them in that order as flags ardcmd1, ardaddr1 and arddata1 respectively.  See this posting for more information.

use IO::Socket::INET;
use Getopt::Long;  #pick up parms

my $cmdIn = sprintf(“%.0f”,$ARGV[0]);
my $addrOut = $ARGV[1];
my $dataIn = sprintf(“%.0f”,$ARGV[2]);

my $dataOut = $cmdIn . $dataIn;
# print “$cmdOut\n”;
# print “$addrOut\n”;
# flush after every write
# $| = 1;
# my $dot68 = “192.168.0.68”;

#  we call IO::Socket::INET->new() to create the UDP Socket and bound
# to specific port number mentioned in LocalPort and there is no need to
# provide LocalAddr explicitly as in TCPServer.
my $socket = new IO::Socket::INET (
LocalPort => 6001,
Proto => ‘udp’,
PeerPort => 5001,
PeerAddr => $addrOut,
) or die “ERROR in Socket Creation : $!\n”;

# read operation on the socket
# $socket->recv($received_data,1024);

# get the peerhost and peerport at which the recent data received.
# $peer_address = $socket->peerhost();
# $peer_port = $socket->peerport();
# print “\n($peer_address , $peer_port) said : $received_data”;

#send the data to the arduino.
# $data = ‘1’;
print $socket “$dataOut”;

$socket->close();

As In Various and Sundry