在Python中声明类型" uint8_t" *的变量的最佳方法是什么?
uint8_t pipe_num;
的第182行
https://github.com/maniacbug/RF24/blob/master/examples/starping/starping.pde
答案 0 :(得分:2)
ctypes库将帮助您将Python与C库连接,请参阅ctypes library documentation。您可能希望使用c_ubyte
或c_ushort
类型。
答案 1 :(得分:0)
目标尚不清楚。但是,我想你希望Python向Arduino发送一个字节,也许是通过串口等。 Python没有等效类型。对于你正在寻找的效果,“write”方法只发送字节。
import serial
arduino = serial.Serial(port,speed)
time.sleep(2) # may need 5s
byte = chr(0x31)
arduino.write(byte) # byte0<=i<=255
time.sleep(2)
arduino.close()
请注意,在打开端口之后和发送字节之前,您需要暂停,因为Arduino正在重置。
您还可以发送数组或字符串的部分......
mystring = "1234"
ser.write(mystring[0:1])