For opening context, I'm writing a script that will eventually test the robustness of a CLI interface on my TI development board, but before I scream out for help on the general functionality I figured I'd try troubleshooting it myself first. (probably learn more besides ;)

The problem is I'm having a hard time understanding what the board is sending back to me because I believe it is being obfuscated by the interpolation of the board's output.

Here's the setup:

  1. I write the input with Win32-SerialPort-0.19
  2. Input: a string written to the serial port
  3. Output: the CLI program parses when it sees carriage return and returns either OK, Not Supported, or Command Nor Found if the input node exists and the command is valid, if the node exists but is not compatible with the given command, or if the node/command don't exist respectively.
  4. I read the contents of the serial port with Win32-SerialPort-0.19

Here's the relevant piece of the code:

use strict; use warnings; use Win32::SerialPort; # Open COM port my $COM = Win32::SerialPort->new('COM1') || die("Can't open port."); # Input my $sCommand = "SET INTERFACE NETWORK CLI:0 ENABLE"; $COM->write("$sCommand\r"); $COM->read_interval(100); my $iReadBuffer = length($sCommand); my ($count, $sEcho) = $COM->read($iReadBuffer); # Output print "----------------\n"; print "$sEcho\n"; print "----------------"; undef $COM;

Here's what is printed:

---------------- OK SET INTERFACE NETWORK CLI:0 ----------------

While I'm expecting either:

---------------- ---------------- OK or OK SET INTERFACE NETWORK CLI:0 ---------------- ----------------

The point is I'm unsure exactly what the CLI is sending me. I know that you can print a literal string by defining it with single quotes, but since I'm not the one defining this string (merely grabbing it and sliding it into the $sEcho variable) how do I print the literal, uninterpolated string?

All my searches to this point have returned hits on single qoute printing of literal strings; so thanks in advance for your help!


In reply to Printing Literal Contents of a Variable by lyos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.