dji-sdk / RoboMaster-SDK

DJI RoboMaster Python SDK and Sample Code for RoboMaster EP.
Apache License 2.0
311 stars 142 forks source link

为啥串口通信uart中只有发送信息的serial_send_msg(),没有接受信息的方法呢? #32

Open Mr-teacherXia opened 3 years ago

Mr-teacherXia commented 3 years ago

今天用arduino测试ep的串口通信,尝试用serial_send_msg()从ep向arduino发送信息成功后,找了半天没找到ep读取串口信息的方法,去uart模块里一看才发现里面似乎没有接受串口信息的方法,只有一个 def serial_read_data(self, msg_len): pass 想问一下为啥不写读取串口信息的方法呢,现在ep用串口通信只能出不能进好难受哦

lanyusea commented 3 years ago

https://github.com/dji-sdk/RoboMaster-SDK/blob/a1dee654b5f4f2940893d89b7051d24b07d5b53f/src/robomaster/uart.py#L48

我理解应该是在这里。

读不像写是主动触发的动作,应当是回调行为

Mr-teacherXia commented 3 years ago

https://github.com/dji-sdk/RoboMaster-SDK/blob/a1dee654b5f4f2940893d89b7051d24b07d5b53f/src/robomaster/uart.py#L48

我理解应该是在这里。

读不像写是主动触发的动作,适当是某些行为

em....你这么说我我大概能理解什么意思,但是我还是不知道如何写代码读取串口信息,能指点一下吗,多谢了!

lanyusea commented 3 years ago

https://github.com/dji-sdk/RoboMaster-SDK/blob/a1dee654b5f4f2940893d89b7051d24b07d5b53f/src/robomaster/module.py#L65

可以参考上面get_version的写法,

使用send_sync_msg接口发送一个协议,协议的ack会返回出来

PhantomShuttle commented 3 years ago

我也遇到这个问题 如何能读取串口 我看到 RoboMaster-SDK/src/robomaster/uart.py 里有 应该可以把回调 放在 这个函数 sub_serial_msg 然后运行 start 但是sub_serial_msg的参数应该如果填写?

jeguzzi commented 2 years ago

I'm also failing to read the UART through the SDK. I see that there is a callback that should be triggered when a message with cmdset=0x3f and cmdid=0xc1 is received (which corresponds to a ProtoChassisSerialMsgSend prototype) but no such message is received by my EP running the latest firmware. UART writing through the SDK works fine. UART reading and writing through onboard Python (https://github.com/dji-sdk/RoboMaster-SDK/blob/master/docs/source/python/uart.rst) work also fine. I also notice that the SDK example related to UART (https://github.com/dji-sdk/RoboMaster-SDK/blob/master/examples/02_chassis/10_serial.py) just showcases reading.

My questions:

Vvi1Nn commented 6 days ago

Maybe there is no way to get RX data through SDK. When we use SDK to send TX data, first we create a protocal msg, and send this request to robomaster through network, then we can get a response msg.

However, in protocol.py, there is only a protocol for send msg (ProtoChassisSerialMsgSend), but no one for receive msg, so we cannot send reading RX protocol to S1. It's worth mentioning that, RX data is already be sent to S1 control board, we just cannot get it throught SDK.