3 years, 3 months ago.
mbedRPC write feature not working for Python 3?
Has anyone ran into issues with sending serial commands to the mbed using Python 3. I'm currently using Python 3.5 and Pyserial 2.7 (had issues with Pyserial >3).
from mbedRPC_py3 import *
serdev = 3
mbed = SerialRPC(serdev, 9600)
x = RpcDigitalOut(mbed, "LED1")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\...\mbedRPC_py3.py", line 99, in write
r = self.mbed.rpc(self.name, "write", [str(value)])
File "C:\...\mbedRPC_py3.py", line 56, in rpc
File "C:\...\serialwin32.py", line 283, in write
data = to_bytes(data)
File "C:\...\serialutil.py", line 76, in to_bytes
b.append(item) # this one handles int and str for our emulation and ints for Python 3.x
TypeError: an integer is required
I'm clearly sending an int, but I think there is a problem because any value I write gets converted to a string in mbedRPC.py (In either "Class mbed_interface()" or "Class SerialRPC(mbed)"). I've been successfully sending serial commands to an mbed on another computer but I was using both Python and Pyserial versions 2
Question relating to:
To post an answer, please log in.