diff --git a/df_datalink_sp/src/system_monitor.c b/df_datalink_sp/src/system_monitor.c index b7a1046..633b97b 100644 --- a/df_datalink_sp/src/system_monitor.c +++ b/df_datalink_sp/src/system_monitor.c @@ -210,6 +210,7 @@ void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff) buffIndx = GetWritable(sysMonitorInst->sendPLCtrl); sysMonitorInst->sendPLCtrl.wBusy = buffIndx; memcpy(sysMonitorInst->sendPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ); + sysMonitorInst->sendPL[buffIndx].dataId_flj++; sysMonitorInst->sendPLCtrl.latest = buffIndx; sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE; } @@ -217,7 +218,7 @@ void SysMonitor_UpdateSendPayloadFLJRaw(uint8_t *buff) /** * Get send FLJ payload as raw data. */ -void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff) +void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff, uint32_t *id) { ASSERT(sysMonitorInst != NULL); uint8_t buffIndx, buffIndex_old; @@ -227,7 +228,11 @@ void SysMonitor_GetSendPayloadFLJRaw(uint8_t *buff) else buffIndx = GetReadable(sysMonitorInst->sendPLCtrl); sysMonitorInst->sendPLCtrl.rBusy = buffIndx; - memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ); + if (sysMonitorInst->sendPL[buffIndx].dataId_flj != DATA_ID_NONE) + { + memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ); + } + *id = sysMonitorInst->sendPL[buffIndx].dataId_flj; sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old; } @@ -241,6 +246,7 @@ void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff) buffIndx = GetWritable(sysMonitorInst->sendPLCtrl); sysMonitorInst->sendPLCtrl.wBusy = buffIndx; memcpy(sysMonitorInst->sendPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ); + sysMonitorInst->sendPL[buffIndx].dataId_lj++; sysMonitorInst->sendPLCtrl.latest = buffIndx; sysMonitorInst->sendPLCtrl.wBusy = BUFF_NONE; } @@ -248,7 +254,7 @@ void SysMonitor_UpdateSendPayloadLJRaw(uint8_t *buff) /** * Get send LJ payload as raw data. */ -void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff) +void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff, uint32_t *id) { ASSERT(sysMonitorInst != NULL); uint8_t buffIndx, buffIndex_old; @@ -258,7 +264,11 @@ void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff) else buffIndx = GetReadable(sysMonitorInst->sendPLCtrl); sysMonitorInst->sendPLCtrl.rBusy = buffIndx; - memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ); + if (sysMonitorInst->sendPL[buffIndx].dataId_lj != DATA_ID_NONE) + { + memcpy(buff, sysMonitorInst->sendPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ); + } + *id = sysMonitorInst->sendPL[buffIndx].dataId_lj; sysMonitorInst->sendPLCtrl.rBusy = buffIndex_old; } @@ -273,6 +283,7 @@ void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff) buffIndx = GetWritable(sysMonitorInst->recvPLCtrl); sysMonitorInst->recvPLCtrl.wBusy = buffIndx; memcpy(sysMonitorInst->recvPL[buffIndx].data_flj, buff, sizeof(uint8_t) * PAYLOAD_FLJ); + sysMonitorInst->recvPL[buffIndx].dataId_flj++; sysMonitorInst->recvPLCtrl.latest = buffIndx; sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE; } @@ -280,7 +291,7 @@ void SysMonitor_UpdateRecvPayloadFLJRaw(uint8_t *buff) /** * Get send FLJ payload as raw data. */ -void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff) +void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff, uint32_t *id) { ASSERT(sysMonitorInst != NULL); uint8_t buffIndx, buffIndex_old; @@ -290,7 +301,11 @@ void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff) else buffIndx = GetReadable(sysMonitorInst->recvPLCtrl); sysMonitorInst->recvPLCtrl.rBusy = buffIndx; - memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ); + if (sysMonitorInst->recvPL[buffIndx].dataId_flj != DATA_ID_NONE) + { + memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_flj, sizeof(uint8_t) * PAYLOAD_FLJ); + } + *id = sysMonitorInst->recvPL[buffIndx].dataId_flj; sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old; } @@ -304,6 +319,7 @@ void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff) buffIndx = GetWritable(sysMonitorInst->recvPLCtrl); sysMonitorInst->recvPLCtrl.wBusy = buffIndx; memcpy(sysMonitorInst->recvPL[buffIndx].data_lj, buff, sizeof(uint8_t) * PAYLOAD_LJ); + sysMonitorInst->recvPL[buffIndx].dataId_lj++; sysMonitorInst->recvPLCtrl.latest = buffIndx; sysMonitorInst->recvPLCtrl.wBusy = BUFF_NONE; } @@ -311,7 +327,7 @@ void SysMonitor_UpdateRecvPayloadLJRaw(uint8_t *buff) /** * Get send LJ payload as raw data. */ -void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff) +void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff, uint32_t *id) { ASSERT(sysMonitorInst != NULL); uint8_t buffIndx, buffIndex_old; @@ -321,7 +337,11 @@ void SysMonitor_GetRecvPayloadLJRaw(uint8_t *buff) else buffIndx = GetReadable(sysMonitorInst->recvPLCtrl); sysMonitorInst->recvPLCtrl.rBusy = buffIndx; - memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ); + if (sysMonitorInst->recvPL[buffIndx].dataId_lj != DATA_ID_NONE) + { + memcpy(buff, sysMonitorInst->recvPL[buffIndx].data_lj, sizeof(uint8_t) * PAYLOAD_LJ); + } + *id = sysMonitorInst->recvPL[buffIndx].dataId_lj; sysMonitorInst->recvPLCtrl.rBusy = buffIndex_old; } diff --git a/df_datalink_sp/src/system_monitor.h b/df_datalink_sp/src/system_monitor.h index 9a43985..a29a395 100644 --- a/df_datalink_sp/src/system_monitor.h +++ b/df_datalink_sp/src/system_monitor.h @@ -7,6 +7,8 @@ #define PAYLOAD_FLJ 78 #define PAYLOAD_LJ 168 +#define DATA_ID_NONE UINT32_MAX + typedef struct { // FIXME: To Complete @@ -54,7 +56,9 @@ typedef struct typedef struct { + uint32_t dataId_lj; uint8_t data_lj[PAYLOAD_LJ]; + uint32_t dataId_flj; uint8_t data_flj[PAYLOAD_FLJ]; } PAYLOAD; @@ -131,10 +135,10 @@ 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); -void SysMonitor_GetRecvPayloadFLJRaw(uint8_t *buff); -void SysMonitor_GetSendPayloadLJRaw(uint8_t *buff); -void SysMonitor_GetRecvPayloadLJRaw(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_UpdateSendSlotLog(SLOTLOG *log); void SysMonitor_UpdateRecvSlotLog(SLOTLOG *log);