Priya Pawar
Priya Pawar

Reputation: 21

Unable to print hex value of data receive from serial port

I need print hex value of '?' this character

currently, my script returns wierd characters such as '?' or '£☻ §"

I want to read them as proper hex value.

if choice == 8:
   incoming =ser.readline()     
   print incoming

Can anyone please help me with this?

Upvotes: 0

Views: 1585

Answers (1)

Preston
Preston

Reputation: 2653

Take a look at this post: Print a string as hex bytes?

You ultimately need to encode each character as it's raw hex byte using c.encode('hex') where c is a character in your string.

Upvotes: 1

Related Questions