forked from gatsby/df_datalink
183 lines
4.0 KiB
C
183 lines
4.0 KiB
C
#ifndef __SYSTEM_MONITOR_H_
|
|
#define __SYSTEM_MONITOR_H_
|
|
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
|
|
#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
|
|
|
|
#define VOLTAGE_LSB 0.05 // volt
|
|
#define VOLTAGE_MAX 12.75 // volt
|
|
|
|
#define TEMPERATURE_LSB 1.0 // Celsius degree
|
|
#define TEMPERATURE_MAX 127.0 // Celsius degree
|
|
#define TEMPERATURE_MIN -128.0 // Celsius degree
|
|
|
|
|
|
typedef struct
|
|
{
|
|
// FIXME: To Complete
|
|
uint8_t dummy;
|
|
} SYSCONFIG;
|
|
|
|
typedef struct
|
|
{
|
|
// -- unit: ms, 0~604799999
|
|
uint32_t psBDS;
|
|
// -- unit: week, 0~0~8191
|
|
uint16_t pBDS;
|
|
// -- unit: ms, 0~604799999
|
|
uint32_t psGPS;
|
|
// -- unit: week, 0~0~8191
|
|
uint16_t pGPS;
|
|
// Time validation indicator
|
|
// -- [0] GPS
|
|
// -- [1] reserve.
|
|
// -- [2] UTC
|
|
// -- [3] BDS
|
|
uint8_t tmInd;
|
|
// Time of flying
|
|
// uint: s
|
|
float tmFly;
|
|
// Status of flying
|
|
// [7:6] departure status 11 - departed/00 - not departed
|
|
// [5:4] ready status 11 - ready/00 - not ready
|
|
// [3:2] attitude status 11 - attitude ok/00 - attitude not ok
|
|
// [1:0] attitude adjust status 11 - adjusted/00 - not adjusted
|
|
uint8_t stFly;
|
|
// Position in launch coordinate system
|
|
float posX;
|
|
float posY;
|
|
float posZ;
|
|
// Speed in launch coordinate system
|
|
float vX;
|
|
float vY;
|
|
float vZ;
|
|
// Attitude in launch inertia coordinate system
|
|
float pitch;
|
|
float yaw;
|
|
float roll;
|
|
} SYSINFO;
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t dataId;
|
|
uint8_t data[PAYLOAD_LEN_MAX];
|
|
} PAYLOAD;
|
|
|
|
typedef struct
|
|
{
|
|
// Network log
|
|
uint32_t tuNum;
|
|
uint8_t slotNum;
|
|
uint8_t nodeType;
|
|
uint8_t cxnStatus;
|
|
uint8_t linkStage;
|
|
uint32_t recxnCnt;
|
|
uint8_t beamNo;
|
|
uint16_t beamAz;
|
|
uint16_t beamEl;
|
|
uint16_t advTxCnt;
|
|
uint16_t advRecvCnt;
|
|
uint16_t advCorrectCnt;
|
|
uint32_t cfmTxCnt;
|
|
uint32_t cfmRecvCnt;
|
|
uint32_t cfmCorrectCnt;
|
|
uint32_t svcTxCnt;
|
|
uint32_t svcRecvCnt;
|
|
uint32_t svcCorrectCnt;
|
|
int64_t timeDev;
|
|
uint32_t sendId;
|
|
uint32_t recvId;
|
|
} LINKLOG;
|
|
|
|
typedef struct
|
|
{
|
|
uint32_t acqCnt;
|
|
uint32_t fsyncCnt;
|
|
uint32_t decodeCnt;
|
|
uint32_t crcCnt;
|
|
double doppler;
|
|
uint64_t recvStamp;
|
|
uint64_t acqPeak;
|
|
uint64_t acqMean;
|
|
uint8_t acqPhase;
|
|
uint8_t acqFreqCh;
|
|
uint8_t fsyncPeak;
|
|
uint8_t fsyncMean;
|
|
uint8_t fsyncFreqCh;
|
|
uint16_t deintlvAmpEst;
|
|
uint16_t reserve;
|
|
} PHYLOG;
|
|
|
|
typedef struct
|
|
{
|
|
// Hardware log
|
|
// -- Signal processor status
|
|
uint8_t spPsVolt;
|
|
uint8_t spPsAuxVolt;
|
|
uint8_t spDdrVolt;
|
|
uint8_t spPlVolt;
|
|
uint8_t spPlAuxVolt;
|
|
uint8_t spBramVolt;
|
|
int8_t spTemp;
|
|
bool isSpOk;
|
|
// -- Antenna status
|
|
uint8_t antVolt;
|
|
uint8_t antTemp;
|
|
uint8_t antPll;
|
|
uint8_t antMgc0;
|
|
uint8_t antMgc1;
|
|
bool isAntOk;
|
|
} HWSTATE;
|
|
|
|
typedef struct
|
|
{
|
|
// Link layer log
|
|
LINKLOG linkLog;
|
|
|
|
// Physical layer log
|
|
PHYLOG phyLog;
|
|
|
|
// Hardware status
|
|
HWSTATE hwSate;
|
|
} SYSLOG;
|
|
|
|
int32_t SysMonitor_Init(void);
|
|
void SysMonitor_Destroy(void);
|
|
|
|
void SysMonitor_UpdateSysinfo(const SYSINFO *info);
|
|
void SysMonitor_UpdateSysinfoRaw(const uint8_t *buff);
|
|
void SysMonitor_GetSysinfo(SYSINFO *info);
|
|
void SysMonitor_GetSysinfoRaw(uint8_t *buff);
|
|
|
|
void SysMonitor_UpdateSendPayloadRaw(const uint8_t *buff, size_t len);
|
|
void SysMonitor_UpdateRecvPayloadRaw(const 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(const SLOTLOG *log);
|
|
void SysMonitor_UpdateRecvSlotLog(const SLOTLOG *log);
|
|
void SysMonitor_UpdateProtocolLog(const PRTCLLOG *log);
|
|
void SysMonitor_GetSendSlotLog(SLOTLOG *log);
|
|
void SysMonitor_GetRecvSlotLog(SLOTLOG *log);
|
|
void SysMonitor_GetProtocolLog(PRTCLLOG *log);
|
|
void SysMonitor_GetSendSlotLogRaw(uint8_t *buff);
|
|
void SysMonitor_GetRecvSlotLogRaw(uint8_t *buff);
|
|
void SysMonitor_GetProtocolLogRaw(uint8_t *buff);
|
|
|
|
void SysMonitor_UpdateHardwareStatus(const HWSTATE *state);
|
|
void SysMonitor_GetHardwareStatus(HWSTATE *state);
|
|
|
|
void SysMonitor_GetSyslog(SYSLOG *log);
|
|
void SysMonitor_GetSyslogRaw(uint8_t *buff);
|
|
|
|
#endif //__SYSTEM_MONITOR_H_
|