FIX 1.增加铁芯处理分支;

main
wangbo 1 month ago
parent 157291cecc
commit 12dc851e46

@ -9,10 +9,16 @@ typedef int32_t (*csgiron_recv_fun_cb)(uint8_t, char*, uint16_t);
typedef struct
{
uint8_t vport; // slot 1~8
uint8_t reserved[1];
uint16_t report_period;
uint8_t reserved[2];
} iron_config_t;
typedef struct {
uint8_t vport; // slot编号 1~8
uint8_t result; // 应答结果. 0:成功 1:失败
uint8_t reserved[2]; // 保留
}iron_ack_t;
extern int32_t _csgiron_recv_process(uint8_t slot, char *pkt, uint16_t len);
#endif

@ -931,7 +931,8 @@ int32_t _csg_recv_process(char *pkt, uint32_t len)
return E_ERROR;
}
if (DEVICE_M_TYPE == typem && 4 == types)
if (DEVICE_M_TYPE == typem && DEVICE_IR_TYPE == types
&& CSG_C_ADD_DAU != head->cmd)
{
_csgiron_recv_process(head->slot - 1, pkt, len);
return E_NONE;

@ -32,19 +32,41 @@ int32_t _csgiron_config_port_get(uint8_t slot, char* pkt, uint16_t len)
{
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
iron_config_t *pdata = (iron_config_t*)(pkt + sizeof(csg_pkt_head_t));
pdata->vport = slot + 1;
pdata->report_period = pd_config.config_slot[slot].report_period;
_csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(iron_config_t), slot + 1);
_csg_send_data(CSG_PRV_REPLY, head->cmd, pkt, sizeof(iron_config_t), slot + 1);
return E_NONE;
}
int32_t _csgiron_config_port_set(uint8_t slot, char* pkt, uint16_t len)
{
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
iron_config_t *pdata = (iron_config_t*)(pkt + sizeof(csg_pkt_head_t));
pd_config.config_slot[slot].report_period = pdata->report_period;
vtysh_config_save();
iron_ack_t ack = {0};
ack.vport = slot + 1;
ack.result = TRUE;
memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(iron_ack_t));
_csg_send_data(CSG_PRV_REPLY, head->cmd, pkt, sizeof(iron_ack_t), slot + 1);
return E_NONE;
}
int32_t _csgiron_modbus_reply(uint8_t slot, char* pkt, uint16_t len)
{
//csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
//csg_ack_t ack = {0};
//ack.result = TRUE;
//memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_ack_t));
//_csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(csg_ack_t), slot + 1);
return E_NONE;
}
/* 命令映射表 */
static csgiron_recv_fun_cb _csgiron_command[] =
{
@ -59,18 +81,34 @@ static csgiron_recv_fun_cb _csgiron_prv_command[] =
NULL, // CSG_PRV_CONFIG_GLOBAL_GET
_csgiron_config_port_set, // CSG_PRV_CONFIG_PORT_SET
_csgiron_config_port_get, // CSG_PRV_CONFIG_PORT_GET
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL, // CSG_PRV_MODBUS
NULL
};
int32_t _csgiron_recv_process(uint8_t slot, char *pkt, uint16_t len)
{
dau_pkt_head_t *head = (dau_pkt_head_t*)pkt;
if (CSG_REQUEST == head->cmd)
if (CSG_REQUEST == head->cmd_type)
{
_csgiron_command[head->cmd](slot, pkt, len);
if (_csgiron_command[head->cmd])
{
_csgiron_command[head->cmd](slot, pkt, len);
}
}
else if (CSG_PRV_REQUEST == head->cmd)
else if (CSG_PRV_REQUEST == head->cmd_type)
{
_csgiron_prv_command[head->cmd](slot, pkt, len);
if (_csgiron_prv_command[head->cmd])
{
_csgiron_prv_command[head->cmd](slot, pkt, len);
}
}
return E_NONE;
}

@ -728,6 +728,8 @@ int32_t _pd_main_init(void)
cmd_install_element(CONFIG_NODE, &pd_protocol_type_cmd);
cmd_install_element(CONFIG_NODE, &pd_slot_terminal_cmd);
cmd_install_element(PORT_NODE, &pd_slot_terminal_cmd);
cmd_install_element(COMMON_NODE, &show_pd_cmd);

@ -203,20 +203,6 @@ void *_modbus_send_handle()
dau_t *dau = NULL;
while (1)
{
#if 0
for (int unit = 1; unit <= 6; unit++)
{
if (_modbus_tcp_transaction(0, unit, MODBUS_ADDR_CURRENT, MODBUS_CURRENT_LEN) > 0)
{
}
if (_modbus_tcp_transaction(0, unit, MODBUS_ADDR_CURRENT, MODBUS_CURRENT_LEN) > 0)
{
}
}
#else
_modbus_read_slot_stat(modbus.card);
for (int slot = 0; slot < PD_SLOTS_MAX; slot++)
@ -225,12 +211,14 @@ void *_modbus_send_handle()
dau = &daus[slot];
if (pcard->status)
{
_modbus_get_device_type(pcard->unit_id, &dau->info.type_m, &dau->info.type_s);
_modbus_get_device_type(pcard->unit_id, &dau->info.type_m, &dau->info.type_s);
//DBG(DBG_M_PD_MODBUS, "typem:%d types:%d\n", dau->info.type_m, dau->info.type_s);
if (DEVICE_IR_TYPE == dau->info.type_s && DEVICE_M_TYPE == dau->info.type_m)
{
dau->state.beat_cnt = 0;
dau->state.is_connect = TRUE;
sleep(1);
_modbus_get_current(pcard->unit_id,
MODBUS_IR_CURRENT_ADDR, MODBUS_IR_CURRENT_LEN, &pcard->current);
//DBG(DBG_M_PD_MODBUS, "current:%d\n", pcard->current);
@ -243,13 +231,13 @@ void *_modbus_send_handle()
{
dau->state.beat_cnt = 0;
dau->state.is_connect = TRUE;
sleep(1);
_modbus_get_current(pcard->unit_id,
MODBUS_DC_CURRENT_ADDR, MODBUS_DC_CURRENT_LEN, &pcard->current);
//DBG(DBG_M_PD_MODBUS, "current:%d\n", pcard->current);
}
}
}
#endif
sleep(5);
}

Loading…
Cancel
Save