*update system_monitor api (simplified)

This commit is contained in:
Gatsby Van
2024-01-31 10:05:43 +08:00
parent 9f75b519e0
commit 632b1ec636
4 changed files with 42 additions and 124 deletions
@@ -115,11 +115,11 @@ static int32_t Service_Packing(L2_INST *instPtr, L2_FRAME_TYPE type, uint8_t dst
uint32_t dataId;
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
{
SysMonitor_GetSendPayloadFLJRaw(buff + L2_MSG_SVC_PAYLOAD, &dataId);
SysMonitor_GetSendPayloadRaw(buff + L2_MSG_SVC_PAYLOAD, &dataId, PAYLOAD_LEN_FLJ_TX);
}
else
{
SysMonitor_GetSendPayloadLJRaw(buff + L2_MSG_SVC_PAYLOAD, &dataId);
SysMonitor_GetSendPayloadRaw(buff + L2_MSG_SVC_PAYLOAD, &dataId, PAYLOAD_LEN_LJ_TX);
}
L2_FrameInsertChunk(buff, L2_MSG_SVC_PAYLOAD_ID, L2_MSG_SVC_PAYLOAD_ID_LEN, &dataId);
@@ -276,11 +276,11 @@ int32_t L2_Service_PktHandler(L2_INST *instPtr, uint8_t *msg)
{
if(L2_GetNodeType(instPtr) == L2_NODE_HEAD)
{
SysMonitor_UpdateRecvPayloadFLJRaw(msg+L2_MSG_SVC_PAYLOAD);
SysMonitor_UpdateRecvPayloadRaw(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_FLJ_RX);
}
else
{
SysMonitor_UpdateRecvPayloadLJRaw(msg+L2_MSG_SVC_PAYLOAD);
SysMonitor_UpdateRecvPayloadRaw(msg+L2_MSG_SVC_PAYLOAD, PAYLOAD_LEN_LJ_RX);
}
}
+22 -98
View File
@@ -78,14 +78,10 @@ int32_t SysMonitor_Init(void)
memset(&(sysMonitorInst->protocolLogCtrl), BUFF_NONE, sizeof(PINGPONG));
memset(&(sysMonitorInst->hwStateCtrl), BUFF_NONE, sizeof(PINGPONG));
sysMonitorInst->recvPL[0].dataId_flj = DATA_ID_NONE;
sysMonitorInst->recvPL[0].dataId_lj = DATA_ID_NONE;
sysMonitorInst->recvPL[1].dataId_flj = DATA_ID_NONE;
sysMonitorInst->recvPL[1].dataId_lj = DATA_ID_NONE;
sysMonitorInst->sendPL[0].dataId_flj = DATA_ID_NONE;
sysMonitorInst->sendPL[0].dataId_lj = DATA_ID_NONE;
sysMonitorInst->sendPL[1].dataId_flj = DATA_ID_NONE;
sysMonitorInst->sendPL[1].dataId_lj = DATA_ID_NONE;
sysMonitorInst->recvPL[0].dataId = DATA_ID_NONE;
sysMonitorInst->recvPL[1].dataId = DATA_ID_NONE;
sysMonitorInst->sendPL[0].dataId = DATA_ID_NONE;
sysMonitorInst->sendPL[1].dataId = DATA_ID_NONE;
return SUCCESS;
}
@@ -210,24 +206,24 @@ void SysMonitor_GetSysinfoRaw(uint8_t *buff)
}
// @Send Payload
/**
* Update send FLJ payload by raw data.
* Update send payload by raw data.
*/
void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff)
void SysMonitor_UpdateSendPayloadRaw(uint8_t *buff, size_t len)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx;
buffIndx = GetWritable(sysMonitorInst->sendPLCtrl);
sysMonitorInst->sendPLCtrl.wBusy = buffIndx;
memcpy(sysMonitorInst->sendPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ_TX);
sysMonitorInst->sendPL[buffIndx].dataId_flj++;
memcpy(sysMonitorInst->sendPL[buffIndx].data, buff, len);
sysMonitorInst->sendPL[buffIndx].dataId++;
sysMonitorInst->sendPLCtrl.latest = buffIndx;
sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE;
}
/**
* Get send FLJ payload as raw data.
* Get send payload as raw data.
*/
void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff, uint32_t *id)
void SysMonitor_GetSendPayloadRaw(uint8_t *buff, uint32_t *id, size_t len)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx, buffIndex_old;
@@ -237,70 +233,34 @@ void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff, uint32_t *id)
else
buffIndx = GetReadable(sysMonitorInst->sendPLCtrl);
sysMonitorInst->sendPLCtrl.rBusy = buffIndx;
if (sysMonitorInst->sendPL[buffIndx].dataId_flj != DATA_ID_NONE)
if (sysMonitorInst->sendPL[buffIndx].dataId != DATA_ID_NONE)
{
memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ_TX);
memcpy(buff, sysMonitorInst->sendPL[buffIndx].data, len);
}
*id = sysMonitorInst->sendPL[buffIndx].dataId_flj;
sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old;
}
/**
* Update LJ send payload by raw data.
*/
void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx;
buffIndx = GetWritable(sysMonitorInst->sendPLCtrl);
sysMonitorInst->sendPLCtrl.wBusy = buffIndx;
memcpy(sysMonitorInst->sendPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ_TX);
sysMonitorInst->sendPL[buffIndx].dataId_lj++;
sysMonitorInst->sendPLCtrl.latest = buffIndx;
sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE;
}
/**
* Get send LJ payload as raw data.
*/
void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff, uint32_t *id)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx, buffIndex_old;
buffIndex_old = sysMonitorInst->sendPLCtrl.rBusy;
if (buffIndex_old != BUFF_NONE)
buffIndx = buffIndex_old; // Keep it busy
else
buffIndx = GetReadable(sysMonitorInst->sendPLCtrl);
sysMonitorInst->sendPLCtrl.rBusy = buffIndx;
if (sysMonitorInst->sendPL[buffIndx].dataId_lj != DATA_ID_NONE)
{
memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ_TX);
}
*id = sysMonitorInst->sendPL[buffIndx].dataId_lj;
*id = sysMonitorInst->sendPL[buffIndx].dataId;
sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old;
}
// @Receive Payload
/**
* Update receive FLJ payload by raw data.
* Update receive payload by raw data.
*/
void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff)
void SysMonitor_UpdateRecvPayloadRaw(uint8_t *buff, size_t len)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx;
buffIndx = GetWritable(sysMonitorInst->recvPLCtrl);
sysMonitorInst->recvPLCtrl.wBusy = buffIndx;
memcpy(sysMonitorInst->recvPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ_RX);
sysMonitorInst->recvPL[buffIndx].dataId_flj++;
memcpy(sysMonitorInst->recvPL[buffIndx].data, buff, len);
sysMonitorInst->recvPL[buffIndx].dataId++;
sysMonitorInst->recvPLCtrl.latest = buffIndx;
sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE;
}
/**
* Get send FLJ payload as raw data.
* Get send payload as raw data.
*/
void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff, uint32_t *id)
void SysMonitor_GetRecvPayloadRaw(uint8_t *buff, uint32_t *id, size_t len)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx, buffIndex_old;
@@ -310,47 +270,11 @@ void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff, uint32_t *id)
else
buffIndx = GetReadable(sysMonitorInst->recvPLCtrl);
sysMonitorInst->recvPLCtrl.rBusy = buffIndx;
if (sysMonitorInst->recvPL[buffIndx].dataId_flj != DATA_ID_NONE)
if (sysMonitorInst->recvPL[buffIndx].dataId != DATA_ID_NONE)
{
memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ_RX);
memcpy(buff, sysMonitorInst->recvPL[buffIndx].data, len);
}
*id = sysMonitorInst->recvPL[buffIndx].dataId_flj;
sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old;
}
/**
* Update receive LJ payload by raw data.
*/
void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx;
buffIndx = GetWritable(sysMonitorInst->recvPLCtrl);
sysMonitorInst->recvPLCtrl.wBusy = buffIndx;
memcpy(sysMonitorInst->recvPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ_RX);
sysMonitorInst->recvPL[buffIndx].dataId_lj++;
sysMonitorInst->recvPLCtrl.latest = buffIndx;
sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE;
}
/**
* Get send LJ payload as raw data.
*/
void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff, uint32_t *id)
{
ASSERT(sysMonitorInst != NULL);
uint8_t buffIndx, buffIndex_old;
buffIndex_old = sysMonitorInst->recvPLCtrl.rBusy;
if (buffIndex_old != BUFF_NONE)
buffIndx = buffIndex_old; // Keep it busy
else
buffIndx = GetReadable(sysMonitorInst->recvPLCtrl);
sysMonitorInst->recvPLCtrl.rBusy = buffIndx;
if (sysMonitorInst->recvPL[buffIndx].dataId_lj != DATA_ID_NONE)
{
memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ_RX);
}
*id = sysMonitorInst->recvPL[buffIndx].dataId_lj;
*id = sysMonitorInst->recvPL[buffIndx].dataId;
sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old;
}
+12 -18
View File
@@ -4,11 +4,11 @@
#include <stdint.h>
#include <stdbool.h>
#define PAYLOAD_LEN 256
#define PAYLOAD_FLJ_RX 168
#define PAYLOAD_FLJ_TX 66
#define PAYLOAD_LJ_RX 66
#define PAYLOAD_LJ_TX 168
#define PAYLOAD_LEN_MAX 256
#define PAYLOAD_LEN_FLJ_RX 168
#define PAYLOAD_LEN_FLJ_TX 66
#define PAYLOAD_LEN_LJ_RX 66
#define PAYLOAD_LEN_LJ_TX 168
#define DATA_ID_NONE UINT32_MAX
#define DATA_ID_TEST 0x02030203
@@ -60,10 +60,8 @@ typedef struct
typedef struct
{
uint32_t dataId_lj;
uint8_t data_lj[PAYLOAD_LEN];
uint32_t dataId_flj;
uint8_t data_flj[PAYLOAD_LEN];
uint32_t dataId;
uint8_t data[PAYLOAD_LEN_MAX];
} PAYLOAD;
typedef struct
@@ -73,7 +71,7 @@ typedef struct
uint8_t slotNo;
uint8_t frameType;
// Payload
uint8_t payload[PAYLOAD_LEN];
uint8_t payload[PAYLOAD_LEN_MAX];
// Time sync info
uint64_t tmStamp;
uint32_t tmDevi;
@@ -135,14 +133,10 @@ void SysMonitor_UpdateSysinfoRaw(uint8_t *buff);
void SysMonitor_GetSysinfo(SYSINFO *info);
void SysMonitor_GetSysinfoRaw(uint8_t *buff);
void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff);
void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff);
void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff);
void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff);
void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff, uint32_t *id);
void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff, uint32_t *id);
void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff, uint32_t *id);
void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff, uint32_t *id);
void SysMonitor_UpdateSendPayloadRaw(uint8_t *buff, size_t len);
void SysMonitor_UpdateRecvPayloadRaw(uint8_t *buff, size_t len);
void SysMonitor_GetSendPayloadRaw(uint8_t *buff, uint32_t *id, size_t len);
void SysMonitor_GetRecvPayloadRaw(uint8_t *buff, uint32_t *id, size_t len);
void SysMonitor_UpdateSendSlotLog(SLOTLOG *log);
void SysMonitor_UpdateRecvSlotLog(SLOTLOG *log);
+4 -4
View File
@@ -414,12 +414,12 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
// TODO
case CMD_FLJ_SEND:
{
SysMonitor_UpdateSendPayloadFLJRaw(data + FLJ_DATA_OFFSET); // omit control info
SysMonitor_UpdateSendPayloadRaw(data + FLJ_DATA_OFFSET, PAYLOAD_LEN_FLJ_TX); // omit control info
break;
}
case CMD_LJ_SEND:
{
SysMonitor_UpdateSendPayloadLJRaw(data + LJ_DATA_OFFSET); // omit control info
SysMonitor_UpdateSendPayloadRaw(data + LJ_DATA_OFFSET, PAYLOAD_LEN_LJ_TX); // omit control info
break;
}
case CMD_FLJ_POLL:
@@ -440,7 +440,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
sysbusRsp->data[WD_CMD] = CMD_FLJ_POLL;
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
uint32_t dataId;
SysMonitor_GetRecvPayloadFLJRaw(sysbusRsp->data + FLJ_DATA_OFFSET, &dataId); // omit control info
SysMonitor_GetRecvPayloadRaw(sysbusRsp->data + FLJ_DATA_OFFSET, &dataId, PAYLOAD_LEN_FLJ_RX); // omit control info
if (dataId == DATA_ID_NONE)
{
free(sysbusRsp);
@@ -476,7 +476,7 @@ int32_t SystemBus_HandleCmd(SYSBUS *instPtr)
sysbusRsp->data[WD_CMD] = CMD_LJ_POLL;
sysbusRsp->data[WD_PRD] = MY_PRD_ID;
uint32_t dataId;
SysMonitor_GetRecvPayloadLJRaw(sysbusRsp->data + LJ_DATA_OFFSET, &dataId); // omit control info
SysMonitor_GetRecvPayloadRaw(sysbusRsp->data + LJ_DATA_OFFSET, &dataId, PAYLOAD_LEN_LJ_RX); // omit control info
if (dataId == DATA_ID_NONE)
{
free(sysbusRsp);