PaulNg has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,

I'm having some problems with IAC,interpret as command, I would like to know how to disable it in Telnet.pm? I need to read back the values after my controller sends 255/FF but IAC converts the stuff after that to jibberish and I am unsure if the setting is in Linux itself or in the Telnet.pm function. Thanks for the assistance!

Warmest regards, Paul.

Replies are listed 'Best First'.
Re: Telnet.pm and IAC
by Khen1950fx (Canon) on Feb 24, 2012 at 14:29 UTC
    "Disable" may not be the right term. For me, I think "use it, then remove it". Here's my first try.
    #!/usr/bin/perl -l use strict; use warnings; use Net::Telnet::Options; my $nto = Net::Telnet::Options->new(); my($ssocket) = 'This is a test'; open my $socket, "<", \$ssocket or die "Can't open socket scalar: $!"; my $data = chr(255); my $returned = $nto->answerTelnetOpts($socket, $data); print "SSocket : ", join(' ', map({ ord $_; } split(//, $ssocket))); close $socket;
Re: Telnet.pm and IAC
by thundergnat (Deacon) on Feb 24, 2012 at 16:12 UTC

    I replied to your previous node before I noticed this one.

    The problem is neither in Linux or Telnet.pm. It is working as specced. According to the Telnet RFCs, if you want to sent \xff as data you need to sent it twice to escape the escape. For example, to send the sequence: (\xff \xde), send (\xff \xff \xde).

      Hi thundergnat,

      Thanks for the responses. From the client's side I can send 2 FFs to escape the escape that's not a problem, the problem comes in when I readback data from the controller, I can't control the output from the WATLOW and it won't print 2 FFs! Basically I need to get the data as it is but since Telnet.pm or Fedora interprets the IAC as a command its not going to work :(

      Hi Khen1950fx

      I'm not entirely sure how the options work. For my script I'm currently using Net::Telnet() module. As I am quite new to Perl, how do I go about including the extra options module to my script? Thanks!

        If you cannot change the sending side, I think that using Net::Telnet is the wrong tool. Have you considered using simple plain sockets, via connect? All more specific layers will likely have problems with the data potentially containing delimiters.

        Also see Modbus. Especially Modbus::Client seems to be a potential solution, if you open the socket first and then pass it in to the Modbus::Client constructor.

        Actually the problem is not with the Watlow but with the Digi CM-32. The Watlow is communicating to the Digi CM-32 in Modbus RTU which has no issues with \xff characters.

        See if there is some option you can set in the Digi CM-32 to allow "raw" data mode or some such. If not, you may need to implement your ethernet communication with raw TCP sockets using IO::Socket::INET, which is what Net::Telnet uses under the hood.