$data = join('',@buffor); #Modbus frame to scalar # chomp($data); print "ASCII characters sent: !$data!\n"; if ($Telnet) { $pass=$ob->print($data) or warn "Modbus client : problem with send: $!\n"; } else { $pass=$ob->write($data) or warn "Modbus client : problem with send: $!\n"; } if ($Telnet) { # Telnet $TimeOut = int($TimeOut / 1000); # Convert to seconds $ob->errmode('return'); my $i = 0; do { $Buffer = $ob->get(TimeOut => 1); print "Buff data: !$Buffer!\n"; if (defined($Buffer)) { $i = 0; $Reply .= $Buffer; } else { $i++; } } until ((! defined($Buffer) and $i >= $TimeOut) or length($Reply) >= 8);