forked from gatsby/df_datalink
fix: 修复消息队列未初始化的问题,简易上位机新增指定节点数据发送
This commit is contained in:
@@ -39,10 +39,10 @@ class Plugin(Plugin_Base):
|
||||
"data": "5A 54 E1 EE 00 CF 02 5A FE"
|
||||
},
|
||||
{
|
||||
"caption": "数据发送测试 - 40 Byte",
|
||||
"caption": "数据发送测试(节点01)",
|
||||
"icon": "fa5.play-circle",
|
||||
"data": (
|
||||
"5A 54 E4 EE 00 00 00 00 02 00 28 "
|
||||
"5A 54 E4 EE 01 00 00 00 01 28 00 "
|
||||
"00 01 02 03 04 05 06 07 "
|
||||
"08 09 0A 0B 0C 0D 0E 0F "
|
||||
"10 11 12 13 14 15 16 17 "
|
||||
@@ -51,11 +51,32 @@ class Plugin(Plugin_Base):
|
||||
"00 08 31 5A FE"
|
||||
)
|
||||
},
|
||||
# {
|
||||
# "caption": "数据发送测试 - 2",
|
||||
# "icon": "fa5.play-circle",
|
||||
# "data": ""
|
||||
# },
|
||||
{
|
||||
"caption": "数据发送测试(节点02)",
|
||||
"icon": "fa5.play-circle",
|
||||
"data": (
|
||||
"5A 54 E4 EE 02 00 00 00 02 28 00 "
|
||||
"00 01 02 03 04 05 06 07 "
|
||||
"08 09 0A 0B 0C 0D 0E 0F "
|
||||
"10 11 12 13 14 15 16 17 "
|
||||
"18 19 1A 1B 1C 1D 1E 1F "
|
||||
"20 21 22 23 24 25 26 27 "
|
||||
"00 0A 31 5A FE"
|
||||
)
|
||||
},
|
||||
{
|
||||
"caption": "数据发送测试(节点03)",
|
||||
"icon": "fa5.play-circle",
|
||||
"data": (
|
||||
"5A 54 E4 EE 03 00 00 00 03 28 00 "
|
||||
"00 01 02 03 04 05 06 07 "
|
||||
"08 09 0A 0B 0C 0D 0E 0F "
|
||||
"10 11 12 13 14 15 16 17 "
|
||||
"18 19 1A 1B 1C 1D 1E 1F "
|
||||
"20 21 22 23 24 25 26 27 "
|
||||
"00 0C 31 5A FE"
|
||||
)
|
||||
},
|
||||
{
|
||||
"caption": "装订 - 【主 - 0x01】128 kbps,时隙表 0",
|
||||
"icon": "fa5.play-circle",
|
||||
|
||||
@@ -762,25 +762,28 @@ 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),
|
||||
for (uint8_t ii = 0; ii < L2_NET_SCALE; ii++)
|
||||
{
|
||||
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),
|
||||
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)
|
||||
|
||||
@@ -109,7 +109,7 @@ typedef struct
|
||||
* @struct SYSBUS_SVC_PLD
|
||||
* @brief Payload struct that holds the service payload
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct __attribute__((packed))
|
||||
{
|
||||
uint32_t dataId; ///< data identifier
|
||||
uint8_t nodeId; ///< destination ID for tx, source ID for rx
|
||||
|
||||
Reference in New Issue
Block a user