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
  Decoding lat/long in file name johnmcd 4 414 Mar-22-2024, 11:51 AM
Last Post: johnmcd
  Enigma Decoding Problem krisarmstrong 4 790 Dec-14-2023, 10:42 AM
Last Post: Larz60+
  Microphone stream manipulation Talking2442 1 2,765 Nov-19-2023, 02:08 PM
Last Post: palumanic
  pyserial/serial "has no attribute 'Serial' " gowb0w 9 4,369 Aug-24-2023, 07:56 AM
Last Post: gowb0w
  EEG stream data with mne and brainfolw PaulC 0 509 Aug-22-2023, 03:17 AM
Last Post: PaulC
  json decoding error deneme2 10 3,745 Mar-22-2023, 10:44 PM
Last Post: deanhystad
  flask app decoding problem mesbah 0 2,379 Aug-01-2021, 08:32 PM
Last Post: mesbah
  Best Video Quality And Stream Harshil 2 2,272 Aug-19-2020, 09:03 AM
Last Post: Harshil
  xml decoding failure(bs4) roughstroke 1 2,287 May-09-2020, 04:37 PM
Last Post: snippsat
  python3 decoding problem but python2 OK mesbah 0 1,821 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