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);
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.