我用过Hobbyporter F405。我需要从树莓派或arduino发送命令。我不知道需要发送什么命令来控制油门和其他。我已经在聊天 gpt 上询问了代码,但它不起作用。所以请帮助我。寻求任何帮助。也许有带有命令的协议,找不到。
baud_rate = 115200
port = /dev/tty.usbmodem0x80000001
def send_throttle_command(ser, throttle_value):
try:
ser.write(b'throttle {throttle_value}\n')
time.sleep(0.1)
except Exception as e:
print("throttle:", e)
with serial.Serial(port, baud_rate, timeout=1) as ser:
throttle_value = 1100
send_throttle_command(ser, throttle_value)
这是来自聊天 gpt 的代码,但这不起作用。
#!/usr/bin/env python
import time
import serial
baud_rate = 115200
port = "/dev/ttyS0" #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
ser = serial.Serial(
port=port,
baudrate = baud_rate,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
command_for_throttle = 'throttle 1100' # You need enter you command
try:
ser.write(command_for_throttle)
time.sleep(0.1)
except Exception as e:
print("throttle:", e)