Linux CNC terminal cannot display hexadecimal string
- EdisonBin
- Offline
- Senior Member
-
Less
More
- Posts: 54
- Thank you received: 4
18 May 2022 08:33 #243254
by EdisonBin
Linux CNC terminal cannot display hexadecimal string was created 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?
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?
Please Log in or Create an account to join the conversation.
- HansU
-
- Offline
- Platinum Member
-
Less
More
- Posts: 696
- Thank you received: 212
18 May 2022 10:56 #243260
by HansU
Replied by HansU on topic Linux CNC terminal cannot display hexadecimal string
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
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.
- EdisonBin
- Offline
- Senior Member
-
Less
More
- Posts: 54
- Thank you received: 4
19 May 2022 02:55 #243311
by EdisonBin
Replied by EdisonBin on topic Linux CNC terminal cannot display hexadecimal string
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
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.
- rodw
-
- Offline
- Platinum Member
-
Less
More
- Posts: 11309
- Thank you received: 3792
19 May 2022 04:17 #243313
by rodw
Replied by rodw on topic Linux CNC terminal cannot display hexadecimal string
in python3, (eg master branch) where x is an integer
hex(x)
returns a hexadecimal string.
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