def uart_formate_ocu_spd_remote():#速度遥控命令
global rx_data,tx_data,rx_cnt,rx_num_now,uartState,print_cnt,BYTE0,BYTE1,BYTE2,BYTE3
global Baudrate,COM,Stopbits,ser,ReadUARTThread,cond_d,stop_d
sum = 0
_cnt = 0
data_to_send = []
data_to_send.append(0xAA)
data_to_send.append(0xAF)
data_to_send.append(0x32)#机器人参数
data_to_send.append(0)
send_char(data_to_send,88)#88
send_float(data_to_send,gl.get_value('OCU_SPD_XY')[0])#
send_float(data_to_send,gl.get_value('OCU_SPD_XY')[1])#
send_float(data_to_send,gl.get_value('OCU_ATT_PR')[0])#
send_float(data_to_send,gl.get_value('OCU_ATT_PR')[1])#
send_float(data_to_send,gl.get_value('OCU_YAW_RATE'))#
send_char(data_to_send,gl.get_value('OCU_CMD_START'))#
send_char(data_to_send,gl.get_value('OCU_CMD_BACK'))#
send_int(data_to_send,gl.get_value('OCU_CMD_LR'))#
send_int(data_to_send,gl.get_value('OCU_CMD_FB'))#
send_char(data_to_send,gl.get_value('OCU_CMD_X'))#
send_char(data_to_send,gl.get_value('OCU_CMD_Y'))#
send_char(data_to_send,gl.get_value('OCU_CMD_B'))#
send_char(data_to_send,gl.get_value('OCU_CMD_A'))#
send_char(data_to_send,gl.get_value('OCU_CMD_LL'))#
send_char(data_to_send,gl.get_value('OCU_CMD_RR'))#
_cnt = len(data_to_send)
data_to_send[3] = _cnt - 4
for i in range(0,_cnt):
sum = sum+ data_to_send[i]
data_to_send.append(BYTE0(int(sum)))
tx_data[0:len(data_to_send)]= data_to_send
gl.set_value('UART_TX_LEN',len(data_to_send))
return len(data_to_send)
R
rcx5
@rcx5
0
声望
3
楼层
232
资料浏览
0
粉丝
0
关注
rcx5 发布的帖子
-
这段代码里哪些是和串口通信协议有关的?
-
这个可以在Linux系统内运行的如何用openmv写出来?
def uart_formate_ocu_spd_remote():#速度遥控命令 global rx_data,tx_data,rx_cnt,rx_num_now,uartState,print_cnt,BYTE0,BYTE1,BYTE2,BYTE3 global Baudrate,COM,Stopbits,ser,ReadUARTThread,cond_d,stop_d sum = 0 _cnt = 0 data_to_send = [] data_to_send.append(0xAA) data_to_send.append(0xAF) data_to_send.append(0x32)#机器人参数 data_to_send.append(0) send_char(data_to_send,88)#88 send_float(data_to_send,gl.get_value('OCU_SPD_XY')[0])# send_float(data_to_send,gl.get_value('OCU_SPD_XY')[1])# send_float(data_to_send,gl.get_value('OCU_ATT_PR')[0])# send_float(data_to_send,gl.get_value('OCU_ATT_PR')[1])# send_float(data_to_send,gl.get_value('OCU_YAW_RATE'))# send_char(data_to_send,gl.get_value('OCU_CMD_START'))# send_char(data_to_send,gl.get_value('OCU_CMD_BACK'))# send_int(data_to_send,gl.get_value('OCU_CMD_LR'))# send_int(data_to_send,gl.get_value('OCU_CMD_FB'))# send_char(data_to_send,gl.get_value('OCU_CMD_X'))# send_char(data_to_send,gl.get_value('OCU_CMD_Y'))# send_char(data_to_send,gl.get_value('OCU_CMD_B'))# send_char(data_to_send,gl.get_value('OCU_CMD_A'))# send_char(data_to_send,gl.get_value('OCU_CMD_LL'))# send_char(data_to_send,gl.get_value('OCU_CMD_RR'))# _cnt = len(data_to_send) data_to_send[3] = _cnt - 4 for i in range(0,_cnt): sum = sum+ data_to_send[i] data_to_send.append(BYTE0(int(sum))) tx_data[0:len(data_to_send)]= data_to_send gl.set_value('UART_TX_LEN',len(data_to_send)) return len(data_to_send)