Send Modbus RTU command.
Button: [Settings] - [Externals] - [Modbus RTU] - Send.
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);
}
});
}