|
|
|
@ -138,6 +138,26 @@ void _csg_server_set(int32_t ip, uint16_t port)
|
|
|
|
|
csg.server.sin_port = htons(csg.server_port);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 封装数据并写fifo */
|
|
|
|
|
int32_t _csg_msg_send(uint32_t type, void *data)
|
|
|
|
|
{
|
|
|
|
|
pd_csg_msg_t msg;
|
|
|
|
|
|
|
|
|
|
/* 封装消息. */
|
|
|
|
|
msg.type = type;
|
|
|
|
|
msg.data = data;
|
|
|
|
|
|
|
|
|
|
/* 发送消息 */
|
|
|
|
|
if (fifo_write(csg.fifo_cmd_id, (void*)(&msg), sizeof(pd_csg_msg_t)) != sizeof(pd_csg_msg_t))
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_FIFO, "SSG write ERROR! type=%d\r\n", msg.type);
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 校验收到包的包头, 长度, 校验码. */
|
|
|
|
|
int32_t _csg_pkt_check(char *pkt)
|
|
|
|
@ -207,8 +227,6 @@ int32_t _csg_connect_send(void)
|
|
|
|
|
{
|
|
|
|
|
char *pkt = csg.buf_send;
|
|
|
|
|
csg_contact_t *pinfo = (csg_contact_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
uint8_t unit = 0;
|
|
|
|
|
uint8_t port = 0;
|
|
|
|
|
|
|
|
|
|
pinfo->type_m = device_info.type_m;
|
|
|
|
|
pinfo->type_s = device_info.type_s;
|
|
|
|
@ -228,21 +246,7 @@ int32_t _csg_connect_send(void)
|
|
|
|
|
pinfo->server_ipv4 = csg.server_ip;
|
|
|
|
|
|
|
|
|
|
memset(pinfo->port, 0, sizeof(pinfo->port));
|
|
|
|
|
memset(pinfo->port, 0, sizeof(pinfo->port_type));
|
|
|
|
|
for(unit = 0; unit < PD_DAU_SUM; unit++)
|
|
|
|
|
{
|
|
|
|
|
//if (!dau_is_valid(dau[unit]))
|
|
|
|
|
{
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//for(port = 0; port < dau[unit]->port_num; port++)
|
|
|
|
|
{
|
|
|
|
|
pinfo->port[port] = pd_config.config_port[unit][port].vport;
|
|
|
|
|
pinfo->port_type[port] = pd_config.config_port[unit][port].port_type;;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
memset(pinfo->port_type, 0, sizeof(pinfo->port_type));
|
|
|
|
|
_csg_send_data(CSG_REPLY, CSG_C_CONTACT, pkt, sizeof(csg_contact_t));
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
@ -308,19 +312,52 @@ void _csg_connect_recv(void)
|
|
|
|
|
void _csg_add_dau_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
|
//int slot = head->slot;
|
|
|
|
|
int slot = head->slot;
|
|
|
|
|
if (slot < 0 || slot >= PD_SLOTS_MAX)
|
|
|
|
|
{
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "Add DAU %d error!\r\n", slot);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf("_csg_add_dau_recv slot = %d\n", head->slot);
|
|
|
|
|
printf("_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
|
head->dev_id = head->sdev_id;
|
|
|
|
|
head->cmd_type = CSG_REQUEST;
|
|
|
|
|
head->cmd = CSG_C_CONTACT;
|
|
|
|
|
head->len = CSG_HEAD_LEN + 4;
|
|
|
|
|
//(uint32_t *)(pkt + CSG_HEAD_LEN) = time(NULL);
|
|
|
|
|
uint32_t *timestamp = (uint32_t *)(pkt + CSG_HEAD_LEN);
|
|
|
|
|
*timestamp = time(NULL);
|
|
|
|
|
|
|
|
|
|
daus[slot].state.is_insert = TRUE;
|
|
|
|
|
//_dau_response(slot, pkt, head->len);
|
|
|
|
|
//_dau_response(slot, pkt, head->len);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void _csg_add_dau_send(int slot, int status)
|
|
|
|
|
{
|
|
|
|
|
char *pkt = csg.buf_send;
|
|
|
|
|
csg_add_dau_t *pinfo = (csg_add_dau_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
dau_contact_t *pdau = &daus[slot].info;
|
|
|
|
|
pinfo->type_m = pdau->type_m;
|
|
|
|
|
pinfo->type_s = pdau->type_s;
|
|
|
|
|
pinfo->slot = slot;
|
|
|
|
|
pinfo->status = status;
|
|
|
|
|
pinfo->dev_id = pdau->dev_id;
|
|
|
|
|
strncpy(pinfo->hostname, pdau->hostname, sizeof(pinfo->hostname)-1);
|
|
|
|
|
pinfo->factory_date = pdau->factory_date;
|
|
|
|
|
pinfo->deployment_date = pdau->deployment_date;
|
|
|
|
|
strncpy((char *)pinfo->app_version, (char *)pdau->app_version, sizeof(pinfo->app_version)-1);
|
|
|
|
|
strncpy((char *)pinfo->app_compile_time, (char *)pdau->app_compile_time, sizeof(pinfo->app_compile_time)-1);
|
|
|
|
|
strncpy((char *)pinfo->hardware_version, (char *)pdau->hardware_version, sizeof(pinfo->hardware_version)-1);
|
|
|
|
|
strncpy((char *)pinfo->FPGA_version, (char *)pdau->FPGA_version, sizeof(pinfo->FPGA_version)-1);
|
|
|
|
|
pinfo->ip = pdau->ip;
|
|
|
|
|
pinfo->mask = pdau->mask;
|
|
|
|
|
pinfo->gw = pdau->gw;
|
|
|
|
|
memcpy(pinfo->mac, pdau->mac, sizeof(pinfo->mac));
|
|
|
|
|
pinfo->server_port = pdau->server_port;
|
|
|
|
|
pinfo->server_ipv4 = pdau->server_ipv4;
|
|
|
|
|
memcpy(pinfo->port, pdau->port, sizeof(pinfo->port));
|
|
|
|
|
memcpy(pinfo->port_type, pdau->port_type, sizeof(pinfo->port_type));
|
|
|
|
|
|
|
|
|
|
_csg_send_data(CSG_REPLY, CSG_C_ADD_DAU, pkt, sizeof(csg_add_dau_t));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 解析心跳报文. */
|
|
|
|
@ -572,6 +609,26 @@ int32_t _csg_port_config_get_recv(char *pkt)
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 解析HUF实时图谱召唤报文. */
|
|
|
|
|
int32_t _csg_real_image_recv(char *pkt)
|
|
|
|
|
{
|
|
|
|
|
csg_real_image_get_t *pdata = (csg_real_image_get_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
void *data = NULL;
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG, "vport=%d \r\n", pdata->vport);
|
|
|
|
|
DBG(DBG_M_PD_CSG, "is_concern=%d\r\n", pdata->is_concern);
|
|
|
|
|
DBG(DBG_M_PD_CSG, "denoise_correlation=%d\r\n", pdata->denoise_correlation);
|
|
|
|
|
DBG(DBG_M_PD_CSG, "denoise_type=%d\r\n", pdata->denoise_type);
|
|
|
|
|
DBG(DBG_M_PD_CSG, "denoise_manual=%d\r\n", pdata->denoise_manual);
|
|
|
|
|
DBG(DBG_M_PD_CSG, "filter_cfg=%d\r\n", pdata->filter);
|
|
|
|
|
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_real_image_get_t));
|
|
|
|
|
memcpy(data, pdata, sizeof(csg_real_image_get_t));
|
|
|
|
|
_csg_msg_send(PD_SEND_TYPE_CMD, data);
|
|
|
|
|
return E_NONE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 升级文件接收 */
|
|
|
|
|
int32_t _csg_upgrade_recv(char *pkt)
|
|
|
|
@ -718,6 +775,7 @@ int32_t _csg_recv_process(char *pkt, uint32_t len)
|
|
|
|
|
_csg_port_config_get_recv(pkt);
|
|
|
|
|
break;
|
|
|
|
|
case CSG_PRV_CONFIG_REAL_WAVE:
|
|
|
|
|
_csg_real_image_recv(pkt);
|
|
|
|
|
break;
|
|
|
|
|
case CSG_PRV_TREND:
|
|
|
|
|
break;
|
|
|
|
@ -817,6 +875,17 @@ void *_csg_heartbeat_handle(void *arg)
|
|
|
|
|
_csg_disconnect_set(__FUNCTION__);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < PD_SLOTS_MAX; i++)
|
|
|
|
|
{
|
|
|
|
|
printf("dau[%d]:is_connect=%d is_insert=%d\n", i, daus[i].state.is_connect,
|
|
|
|
|
daus[i].state.is_insert);
|
|
|
|
|
if (daus[i].state.is_connect == TRUE
|
|
|
|
|
&& daus[i].state.is_insert != TRUE)
|
|
|
|
|
{
|
|
|
|
|
_csg_add_dau_send(i + 1, 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
@ -903,6 +972,34 @@ int32_t csg_handle_init_after(void)
|
|
|
|
|
/* 保存数据. */
|
|
|
|
|
csg.skfd = fd;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csg.fifo_cmd_id = fifo_create(CSG_FIFO_CMD, CSG_CMD_FIFO_NUM);
|
|
|
|
|
if (csg.fifo_cmd_id < 0)
|
|
|
|
|
{
|
|
|
|
|
log_err(LOG_CSG, "Open fifo " CSG_FIFO_CMD " error!");
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csg.fifo_prps_id = fifo_create(CSG_FIFO_PRPS, CSG_PRPS_FIFO_NUM);
|
|
|
|
|
if (csg.fifo_prps_id < 0)
|
|
|
|
|
{
|
|
|
|
|
log_err(LOG_CSG, "Open fifo " CSG_FIFO_PRPS " error!");
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csg.fifo_event_id = fifo_create(CSG_FIFO_EVENT, CSG_EVENT_FIFO_NUM);
|
|
|
|
|
if (csg.fifo_event_id < 0)
|
|
|
|
|
{
|
|
|
|
|
log_err(LOG_CSG, "Open fifo " CSG_FIFO_EVENT " error!");
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
csg.fifo_trend_id = fifo_create(CSG_FIFO_TREND, CSG_TREND_FIFO_NUM);
|
|
|
|
|
if (csg.fifo_trend_id < 0)
|
|
|
|
|
{
|
|
|
|
|
log_err(LOG_CSG, "Open fifo " CSG_FIFO_TREND " error!");
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
param.arg = NULL;
|
|
|
|
|
param.log_module = LOG_CSG;
|
|
|
|
|