Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Decoding a serial stream
#2
b’\t\x9c\x1d\xc8LX\t\xfdXh\t\xbf\x1e\x8a^X{|\xbe\x85’ is a bytearray. When you print a bytearray it displays ascii characters when possible, or it uses hexadecimal notation. (\x). Since you are seeing \x in your byte array, it means that the bytearray data is either numbers or Unicode.

If you want to see the bytes as hex values you can do this:
import binascii

x = b'\t\x9c\x1d\xc8LX\t\xfdXh\t\xbf\x1e\x8a^X{|\xbe\x85'
print(binascii.hexlify(x))
Output:
b'099c1dc84c5809fd586809bf1e8a5e587b7cbe85'
If you want to convert it to a Unicode string use .decode().
Reply


Messages In This Thread
Decoding a serial stream - by AKGentile1963 - Mar-20-2021, 03:04 PM
RE: Decoding a serial stream - by deanhystad - Mar-20-2021, 03:31 PM
RE: Decoding a serial stream - by AKGentile1963 - Mar-20-2021, 04:30 PM
RE: Decoding a serial stream - by AKGentile1963 - Mar-20-2021, 04:33 PM
RE: Decoding a serial stream - by deanhystad - Mar-20-2021, 05:15 PM
RE: Decoding a serial stream - by AKGentile1963 - Mar-20-2021, 06:30 PM
RE: Decoding a serial stream - by bowlofred - Mar-20-2021, 07:08 PM
RE: Decoding a serial stream - by deanhystad - Mar-20-2021, 08:07 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pyserial/serial "has no attribute 'Serial' " gowb0w 11 21,868 Sep-27-2024, 12:18 PM
Last Post: NigelHalse
  Decoding lat/long in file name johnmcd 4 1,533 Mar-22-2024, 11:51 AM
Last Post: johnmcd
  Enigma Decoding Problem krisarmstrong 4 2,136 Dec-14-2023, 10:42 AM
Last Post: Larz60+
  EEG stream data with mne and brainfolw PaulC 0 988 Aug-22-2023, 03:17 AM
Last Post: PaulC
  json decoding error deneme2 10 8,109 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  flask app decoding problem mesbah 0 3,201 Aug-01-2021, 08:32 PM
Last Post: mesbah
  Microphone stream manipulation Talking2442 0 3,820 Jan-07-2021, 07:36 PM
Last Post: Talking2442
  Best Video Quality And Stream Harshil 2 3,076 Aug-19-2020, 09:03 AM
Last Post: Harshil
  xml decoding failure(bs4) roughstroke 1 3,010 May-09-2020, 04:37 PM
Last Post: snippsat
  python3 decoding problem but python2 OK mesbah 0 2,305 Nov-30-2019, 04:42 PM
Last Post: mesbah

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020