<?xml version="1.0" encoding="windows-1252"?>
<node id="955667" title="Telnet.pm and Negative Values for Modbus" created="2012-02-23 02:35:07" updated="2012-02-23 02:35:07">
<type id="115">
perlquestion</type>
<author id="955469">
PaulNg</author>
<data>
<field name="doctext">
&lt;p&gt;Latest update: Hi all, It's not the negative values that is throwing it off, rather the ff (Ascii chr 255) that the Telnet.pm can't seem to send! Can anyone advise me how can I do this? Thanks&lt;/p&gt;

&lt;p&gt;Hi all,&lt;/p&gt;

&lt;p&gt;I'm having problems with Telnet.pm and negative values. For some unknown reason, the reply in the buffer seems to be dropping characters, even a send doesn't seem to be sending correctly as the value on the controller did not respond. However, using a simulator, the value seems to have been sent correctly. Does anyone know why? All help is greatly appreciated. The controller I'm connected to is a WATLOW F4.&lt;/p&gt;

&lt;code&gt;---MODBUS Packet details---
Slave address: 1
Read Write: 6
Start Address 1: 01
Start Address 2: 2c
Value 1: ff
Value 2: 9b
CRC 1: 73
CRC 2: 164

ASCII characters sent: !,ÿI¤!
Buff data: !,I¤!&lt;/code&gt;

&lt;code&gt;
                $data = join('',@buffor);                           #Modbus frame to scalar
        #       chomp($data);
                print "ASCII characters sent: !$data!\n";
                if ($Telnet) {
                        $pass=$ob-&gt;print($data)
                        or warn "Modbus client : problem with send: $!\n";
                } else {
                        $pass=$ob-&gt;write($data)
                        or warn "Modbus client : problem with send: $!\n";
                }

                if ($Telnet) {
                        # Telnet
                        $TimeOut = int($TimeOut / 1000);         # Convert to seconds
                        $ob-&gt;errmode('return');
                        my $i = 0;
                        do {
                                $Buffer = $ob-&gt;get(TimeOut =&gt; 1);
                                print "Buff data: !$Buffer!\n";
                                if (defined($Buffer)) {
                                        $i = 0;
                                        $Reply .= $Buffer;
                                } else {
                                        $i++;
                                }
                        } until ((! defined($Buffer) and $i &gt;= $TimeOut) or length($Reply) &gt;= 8);
&lt;/code&gt;</field>
</data>
</node>
