0

I'm doing a project for a microcontroller that involves sending and receiving special (non-printable character) data through its serial port.

I found myself a simulator (ucsim) so I can test things out. I want to take advantage of its bi-directional serial port.

I tried its option of using unix files for port operation, and that worked a little clunky (probably because it relies on the operation of the termios subsystem).

So I have better ideas. I can use the program to make a server via TCP/IP that acts like a microcontroller serial port. The closest "perfect" setup I have is running "realterm" in Wine. It's a terminal designed for engineers. The problem with that program is that it locks up at unexpected times.

So I made myself an excellent setup to log the data coming from the virtual microcontroller (ucsim) as follows:

1. Execute: s51 -k9876 /path/to/hexfile.hex
2. Open a second window
3. Run in 2nd window: nc 127.0.0.1 9876 | od -tx1 -w30
4. type r in simulator window to run 8051 machine code
5. Switch to 2nd window to see results

s51 is the main executable unpacked from ucsim that simulates an 8051 processor and the hexfile is my code that is injected into it. The number after -k is the port number I chose to use as the server port. This setup works without lockup.

Now what I want to do is also the reverse of what I demonstrated.

I want to be able to specify the data I want to send back to the live simulator server (at address 127.0.0.1 port 9876) in hexadecimal format, but the server will receive it as raw character data.

For example, Say I want the server to receive "ABCD" without quotes. Then I want to specify that I want to send 41h 42h 43h and 44h respectively since those are hexadecimal values for each of the characters.

So far, I can achieve the first step with the following command:

echo -e -n "\x41\x42\x43\x44"

Now if the server was instead a simple file, I could do the following:

echo -e -n "\x41\x42\x43\x44" > /path/to/file

But I want to send it to the server so it can process the data.

How do I go about doing this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.