LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Removing TCP hex codes from ascii string

I have a TCP connection to my VI and I'm using PuTTY to communicate with it. It is a basic terminal with a few commands. On boot my first command is always unrecognized because a few TCP protocol's are sent immediately beforehand:

Untitled.pngUntitled2.png


FF FB 1F “window size” FF FB 20 “terminal speed” FF FB 18 “terminal type” FF FB 27 “Telnet Environment Option” FF FD 01 “echo” FF FB 03 “suppress go ahead” FF FD 03 “suppress go ahead”

Each command is always proceeded by a command character "FF". I can remove the entire offending sting without any problem, however what I've been trying to do is remove any hex code following the command character. I have tried a few things with regular expressions without much luck. Any insight on how to solve this challenge would be appreciated!

Thanks,

Devin 

0 Kudos
Message 1 of 4
(3,055 Views)

One really easy solution would be to select "Raw" as the connection type instead of "Telnet" when you open PuTTY.

 

If that's not sufficient, it would help if you show your code. What are you trying to remove the command sequences from? I assume you have a TCP Read, you read a string, and then what? I'm not familiar with the details of the Telnet protocol, but I'd start by looking there to determine if every command has the same number of bytes (in which case you can simply skip over the appropriate number of characters), or if you need to parse the command to determine how many bytes to skip.

0 Kudos
Message 2 of 4
(3,026 Views)

Untitled.pngUntitled2.png

 

Thank you for your interest! This works for me, I'm sure it's not the most elegant way to accomplish it but It works. For the codes themselves I'm converting it from a spreadsheet string to an array and separating them by the 0xFF hex code.  

Message 3 of 4
(3,022 Views)

I'm not a regular expression power user, but I'd try something like the code below (right-click on "Search and Replace String" to set the "Regular Expression" option). This code looks for \FF followed by either \F0 through FA, or \FB through \FE followed by any other character, which I think matches the rules in the Telnet protocol as listed here: http://tools.ietf.org/html/rfc854 It replaces any match found with an empty string.

RemoveTelnetCommands.png

0 Kudos
Message 4 of 4
(3,003 Views)