xarm_set_effector_modbus_rtu_cmd

1. 介绍

发送Modbus RTU指令。
按钮:设置-外接设备-Modbus RTU-发送。

2. 请求和回复

信息

{
    "cmd": "xarm_set_effector_modbus_rtu_cmd",
    "data": {
        "is_loop": false,
       "mdb_info": [
{"checked": true, "note": {"cn": "", "en": ""}, "delay": "1000", "cmd": "08 10 01 00 00 01 02 00 01"}
],
        "end_fmv": "2.6.0",
        "baudrate": 115200,
        "is_stop": true,
        "host_id": 9
    },
    "id": "1"
}

请求

名称数据类型是否必须描述
isloopboolNowhether to send Modbus commands cyclically.
mdb_infoArrayYes

command information. For example: [{'checked': True, 'note': {'cn':'','en': ''},'delay':'','cmd':'00 01 00 02'}]

('checked'- whether check the format is correct or not;'note'-{'cn':'','en': ''}'delay'-delay time'cmd'-modbus command)

end_fmvStringYesThe firmware version of end IO board, e.g.‘2.5.9’
buadrateintYesmodbus baud rate(4800-2500000)
is_stopintNowheter to stop sending the command
host_idintYes

Host ID.

11: linear motor

10: controller 485

9: tool end 485

回复

code=0->success;
code!=0->Failed, refer to xarm_api_code;

3. 示例

后台
if info_dic.get('checked', False):
    try:
        response(client, cmd_id, code=100)
        if cmd and is_run:
            cmd_li = re.sub(',', ' ', cmd)
            cmd_li = re.sub(' +', ' ', cmd_li)
            cmd_li = cmd_li.strip().split(' ')
            int_li = [int(da, 16) for da in cmd_li]
            send_time = ''.join(str(datetime.now())[11:23])
            host_id = data.get('host_id', 9)
            code, ret = GLOBAL.XArm.xarm.getset_tgpio_modbus_data(int_li, host_id=host_id)
            recv_time = ''.join(str(datetime.now())[11:23])
            if code == 0 and ret:
                recv = ''
                for da in ret:
                    re1 = hex(da)[2:]
                    if len(re1) == 1:
                        re1 = '0' + re1
                    recv = recv + ' ' + re1
                    recv = recv.upper()
                response(client, cmd_id, code,
                         {'recv': recv, 'send': cmd, 'send_time': send_time, 'recv_time': recv_time})
            else:
                return response(client, cmd_id, 1, {'send': cmd, })
    except Exception as e:
        logger.error(e)
        return response(client, cmd_id, 1, {'send': cmd, })
前端
self.setEffectorModbusCmd = (data, callback, host_id) => {
  const params = window.GlobalConstant.INIT_CMD_PARAMS_COMMON_DATA();
  Object.assign(params.data, data, {
    host_id: host_id,
  });
  self.sendCmd(window.GlobalConstant.SET_MODBUS_EFFECTOR_RTU_CMD, params, (dict) => {
    if (callback) {
      callback(dict);
    }
  });
} 
Logo

中国智能体开发者社区,聚焦智能体与大模型开发,提供前沿资讯、实用工具链、开源项目及行业案例。通过技术沙龙、开发者大赛等活动,促进经验交流与协作,助力开发者快速构建创新智能应用。

更多推荐