forked from 0xha0/df_datalink
fix: 修复消息队列未初始化的问题,简易上位机新增指定节点数据发送
This commit is contained in:
+20
-16
@@ -762,24 +762,27 @@ int32_t SysMonitor_Init(SYSMON_CONFIG *config)
|
||||
}
|
||||
|
||||
memcpy(&(sysMonitorInst->config), config, sizeof(SYSMON_CONFIG));
|
||||
sysMonitorInst->sendQueue[1] = NULL;
|
||||
sysMonitorInst->recvQueue[1] = NULL;
|
||||
memset(&(sysMonitorInst->sysInfoCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->linkLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->phyLogCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
memset(&(sysMonitorInst->hwStateCtrl), BUFF_NONE, sizeof(PINGPONG));
|
||||
|
||||
if (CircQueueCreate(&(sysMonitorInst->sendQueue),
|
||||
sysMonitorInst->config.sendQueueMax) == false)
|
||||
for (uint8_t ii = 0; ii < L2_NET_SCALE; ii++)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
if (CircQueueCreate(&(sysMonitorInst->recvQueue),
|
||||
sysMonitorInst->config.recvQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
sysMonitorInst->sendQueue[ii] = NULL;
|
||||
sysMonitorInst->recvQueue[ii] = NULL;
|
||||
if (CircQueueCreate(&(sysMonitorInst->sendQueue[ii]),
|
||||
sysMonitorInst->config.sendQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
if (CircQueueCreate(&(sysMonitorInst->recvQueue[ii]),
|
||||
sysMonitorInst->config.recvQueueMax) == false)
|
||||
{
|
||||
SysMonitor_Destroy();
|
||||
return ENOMEM;
|
||||
}
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
@@ -870,7 +873,8 @@ int32_t SysMonitor_UpdateSendPayload(SYSBUS_SVC_PLD *payload)
|
||||
return ENOMEM;
|
||||
}
|
||||
memcpy(payloadCopy, payload, sizeof(SYSBUS_SVC_PLD));
|
||||
if (CircQueuePush(sysMonitorInst->sendQueue[payload->nodeId], (void *)payloadCopy) == false)
|
||||
// valid id starts from 0x01
|
||||
if (CircQueuePush(sysMonitorInst->sendQueue[payload->nodeId-1], (void *)payloadCopy) == false)
|
||||
{
|
||||
DBG_WARNING("SystemMonitor::SEND Queue overflowed!\n");
|
||||
free(payloadCopy);
|
||||
@@ -890,7 +894,8 @@ void SysMonitor_GetSendPayload(SYSBUS_SVC_PLD **payload, uint8_t dstId)
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
|
||||
if (CircQueuePop(sysMonitorInst->sendQueue[dstId], (void **)payload) == false)
|
||||
// valid id starts from 0x01
|
||||
if (CircQueuePop(sysMonitorInst->sendQueue[dstId-1], (void **)payload) == false)
|
||||
{
|
||||
*payload = NULL;
|
||||
DBG_INFO("SystemMonitor::Empty sendQueue, nothing need sent.\n");
|
||||
@@ -904,8 +909,7 @@ void SysMonitor_GetSendPayload(SYSBUS_SVC_PLD **payload, uint8_t dstId)
|
||||
*/
|
||||
int32_t SysMonitor_GenRecvRsp(SYSBUS_SVC_PLD *payload)
|
||||
{
|
||||
ASSERT(sysMonitorInst != NULL);
|
||||
ASSERT(sysbusDescPtr != NULL);
|
||||
ASSERT(payload != NULL);
|
||||
int32_t Status;
|
||||
|
||||
if (payload->dataId == DATA_ID_NONE || payload->dataLen > SYSBUS_PLD_MAX)
|
||||
|
||||
Reference in New Issue
Block a user