From f64016baeba7b899de16865a108e8241fabc1670 Mon Sep 17 00:00:00 2001 From: wangbo Date: Thu, 3 Jul 2025 07:12:35 +0000 Subject: [PATCH] =?UTF-8?q?FIX=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81;?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/lib/a_process/pd_csg.c | 111 ++++++++++++------------------------- 1 file changed, 36 insertions(+), 75 deletions(-) diff --git a/app/lib/a_process/pd_csg.c b/app/lib/a_process/pd_csg.c index c350bd5..8bbe99e 100755 --- a/app/lib/a_process/pd_csg.c +++ b/app/lib/a_process/pd_csg.c @@ -93,7 +93,6 @@ void _csg_send_trend_data(uint8_t, void *data); void _csg_send_prps_data(uint8_t, void *data); void _csg_send_event_data(uint8_t, void *data); -#if 1 // 命令映射表 static csg_send_fun_cb _csg_send_command[] = { @@ -114,41 +113,6 @@ static csg_send_fun_cb _csg_send_command[] = _csg_send_prps_data, // DAU_SEND_PRPS 14 NULL, // 15 }; -#else - -// 命令映射表 -static csg_send_fun_cb _csg_send_command[] = -{ - NULL, // 0 - NULL, // DAU_C_CONTACT 1 - NULL, // DAU_C_ADD_DAU 2 - _csg_send_reset, // DAU_C_RESET 3 - NULL, // 4 - NULL, // DAU_C_UPDATE 5 - _csg_send_info_set, // DAU_C_DEV_INFO_SET 6 - _csg_send_info_get, // DAU_C_DEV_INFO_GET 7 - NULL, // 8 - NULL, // DAU_C_UPDATE_RESULT 9 - //_hf_recv_heartbeat, // DAU_C_HEARTBEAT 10 -}; - -static csg_send_fun_cb _csg_send_prv_command[] = -{ - NULL, // 0 - _csg_send_cfg_set, // DAU_P_CONFIG_SET 1 - _csg_send_cfg_get, // DAU_P_CONFIG_GET 2 - _csg_send_cfg_set_port, // DAU_P_CONFIG_PORT_SET 3 - _csg_send_cfg_get_port, // DAU_P_CONFIG_PORT_GET 4 - _csg_send_prps_get, // DAU_P_CONFIG_REAL_WAVE 5 - NULL, // 6 - NULL, // 7 - NULL, // 8 - NULL, // 9 - _csg_send_trend, // DAU_P_TREND 10 - _csg_send_prps, // DAU_P_REAL_PRPS 11 - _csg_send_event, // DAU_P_EVENT 12 -}; -#endif /* Internal functions --------------------------------------------------------*/ /* 服务器地址设置 */ @@ -414,18 +378,30 @@ void _csg_heartbeat_recv(char *pkt) } /* 设备重启报文. */ -void _csg_reboot_recv(char *pkt) -{ - 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), 0); - - sleep(3); - reboot_system(LOG_CSG, REBOOT_REMOTE_RESET); -} +int32_t _csg_reboot_recv(char *pkt) +{ + csg_pkt_head_t *head = (csg_pkt_head_t*)pkt; + int *data = NULL; + uint8_t slot = head->slot - 1; + if (slot > PD_SLOTS_MAX) + { + DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot); + return E_BAD_PARAM; + } + + data = XMALLOC(MTYPE_CSG, sizeof(int)); + if (!data) + { + DBG(DBG_M_PD_CSG_ERR, "XMALLOC ERROR!\r\n"); + return E_MEM; + } + + if (_csg_msg_send_dau(slot, DAU_SEND_RESET, data) != E_NONE) + { + XFREE(MTYPE_CSG, data); + } + return E_NONE; +} /* 厂家参数设置报文处理. 说明:修改本地ip 设备ID 服务器地址时需要重启。 @@ -586,7 +562,7 @@ int32_t _csg_port_config_get_recv(char *pkt) } *data = *param; - if (_csg_msg_send_dau(slot, DAU_SEND_CFG_GET, data) != E_NONE) + if (_csg_msg_send_dau(slot, DAU_SEND_PORT_GET, data) != E_NONE) { XFREE(MTYPE_CSG, data); } @@ -862,8 +838,9 @@ void _csg_send_cfg_get(uint8_t slot, void *data) { return; } - memcpy(pkt, data, sizeof(csg_config_global_t)); - _csg_send_data(CSG_REPLY, CSG_PRV_CONFIG_GLOBAL_SET, pkt, sizeof(csg_config_global_t), slot + 1); + + memcpy(pkt + sizeof(csg_pkt_head_t), data, sizeof(csg_config_global_t)); + _csg_send_data(CSG_PRV_REPLY, CSG_PRV_CONFIG_GLOBAL_GET, pkt, sizeof(csg_config_global_t), slot + 1); } void _csg_send_cfg_set_port(uint8_t slot, void *data) @@ -873,8 +850,8 @@ void _csg_send_cfg_set_port(uint8_t slot, void *data) hf_cfg_port_ack_t *psrc = (hf_cfg_port_ack_t *)data; ack.result = TRUE; ack.vport = psrc->vport; - memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_ack_t)); - _csg_send_data(CSG_PRV_REPLY, CSG_PRV_CONFIG_PORT_SET, pkt, sizeof(csg_ack_t), slot + 1); + memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_config_port_ack_t)); + _csg_send_data(CSG_PRV_REPLY, CSG_PRV_CONFIG_PORT_SET, pkt, sizeof(csg_config_port_ack_t), slot + 1); } void _csg_send_cfg_get_port(uint8_t slot, void *data) @@ -885,8 +862,8 @@ void _csg_send_cfg_get_port(uint8_t slot, void *data) return; } - memcpy(pkt, data, sizeof(csg_config_global_t)); - _csg_send_data(CSG_PRV_REPLY, CSG_PRV_CONFIG_PORT_GET, pkt, sizeof(csg_config_global_t), slot + 1); + memcpy(pkt + sizeof(csg_pkt_head_t), data, sizeof(csg_config_port_t)); + _csg_send_data(CSG_PRV_REPLY, CSG_PRV_CONFIG_PORT_GET, pkt, sizeof(csg_config_port_t), slot + 1); } void _csg_send_prps_get(uint8_t slot, void *data) @@ -911,7 +888,7 @@ void _csg_send_prps_data(uint8_t slot, void *data) uint32_t last_pack_len = 0; uint32_t port_len = 0; - if (NULL != data) + if (NULL == data) { return; } @@ -942,6 +919,7 @@ void _csg_send_prps_data(uint8_t slot, void *data) head->pkt_index = i; head->len = len; memcpy(pdata, (char *)real->prps + CSG_PKT_LEN * i, len); + /* 这里延迟 500us, 是因为当使用 100M 光转电模块时, 因为我们的光口是千兆的所以会丢包 */ usleep(500); _csg_send_data(CSG_PRV_REPLY, CSG_PRV_REAL_PRPS, pkt, sizeof(csg_real_image_t) + len, slot + 1); @@ -959,17 +937,6 @@ void _csg_send_trend(uint8_t slot, void *data) _csg_send_data(CSG_PRV_REPLY, CSG_PRV_TREND, pkt, sizeof(csg_ack_t), slot + 1); } -void _csg_send_prps(uint8_t slot, void *data) -{ - char *pkt = csg.buf_send; - if (NULL != data) - { - return; - } - memcpy(pkt + sizeof(csg_pkt_head_t), data, sizeof(csg_ack_t)); - _csg_send_data(CSG_PRV_REPLY, CSG_PRV_REAL_PRPS, pkt, sizeof(csg_ack_t), slot + 1); -} - void _csg_send_event(uint8_t slot, void *data) { char *pkt = csg.buf_send; @@ -1017,8 +984,6 @@ void *_csg_send_cmd_handle(void *arg) sleep(1); } - csg.send_cb = _csg_send_process; - while(1) { if (fifo_read(csg.fifo_cmd_id, (void**)&recv_msg) != 0) @@ -1051,8 +1016,6 @@ void *_csg_send_prps_handle(void *arg) { sleep(1); } - - csg.send_cb = _csg_send_process; while(1) { @@ -1087,8 +1050,6 @@ void *_csg_send_trend_handle(void *arg) sleep(1); } - csg.send_cb = _csg_send_process; - while(1) { if (fifo_read(csg.fifo_trend_id, (void**)&recv_msg) != 0) @@ -1122,8 +1083,6 @@ void *_csg_send_event_handle(void *arg) sleep(1); } - csg.send_cb = _csg_send_process; - while(1) { if (fifo_read(csg.fifo_event_id, (void**)&recv_msg) != 0) @@ -1352,6 +1311,8 @@ int32_t csg_handle_init_after(void) log_err(LOG_CSG, "Open fifo " CSG_FIFO_TREND " error!"); return E_ERROR; } + + csg.send_cb = _csg_send_process; param.arg = NULL; param.log_module = LOG_CSG;