Hi thndergnat,
I'm using ModBus RTU via a Digi CM-32 NTS. Basically I telnet onto the port and transmit the data over the Telnet line using ASCII characters. Weird enough it works perfectly with positive integers but once I use negative values, it seems to have a lot of problems. @buffor is the buffer I'm using to hold the data and it's a global array. Thanks for the help!
Regards,
Paul.
$buffor[0] = chr($slave_add);
$buffor[1] = chr($readwrite);
my $pack_val = unpack("H*",pack("n",$start_add));
my $tmp1= (substr $pack_val, 0, 2);
my $tmp2= (substr $pack_val, 2, 2);
$buffor[2] = chr(hex (substr $pack_val, 0, 2));
$buffor[3] = chr(hex (substr $pack_val, 2, 2));
$pack_val = unpack("H*",pack("n",$quantity));
my $tmp3= (substr $pack_val, 0, 2); #FF
my $tmp4= (substr $pack_val, 2, 2); #EB
$buffor[4] = chr(hex (substr $pack_val, 0, 2));
$buffor[5] = chr(hex (substr $pack_val, 2, 2));
$buffor[6] = chr(CRC_calc(1));
$buffor[7] = chr(CRC_calc(0));
my $tmp5 = CRC_calc(1);
my $tmp6 = CRC_calc(0);