I have a special application (8051 simulator from ucsim) on a local server that transmits and expects non-printable characters on only one port. Essentially, I'm defining my own data format.
Telnet would have been the perfect program if I can see the hex codes of each character returned back in 30 columns as well as being able to type hex codes of characters going out. Problem is, the telnet shipped with Linux only allows 1 row of hex characters and may alter behaviour when certain characters are received.
So far, the closest solution I have is to run the realterm program in wine and choose hex display, but the problem with it is that it locks up if I switch windows. until I stop the server from transmitting and receiving characters. So I'm looking for a native linux solution to all this.
As for receiving data, I can easily get away with this command:
nc 127.0.0.1 port | od -tx1 -w30
But when it comes to sending data on the same open port as what data is flowing out on, I try this command:
echo -e -n "\x11\x22\x33" | nc 127.0.0.1 port
where 11, 22, 33, are hexadecimal digits to send back out to the server. Problem is when I try this command, it just stalls and I have to press CTRL+C to exit.
Is my logic correct here?
or are there better commands I can use in unix to see hexadecimal characters from a server that transmits binary and also transmit binary codes of the hexadecimal characters typed in at the local console?
It would be perfect if the realterm program currently works in linux without the need of wine.
P.S. I'm sorry if this forum isn't the perfect place for this question, but personally, I wouldn't mind making a unix script of 50 commands if that's what it takes to get what I achieve, because the application I'm looking for has yet to exist for linux.
nc
will read from its standard input and send that data over the network connection. So if you simply want to be able to type hex digits into the terminal and have the corresponding binary sent to the simulator, you could use something likexxd -r -p
to pipe data intonc
. I.e. changenc 127.0.0.1 ...
toxxd -r -p | nc 127.0.0.1 ...
.You can then type "41 42 43 44" (followed by
return
, because interactive input is line-buffered) into thexxd
command and that should deliver "ABCD" to the simulator.xxd
in its-r -p
mode treats any non-hex digits as separators, so it's safe to put spaces between pairs of hex digits for readability if you want.If you wanted to be able to send different types of data (hex, binary) from a variety of sources (interactive, cat'ed from files) during the course of a development session then you could probably rig up a second persistent
nc
listener on a different port to collect that data and feed it into the stdin of the existingnc
.Update with a Python program that will read hex from stdin and send the corresponding binary over a network connection, and will read data from the connection and write is as hex to standard output. Save it as something like
nethex.py
and invoke it aspython nethex.py <host> <port>
.