#!/usr/bin/perl # send a unit config command to a radio use strict; use IO::Socket; use Socket; use Getopt::Long; use constant SG90_PORT => '3123'; use constant MSG_TYPE_SG90TX => 0x01; sub Usage { print "Example: sendSG90TestCmd --ip \"10.20.30.145\"\n"; die; } my $radioIP; use Time::HiRes qw(usleep); GetOptions("ip=s" => \$radioIP); Usage unless $radioIP; my $sock = IO::Socket::INET->new(Proto=>'udp', PeerAddr=>$radioIP, PeerPort => SG90_PORT) or die "Could not create Socket : $!\n"; my $cmd = MSG_TYPE_SG90TX; my $msg = pack('C16', $cmd, #msgType 1, #in UL, this is format ID 0, 0, 0, 0x20, 0x32, 6, 0, 3, 0x15, 0x22, 0x20, 0, 0x6c, 0x99 ); $sock->send($msg) || die "Couldn't send: $!"; print "Sent message to $radioIP\n"; usleep(100000);