|
|
@ -382,7 +382,6 @@ void _csg_add_dau_recv(char *pkt)
|
|
|
|
slot--;
|
|
|
|
slot--;
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_add_dau_recv slot = %d\n", slot);
|
|
|
|
daus[slot].state.is_insert = TRUE;
|
|
|
|
daus[slot].state.is_insert = TRUE;
|
|
|
|
modbus.card[slot].is_insert = TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _csg_remove_dau_recv(char *pkt)
|
|
|
|
void _csg_remove_dau_recv(char *pkt)
|
|
|
@ -398,8 +397,7 @@ void _csg_remove_dau_recv(char *pkt)
|
|
|
|
slot--;
|
|
|
|
slot--;
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_remove_dau_recv slot = %d\n", slot);
|
|
|
|
log_out(LOG_CSG, LOG_LVL_WARN, "_csg_remove_dau_recv slot = %d\n", slot);
|
|
|
|
daus[slot].state.is_insert = FALSE;
|
|
|
|
daus[slot].state.is_insert = FALSE;
|
|
|
|
modbus.card[slot].is_insert = FALSE;
|
|
|
|
daus[slot].state.is_connect = FALSE;
|
|
|
|
modbus.card[slot].is_connect = FALSE;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -420,13 +418,15 @@ int32_t _csg_reboot_recv(char *pkt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
int *data = NULL;
|
|
|
|
int *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 != slot)
|
|
|
|
|
|
|
|
{
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -434,10 +434,21 @@ int32_t _csg_reboot_recv(char *pkt)
|
|
|
|
return E_MEM;
|
|
|
|
return E_MEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_RESET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_RESET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reboot_system(LOG_CSG, REBOOT_REMOTE_RESET);
|
|
|
|
|
|
|
|
}
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -449,13 +460,15 @@ int32_t _csg_dev_info_set_recv(char *pkt)
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_dev_info_t *param = (csg_dev_info_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_dev_info_t *param = (csg_dev_info_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_dev_info_t *data = NULL;
|
|
|
|
csg_dev_info_t *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 != slot)
|
|
|
|
|
|
|
|
{
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_dev_info_t));
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_dev_info_t));
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -464,10 +477,45 @@ int32_t _csg_dev_info_set_recv(char *pkt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(data, param, sizeof(csg_dev_info_t));
|
|
|
|
memcpy(data, param, sizeof(csg_dev_info_t));
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_INFO_SET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_INFO_SET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
csg_dev_info_t *pinfo = (csg_dev_info_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
bool change_ip = FALSE;
|
|
|
|
|
|
|
|
uint8_t mac[MAC_ADDR_LEN] = {0};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
device_info.dev_id = pinfo->dev_id;
|
|
|
|
|
|
|
|
device_info.mask = pinfo->mask;
|
|
|
|
|
|
|
|
device_info.gw = pinfo->gw;
|
|
|
|
|
|
|
|
snprintf((char*)device_info.hostname, FILE_NAME_LEN, "%s", pinfo->hostname);
|
|
|
|
|
|
|
|
if (device_info.ip != pinfo->ip)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
device_info.ip = pinfo->ip;
|
|
|
|
|
|
|
|
change_ip = TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(device_info.mac, pinfo->mac, MAC_ADDR_LEN);
|
|
|
|
|
|
|
|
csg.server_ip = pinfo->server_ipv4;
|
|
|
|
|
|
|
|
csg.server_port = pinfo->server_port;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vtysh_config_save();
|
|
|
|
|
|
|
|
if (change_ip)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mac_generate_from_ip(device_info.ip, mac);
|
|
|
|
|
|
|
|
memcpy(device_info.mac, mac, MAC_ADDR_LEN);
|
|
|
|
|
|
|
|
vtysh_eth0_save();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
vtysh_device_save();
|
|
|
|
|
|
|
|
reboot_system(LOG_CSG, REBOOT_REMOTE_DEVINFO_CHANGE);
|
|
|
|
|
|
|
|
}
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -476,13 +524,15 @@ int32_t _csg_dev_info_get_recv(char *pkt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
int *data = NULL;
|
|
|
|
int *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 != slot)
|
|
|
|
|
|
|
|
{
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -490,10 +540,34 @@ int32_t _csg_dev_info_get_recv(char *pkt)
|
|
|
|
return E_MEM;
|
|
|
|
return E_MEM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_INFO_GET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_INFO_GET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
csg_dev_info_t *pinfo = (csg_dev_info_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pinfo->type_m = device_info.type_m;
|
|
|
|
|
|
|
|
pinfo->type_s = device_info.type_s;
|
|
|
|
|
|
|
|
pinfo->dev_id = device_info.dev_id;
|
|
|
|
|
|
|
|
strcpy(pinfo->hostname, device_info.hostname);
|
|
|
|
|
|
|
|
pinfo->factory_date = device_info.factory_date;
|
|
|
|
|
|
|
|
pinfo->deployment_date = device_info.deployment_date;
|
|
|
|
|
|
|
|
strncpy((char *)pinfo->app_compile_time, host.compile, 31);
|
|
|
|
|
|
|
|
strncpy((char *)pinfo->app_version, host.version, 31);
|
|
|
|
|
|
|
|
//strncpy((char *)pinfo->hardware_version, host.hardversion, 31);
|
|
|
|
|
|
|
|
//strncpy((char *)pinfo->FPGA_version, host.FPGAversion, 31);
|
|
|
|
|
|
|
|
pinfo->ip = device_info.ip;
|
|
|
|
|
|
|
|
pinfo->mask = device_info.mask;
|
|
|
|
|
|
|
|
pinfo->gw = device_info.gw;
|
|
|
|
|
|
|
|
memcpy(pinfo->mac, device_info.mac, sizeof(pinfo->mac));
|
|
|
|
|
|
|
|
pinfo->server_port = csg.server_port;
|
|
|
|
|
|
|
|
pinfo->server_ipv4 = csg.server_ip;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(csg_dev_info_t), slot);
|
|
|
|
|
|
|
|
}
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -503,13 +577,15 @@ int32_t _csg_config_set_recv(char *pkt)
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_config_global_t *param = (csg_config_global_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_config_global_t *param = (csg_config_global_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_config_global_t *data = NULL;
|
|
|
|
csg_config_global_t *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 != slot)
|
|
|
|
|
|
|
|
{
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_config_global_t));
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_config_global_t));
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -518,10 +594,34 @@ int32_t _csg_config_set_recv(char *pkt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(data, param, sizeof(csg_config_global_t));
|
|
|
|
memcpy(data, param, sizeof(csg_config_global_t));
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_CFG_SET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_CFG_SET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
csg_config_global_t *pnet = (csg_config_global_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pd_config.config.power_frequency = pnet->power_frequency;
|
|
|
|
|
|
|
|
pd_config.config.trend_period = pnet->trend_period * 60;
|
|
|
|
|
|
|
|
pd_config.config.sync_mode = pnet->sync_mode;
|
|
|
|
|
|
|
|
pd_config.config.heartbeat_period = pnet->heartbeat_period;
|
|
|
|
|
|
|
|
pd_config.config.pps_mode = pnet->pps_mode;
|
|
|
|
|
|
|
|
pd_config.config.protocol_type = pnet->protocol_type;
|
|
|
|
|
|
|
|
pd_config.config.event_storage = pnet->event_storage;
|
|
|
|
|
|
|
|
pd_config.config.trend_storage = pnet->trend_storage;
|
|
|
|
|
|
|
|
csg.trend_file.files_max = pd_config.config.trend_storage;
|
|
|
|
|
|
|
|
csg.event_file.files_max = pd_config.config.event_storage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vtysh_config_save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_PRV_REPLY, head->cmd, pkt, sizeof(csg_ack_t), slot);
|
|
|
|
|
|
|
|
}
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -537,6 +637,8 @@ int32_t _csg_config_get_recv(char *pkt)
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (0 != slot)
|
|
|
|
|
|
|
|
{
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(int));
|
|
|
|
if (!data)
|
|
|
|
if (!data)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -548,6 +650,22 @@ int32_t _csg_config_get_recv(char *pkt)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
csg_config_global_t *config = (csg_config_global_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config->power_frequency = pd_config.config.power_frequency;
|
|
|
|
|
|
|
|
config->sync_mode = pd_config.config.sync_mode;
|
|
|
|
|
|
|
|
config->heartbeat_period = pd_config.config.heartbeat_period;
|
|
|
|
|
|
|
|
config->pps_mode = pd_config.config.pps_mode;
|
|
|
|
|
|
|
|
config->protocol_type = pd_config.config.protocol_type;
|
|
|
|
|
|
|
|
config->trend_period = pd_config.config.trend_period / 60;
|
|
|
|
|
|
|
|
config->trend_storage = pd_config.config.trend_storage;
|
|
|
|
|
|
|
|
config->event_storage = pd_config.config.event_storage;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_csg_send_data(CSG_PRV_REPLY, head->cmd, pkt, sizeof(csg_config_global_t), slot);
|
|
|
|
|
|
|
|
}
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -557,8 +675,8 @@ int32_t _csg_port_config_set_recv(char *pkt)
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_config_port_t *param = (csg_config_port_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_config_port_t *param = (csg_config_port_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_config_port_t *data = NULL;
|
|
|
|
csg_config_port_t *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
@ -573,7 +691,7 @@ int32_t _csg_port_config_set_recv(char *pkt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(data, param, sizeof(csg_config_port_t));
|
|
|
|
memcpy(data, param, sizeof(csg_config_port_t));
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_PORT_SET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_PORT_SET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -586,8 +704,8 @@ int32_t _csg_port_config_get_recv(char *pkt)
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
uint8_t *param = (uint8_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
uint8_t *param = (uint8_t *)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
uint8_t *data = NULL;
|
|
|
|
uint8_t *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
@ -601,7 +719,7 @@ int32_t _csg_port_config_get_recv(char *pkt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*data = *param;
|
|
|
|
*data = *param;
|
|
|
|
|
|
|
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_PORT_GET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_PORT_GET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -614,8 +732,8 @@ int32_t _csg_real_image_recv(char *pkt)
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_pkt_head_t *head = (csg_pkt_head_t*)pkt;
|
|
|
|
csg_real_image_get_t *param = (csg_real_image_get_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_real_image_get_t *param = (csg_real_image_get_t*)(pkt + sizeof(csg_pkt_head_t));
|
|
|
|
csg_real_image_get_t *data = NULL;
|
|
|
|
csg_real_image_get_t *data = NULL;
|
|
|
|
uint8_t slot = head->slot - 1;
|
|
|
|
uint8_t slot = head->slot;
|
|
|
|
if (slot > PD_SLOTS_MAX)
|
|
|
|
if (slot > PD_SLOTS_MAX && slot != 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
DBG(DBG_M_PD_CSG, "slot:%d error\r\n", head->slot);
|
|
|
|
return E_BAD_PARAM;
|
|
|
|
return E_BAD_PARAM;
|
|
|
@ -629,7 +747,7 @@ int32_t _csg_real_image_recv(char *pkt)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
memcpy(data, param, sizeof(csg_real_image_get_t));
|
|
|
|
memcpy(data, param, sizeof(csg_real_image_get_t));
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_PRPS_GET, data) != E_NONE)
|
|
|
|
if (_csg_msg_send_dau(slot - 1, DAU_SEND_PRPS_GET, data) != E_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -676,6 +794,45 @@ int32_t _csg_event_get_recv(char *pkt)
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t _csg_update_slot(uint8_t type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
csg_upate_msg_t *data = NULL;
|
|
|
|
|
|
|
|
dau_t *dau = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int slot = 0; slot < PD_SLOTS_MAX; slot++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dau = &daus[slot];
|
|
|
|
|
|
|
|
if (dau->info.type_m == 0x03 && (dau->info.type_s == 0x01
|
|
|
|
|
|
|
|
|| dau->info.type_s == 0x02
|
|
|
|
|
|
|
|
|| dau->info.type_s == 0x03))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_upate_msg_t));
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "XMALLOC ERROR!\r\n");
|
|
|
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data->type = type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char buff[64] = {0};
|
|
|
|
|
|
|
|
if (getcwd(buff, sizeof(buff)) == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "getcwd error!\n");
|
|
|
|
|
|
|
|
return E_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
snprintf(data->name, 128, "%s/%s", buff, PD_UPG_SOFTWARE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_UPDATE, data) != E_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return ENABLE_NODE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 升级文件接收 */
|
|
|
|
/* 升级文件接收 */
|
|
|
|
int32_t _csg_upgrade_recv(char *pkt)
|
|
|
|
int32_t _csg_upgrade_recv(char *pkt)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -687,16 +844,8 @@ int32_t _csg_upgrade_recv(char *pkt)
|
|
|
|
upgrade_ack_t ack = {0};
|
|
|
|
upgrade_ack_t ack = {0};
|
|
|
|
int32_t size = 0;
|
|
|
|
int32_t size = 0;
|
|
|
|
int32_t len_wr = 0;
|
|
|
|
int32_t len_wr = 0;
|
|
|
|
int32_t rv = E_NONE;
|
|
|
|
|
|
|
|
uint32_t offset = 0;
|
|
|
|
uint32_t offset = 0;
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 首保处理, 打开文件描述符, 初始化变量 */
|
|
|
|
/* 首保处理, 打开文件描述符, 初始化变量 */
|
|
|
|
if (head_msg->index == 0)
|
|
|
|
if (head_msg->index == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -739,51 +888,15 @@ int32_t _csg_upgrade_recv(char *pkt)
|
|
|
|
close(fd);
|
|
|
|
close(fd);
|
|
|
|
fd = -1;
|
|
|
|
fd = -1;
|
|
|
|
DBG(DBG_M_PD_CSG, "Receive upgrade file end.\n");
|
|
|
|
DBG(DBG_M_PD_CSG, "Receive upgrade file end.\n");
|
|
|
|
csg_upate_msg_t *data;
|
|
|
|
pd_upg_start(PD_UPG_FROM_CSG, head_msg->type);
|
|
|
|
|
|
|
|
|
|
|
|
data = XMALLOC(MTYPE_CSG, sizeof(csg_upate_msg_t));
|
|
|
|
|
|
|
|
if (!data)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "XMALLOC ERROR!\r\n");
|
|
|
|
|
|
|
|
rv = E_ERROR;
|
|
|
|
|
|
|
|
goto UP_ERR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data->type = head_msg->type;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char buff[64] = {0};
|
|
|
|
|
|
|
|
if (getcwd(buff, sizeof(buff)) == NULL)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR, "getcwd error!\n");
|
|
|
|
|
|
|
|
rv = E_ERROR;
|
|
|
|
|
|
|
|
goto UP_ERR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(data->name, 128, "%s/%s", buff, PD_UPG_SOFTWARE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_csg_msg_send_dau(slot, DAU_SEND_UPDATE, data) != E_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XFREE(MTYPE_CSG, data);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UP_ERR:
|
|
|
|
|
|
|
|
ack.index = head_msg->index;
|
|
|
|
ack.index = head_msg->index;
|
|
|
|
ack.result = TRUE;
|
|
|
|
ack.result = TRUE;
|
|
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_PD_CSG_ERR," send ack\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送应答 */
|
|
|
|
/* 发送应答 */
|
|
|
|
memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_ack_t));
|
|
|
|
memcpy(pkt + sizeof(csg_pkt_head_t), (char *)&ack, sizeof(csg_ack_t));
|
|
|
|
_csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(ack), 0);
|
|
|
|
_csg_send_data(CSG_REPLY, head->cmd, pkt, sizeof(ack), 0);
|
|
|
|
|
|
|
|
|
|
|
|
/* 如果升级线程开启失败返回错误信息. */
|
|
|
|
|
|
|
|
if (rv != E_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
printf("Upgrade start failed.\n");
|
|
|
|
|
|
|
|
csg_upgrade_result_send(0, "Upgrade start failed.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -818,7 +931,7 @@ int32_t _csg_recv_process(char *pkt, uint32_t len)
|
|
|
|
return E_ERROR;
|
|
|
|
return E_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (3 == typem && 4 == types)
|
|
|
|
if (DEVICE_M_TYPE == typem && 4 == types)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_csgiron_recv_process(head->slot - 1, pkt, len);
|
|
|
|
_csgiron_recv_process(head->slot - 1, pkt, len);
|
|
|
|
return E_NONE;
|
|
|
|
return E_NONE;
|
|
|
@ -2105,11 +2218,12 @@ void _csg_report_modbus()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (0 == modbus.card[i].status)
|
|
|
|
if (0 == modbus.card[i].status)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
if (modbus.card[i].is_connect == TRUE
|
|
|
|
|
|
|
|
&& modbus.card[i].is_insert == TRUE
|
|
|
|
if (daus[i].state.is_connect == TRUE
|
|
|
|
&& modbus.card[i].type_m == DEVICE_M_TYPE)
|
|
|
|
&& daus[i].state.is_insert == TRUE
|
|
|
|
|
|
|
|
&& daus[i].info.type_m == DEVICE_M_TYPE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (modbus.card[i].type_s)
|
|
|
|
switch (daus[i].info.type_s)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case DEVICE_IR_TYPE:
|
|
|
|
case DEVICE_IR_TYPE:
|
|
|
|
iron.current = modbus.card[i].current;
|
|
|
|
iron.current = modbus.card[i].current;
|
|
|
@ -2135,6 +2249,7 @@ void *_csg_heartbeat_handle(void *arg)
|
|
|
|
time_t t_connect = 0;
|
|
|
|
time_t t_connect = 0;
|
|
|
|
time_t t_heartbeat = 0;
|
|
|
|
time_t t_heartbeat = 0;
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
|
|
|
|
dau_t *dau = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 等待初始化完成 */
|
|
|
|
/* 等待初始化完成 */
|
|
|
|
while(!is_system_init)
|
|
|
|
while(!is_system_init)
|
|
|
@ -2174,28 +2289,31 @@ void *_csg_heartbeat_handle(void *arg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < PD_SLOTS_MAX; i++)
|
|
|
|
for (int slot = 0; slot < PD_SLOTS_MAX; slot++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (daus[i].state.is_connect == TRUE
|
|
|
|
dau = &daus[slot];
|
|
|
|
&& daus[i].state.is_insert != TRUE)
|
|
|
|
if (dau->state.is_connect == TRUE
|
|
|
|
|
|
|
|
&& dau->state.is_insert != TRUE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_csg_send_add_dau(i, &daus[i].info);
|
|
|
|
if (dau->info.type_m == 0x03 && dau->info.type_m == 0x04)
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (modbus.card[i].is_connect == TRUE
|
|
|
|
|
|
|
|
&& modbus.card[i].is_insert != TRUE)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
csg_contact_t info = {0};
|
|
|
|
csg_contact_t info = {0};
|
|
|
|
info.type_m = modbus.card[i].type_m;
|
|
|
|
info.type_m = dau->info.type_m;
|
|
|
|
info.type_s = modbus.card[i].type_s;
|
|
|
|
info.type_s = dau->info.type_s;
|
|
|
|
_csg_send_add_dau(i, &info);
|
|
|
|
_csg_send_add_dau(slot, &info);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_csg_send_add_dau(slot, &dau->info);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (modbus.card[i].status == 0)
|
|
|
|
if (modbus.card[slot].status == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (modbus.card[i].is_connect == TRUE
|
|
|
|
if (dau->state.is_connect == TRUE
|
|
|
|
&& modbus.card[i].is_insert == TRUE)
|
|
|
|
&& dau->state.is_insert == TRUE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_csg_send_del_dau(i, NULL);
|
|
|
|
_csg_send_del_dau(slot, NULL);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|