Linux CNC terminal cannot display hexadecimal string

More
18 May 2022 08:33 #243254 by EdisonBin
Hello, brothers:
I'm new to Linux CNC and python
Recently, I wrote a python API for communication.

My procedure is very simple:
① Accept data from serial port
② Print to terminal
③ Send it back to the serial port intact

My PC uses the serial port assistant to send the hexadecimal string to linuxcnc, and I use Python language to print it on the terminal. Then send it back to the serial port assistant intact.

There are no problems in sending and receiving. The data sent is the same as the data received. But why? My terminal displays a blank? What should I do?
Attachments:

Please Log in or Create an account to join the conversation.

More
18 May 2022 10:56 #243260 by HansU
You have to convert the characters to ASCII if you want to display them in the terminal.
For example if you want to have a "0" displayed, you have to send 0x30.

See: www.rapidtables.com/code/text/ascii-table.html
The following user(s) said Thank You: EdisonBin

Please Log in or Create an account to join the conversation.

More
19 May 2022 02:55 #243311 by EdisonBin
Hello!
Is there no other way, because I don't want to change the data structure sent. I've written the program there and don't want to change it.
Can I change it at the python receiver? Let this character show

Please Log in or Create an account to join the conversation.

More
19 May 2022 04:17 #243313 by rodw
in python3, (eg master branch) where x is an integer
hex(x)
returns a hexadecimal string.
The following user(s) said Thank You: EdisonBin

Please Log in or Create an account to join the conversation.

Time to create page: 0.051 seconds
Powered by Kunena Forum