*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
+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;
}