-1

I'm using a program that reads data from a ubertooth-one device. I put the input data into a pipe file (made with mkfifo), but when i try to read the data i have the following error:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/lib/python3.9/threading.py", line 973, in _bootstrap_inner
    self.run()
  File "/usr/lib/python3.9/threading.py", line 910, in run
    self._target(*self._args, **self._kwargs)
  File "/home/k1k4ss0/Escritorio/proyecto/tests/tmp.py", line 44, in interpretar
    print ("{}".format(fifo.readline()))
  File "/usr/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb2 in position 2: invalid start byte

My code is this one:

# with FIFO as : '/tmp/pipe'
def interpretar():
  with open(FIFO) as fifo:
    while True:
      print ("{}".format(fifo.readline()))

The command excecuted is ubertooth-rx -q /tmp/pipe following the documentation:

• -q <file.pcap> : Capture packets to PCAP

k1k4ss0
  • 87
  • 10

1 Answers1

2

The data you are getting is not unicode/text so can't be decoded as such. Try open(FIFO, "rb") to open in binary mode and read (instead of readline) to read binary data.

Chris Dodd
  • 119,907
  • 13
  • 134
  • 226