bacnet_scan output a csv file error TypeError: a bytes-like object is required, not 'str'

60 views Asked by At

When running bacnet_scan.py it looks like this:

(volttron) (base) bartlino@bartlino-Latitude-E5530-non-vPro:~/Desktop/volttron/scripts/bacnet$ python bacnet_scan.py

Device Address        = <Address 192.168.0.190>
Device Id             = 0
maxAPDULengthAccepted = 1476
segmentationSupported = noSegmentation
vendorID              = 245

Device Address        = <Address 192.168.0.102>
Device Id             = 3056183
maxAPDULengthAccepted = 1024
segmentationSupported = segmentedBoth
vendorID              = 842

Device Address        = <RemoteStation 12345:2>
Device Id             = 201201
maxAPDULengthAccepted = 286
segmentationSupported = noSegmentation
vendorID              = 11

Trying to add on a csv file output with python bacnet_scan.py --csv-out ~/Desktop/volttron/configs/test_mult.csv

I get an error:

Traceback (most recent call last):
  File "bacnet_scan.py", line 203, in <module>
    this_csv_file.writeheader()
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 143, in writeheader
    return self.writerow(header)
  File "/home/bartlino/anaconda3/lib/python3.8/csv.py", line 154, in writerow
    return self.writer.writerow(self._dict_to_list(rowdict))
TypeError: a bytes-like object is required, not 'str'

Any tips?

1

There are 1 answers

3
jklarson On BEST ANSWER

If you are not working out of the latest development branch, I'd suggest trying that first, as there was a PR accepted after the 8.0 release that fixed an issue related to bytes vs string in the output of this script. I'm also not certain how they'd interact, but you appear to have 2 virtual environments activated currently, and its possible that's messing with some versioning... Since its Python3.8 for your Anaconda, I'm doubtful of that, but its something to consider.