I downloaded some code from Github for interfacing with a lab equipment:
readBuffer=ctypes.create_string_buffer(1024)
# some C functions modifying readBuffer using ctypes
deviceInfoList=readBuffer.value.split(',')
The last line shows an error: TypeError: a bytes-like object is required, not 'str'
print(type(readBuffer.value)) shows <class 'bytes'>, and print(readBuffer.value) shows b'0,NEWPORT 1936-R v1.2.2 04/06/12 SN22955\r;'.
According to the SDK documentation file, readBuffer is 'a character buffer with the following format: <DeviceID1>,<DeviceDescription1>;<DeviceID2>,<DeviceDescription2>;<DeviceIDX>,<DeviceDescriptionX>. The last line of the code wants to extract the device ID (which is 0).
Split should be a string method if I'm not mistaken, readBuffer.value looks like a byte, while the error complains that it is string not byte. What has gone wrong here?