Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^2: Telnet.pm and Negative Values for Modbus

by PaulNg (Novice)
on Feb 24, 2012 at 02:00 UTC ( [id://955853]=note: print w/replies, xml ) Need Help??


in reply to Re: Telnet.pm and Negative Values for Modbus
in thread Telnet.pm and Negative Values for Modbus

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);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://955853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-23 18:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found