115 lines
4.6 KiB
C++
115 lines
4.6 KiB
C++
/*******************************************************************************
|
|
* hook-rs422_kk.h
|
|
*
|
|
* FPGA扩展RS422串口外挂程序头文件
|
|
******************************************************************************/
|
|
|
|
#ifndef HOOK_RS422_KK_H_
|
|
#define HOOK_RS422_KK_H_
|
|
|
|
#include "SimMsg.h"
|
|
|
|
#include <stdint.h>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
// 星间通信机子遥测
|
|
typedef union {
|
|
uint8_t ext[9]; // 72位数据的联合体
|
|
struct __attribute__((__packed__)) {
|
|
unsigned int temperature : 12; // 温度遥测
|
|
unsigned int temperature_calibrated : 12; // 温度遥测标校
|
|
unsigned int transmission_power : 12; // 12V电源遥测
|
|
unsigned int power_supply_5v4 : 12; // 5.4V电源遥测
|
|
unsigned int power_supply_2v5 : 12; // 2.5V电源遥测
|
|
unsigned int power_supply_1v2 : 12; // 1.2V电源遥测
|
|
};
|
|
} s_comm_telemetry_t;
|
|
|
|
// 星间通信机参数0
|
|
typedef union {
|
|
uint8_t ext;
|
|
struct __attribute__((__packed__)) {
|
|
unsigned int loadNo : 2; // 加载程序编号
|
|
unsigned int loadMode : 2; // 加载模式
|
|
unsigned int AorB : 1; // AB机状态
|
|
unsigned int FPGAFresh : 1; // FPGA刷新状态
|
|
unsigned int zaiboSync : 1; // 信息载波同步
|
|
unsigned int weimaSync : 1; // 信息伪码同步
|
|
};
|
|
} s_comm_para0;
|
|
|
|
// 星间通信机参数2
|
|
typedef union {
|
|
uint8_t ext;
|
|
struct __attribute__((__packed__)) {
|
|
unsigned int transDampCtrl : 3; // 发射衰减控制字
|
|
unsigned int trans : 1; // 发射通道开关
|
|
unsigned int recDampCtrl : 3; // 接收衰减控制字
|
|
unsigned int recDampCtrlMode : 1; // 接收衰减控制模式
|
|
};
|
|
} s_comm_para2;
|
|
|
|
// 星间通信机参数3
|
|
typedef union {
|
|
uint8_t ext;
|
|
struct __attribute__((__packed__)) {
|
|
unsigned int recStatus : 1; // 接收缓存状态
|
|
unsigned int workmode : 2; // 工作模式
|
|
unsigned int sendStatus : 1; // 发射缓存状态
|
|
unsigned int antsChoice : 1; // 天线选择
|
|
unsigned int FreqChoice : 1; // 频点选择
|
|
unsigned int telem_MM_Mode : 1; // 遥测明/密状态
|
|
unsigned int telec_MM_Mode : 1; // 遥控明/密状态
|
|
};
|
|
} s_comm_para3;
|
|
|
|
// S通信机遥测结构体
|
|
typedef struct __attribute__((packed)) {
|
|
uint8_t packet_cnt_1; // 遥测包计数
|
|
uint8_t cmd1_success_count; // 接收指令1正确计数
|
|
uint8_t cmd1_err_type1_count; // 接收指令1错误类型1计数
|
|
uint8_t cmd2_success_count; // 接收指令2正确计数
|
|
uint8_t cmd2_err_count; // 接收指令2错误计数
|
|
uint8_t reset_count; // 复位计数
|
|
uint8_t refresh_count; // 刷新状态计数
|
|
s_comm_para0 para0;
|
|
uint8_t para1;
|
|
int8_t dopplerFreqInfoChannel; // 信息通道多普勒频偏
|
|
int8_t dopplerFreqMeasureChannel; // 测量通道多普勒频偏
|
|
uint8_t snrInfoChannel; // 信息通道接收信噪比
|
|
uint8_t snrMeasureChannel; // 测量通道接收信噪比
|
|
uint8_t receive_RSSI; // 接收RSSI
|
|
uint8_t generalQueryCount; // 常规遥测查询计数
|
|
uint8_t forwardcmdcnt; // 转发遥控指令计数
|
|
uint8_t cmdinquiryCount; // 空空接收后遥控计数
|
|
uint8_t teletransmissionCount; // 转发遥测计数
|
|
uint8_t res0[2]; // LVDS预留参数
|
|
s_comm_para2 para2;
|
|
s_comm_telemetry_t s_telemetry;
|
|
uint8_t AD9364_configuration_count; // AD9364配置计数
|
|
s_comm_para3 para3;
|
|
uint8_t res1[3]; // 预留参数
|
|
uint8_t cmd1_err_type2_count; // 接收指令1错误类型2计数
|
|
uint16_t teletransmission_secretkey; // 遥测当前密钥
|
|
uint16_t telecmd_secretkey; // 遥控当前密钥
|
|
uint16_t LVDS_sendCnt; // LVDS发送计数
|
|
} S_Comm_telemetry_data_t;
|
|
|
|
// 全局变量声明
|
|
extern volatile int keep_running;
|
|
extern uint8_t scomm_enable;
|
|
|
|
// FastDDS接口函数
|
|
void pkginit(uint8_t domainid, std::string appname, std::string pkgname_);
|
|
void PkgToO2_AkkDataPub(uint8_t* o2_kk_data, uint16_t len);
|
|
void PkgToO_1kkDataPub(uint8_t* o1_kk_data, uint16_t len);
|
|
void pkgSubO_1KKData(message_func_t MessageCallback);
|
|
void PkgSubO2_AKkData(message_func_t MessageCallback);
|
|
|
|
// 主程序函数
|
|
void hook_rs422_kk(const char* tx_port, const char* rx_port);
|
|
void set_scomm_enable(uint8_t s_en);
|
|
void cleanup_hook_rs422();
|
|
|
|
#endif /* HOOK_RS422_KK_H_ */ |