from time import sleep
from pySerialTransfer import pySerialTransfer as txfer
y = 0
if __name__ == '__main__':
try:
link = txfer.SerialTransfer('/dev/ttyACM0')
link.open()
sleep(5)
while True:
if link.available():
y = link.rx_obj(obj_type='i')
print(y)
elif link.status < 0:
if link.status == txfer.CRC_ERROR:
print('ERROR: CRC_ERROR')
elif link.status == txfer.PAYLOAD_ERROR:
print('ERROR: PAYLOAD_ERROR')
elif link.status == txfer.STOP_BYTE_ERROR:
print('ERROR: STOP_BYTE_ERROR')
else:
print('ERROR: {}'.format(link.status))
except KeyboardInterrupt:
link.close()
When I try to run the Python Code I get the error:
Traceback (most recent call last):
File "b.py", line 17, in
y = link.rx_obj(obj_type='i')
File "/home/clemens/.local/lib/python3.8/site-packages/pySerialTransfer/pySerialTransfer.py", line 346, in rx_obj
buff = bytes(self.rxBuff[start_pos:(start_pos + STRUCT_FORMAT_LENGTHS[obj_type])])
TypeError: 'str' object cannot be interpreted as an integer
Hi!
I want to transfer an Integer from my Arduino to my Computer. The Arduino script is based on: https://github.com/PowerBroker2/pySerialTransfer/blob/master/examples/datum/Arduino/tx_datum/tx_datum.ino
My Python Code is based on: https://github.com/PowerBroker2/pySerialTransfer/blob/master/examples/datum/Python/rx_datum.py
When I try to run the Python Code I get the error:
Traceback (most recent call last): File "b.py", line 17, in
y = link.rx_obj(obj_type='i')
File "/home/clemens/.local/lib/python3.8/site-packages/pySerialTransfer/pySerialTransfer.py", line 346, in rx_obj
buff = bytes(self.rxBuff[start_pos:(start_pos + STRUCT_FORMAT_LENGTHS[obj_type])])
TypeError: 'str' object cannot be interpreted as an integer
Is this a bug or am I missing something?
Best Regards, Clemens