|
|
|
|
/*****************************************************************************
|
|
|
|
|
* file include/pd_dbg.h
|
|
|
|
|
* author YuLiang
|
|
|
|
|
* version 1.0.0
|
|
|
|
|
* date 01-June-2023
|
|
|
|
|
* brief This file provides all the headers of the debug server functions.
|
|
|
|
|
******************************************************************************
|
|
|
|
|
* Attention
|
|
|
|
|
*
|
|
|
|
|
* <h2><center>© COPYRIGHT(c) 2021 LandPower</center></h2>
|
|
|
|
|
*
|
|
|
|
|
* Redistribution and use in source and binary forms, with or without modification,
|
|
|
|
|
* are permitted provided that the following conditions are met:
|
|
|
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer.
|
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
* this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
* and/or other materials provided with the distribution.
|
|
|
|
|
* 3. Neither the name of LandPower nor the names of its contributors may be used to
|
|
|
|
|
* endorse or promote products derived from this software without specific
|
|
|
|
|
* prior written permission.
|
|
|
|
|
*
|
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
|
|
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
|
|
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
*
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef __PD_DBG_H__
|
|
|
|
|
#define __PD_DBG_H__
|
|
|
|
|
|
|
|
|
|
#ifdef CFG_DEV_TYPE_LAND_PD
|
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
|
#include "pd_main.h"
|
|
|
|
|
|
|
|
|
|
/* Define --------------------------------------------------------------------*/
|
|
|
|
|
#define DEBUG_DAU_FILE_UPGRADE "/lib/firmware/system_wrapper.bin.upgrade"
|
|
|
|
|
#define DEBUG_DAU_FILE_BAK "./bak/system_wrapper_bak.bin.bak"
|
|
|
|
|
#define DEBUG_DAU_FILE "/lib/firmware/system_wrapper.bin"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define DEBUG_BUG_SIZE 1512
|
|
|
|
|
#define DEBUG_CJSON_BUG_SIZE 1512
|
|
|
|
|
|
|
|
|
|
//#define DEBUG_NOISE_CAREFOR (0x0007) // 关注对应通道的底噪原始值, 校准底噪值.
|
|
|
|
|
//#define DEBUG_NOISE_POST (0x0008) // 获取底噪原始值, 校准底噪值 服务端主动提交每秒刷新一次.
|
|
|
|
|
|
|
|
|
|
enum DebugCommand
|
|
|
|
|
{
|
|
|
|
|
DEBUG_CONFIG_FACTORY_GET = 1, // 获取配置
|
|
|
|
|
DEBUG_CONFIG_FACTORY_SET = 2, // 设置配置
|
|
|
|
|
DEBUG_CONFIG_GLOBAL_SET = 3, /* 设备全局参数设置 */
|
|
|
|
|
DEBUG_CONFIG_GLOBAL_GET = 4, /* 设备全局参数获取 */
|
|
|
|
|
DEBUG_CONFIG_PORT_SET = 5, /* 设备端口参数设置 */
|
|
|
|
|
DEBUG_CONFIG_PORT_GET = 6, /* 设备端口参数获取 */
|
|
|
|
|
DEBUG_REBOOT = 7, // 重启
|
|
|
|
|
DEBUG_TIME_SET = 8, // 对时
|
|
|
|
|
|
|
|
|
|
DEBUG_ADJSUT_COEFFICIENT_GET = 9, // 获取校准系数
|
|
|
|
|
DEBUG_ADJSUT_COEFFICIENT_SET = 10, // 设置校准系数
|
|
|
|
|
DEBUG_NOISE_POST = 11, // 自动获取采样值
|
|
|
|
|
DEBUG_NOISE_CAREFOR = 12, // 使能自动获取采样值功能
|
|
|
|
|
|
|
|
|
|
DEBUG_DEVICE_STATUS = 13, // 查询设备状态(后台连接、4G连接)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEBUG_ARM_UPGRADE = 0x0050, // ARM 升级
|
|
|
|
|
DEBUG_FPGA1_UPGRADE = 0x0051, // FPGA 板卡升级
|
|
|
|
|
DEBUG_UPGRADE_ALL = 0x0056 // ARM 和 FPGA 板卡升级
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define BITMAP_SAVE_FILE (1 << 0)
|
|
|
|
|
#define BITMAP_IP_CHANGE (1 << 1)
|
|
|
|
|
|
|
|
|
|
#define DEBUG_MANAGE_TOOL_PORT (10050)
|
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
|
|
|
/* 端口校准系数. */
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint16_t point[4]; // 通道分段点.
|
|
|
|
|
uint16_t param_a[5]; // 通道线性度校准系数 a.
|
|
|
|
|
uint16_t param_b[5]; // 通道线性度校准系数 b.
|
|
|
|
|
uint16_t alarm_ref; // 断线告警比较值.
|
|
|
|
|
uint16_t reserve;
|
|
|
|
|
} debug_pkt_adj_vport_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
debug_pkt_adj_vport_t vport[PD_PORT_SUM];
|
|
|
|
|
} debug_pkt_adj_t;
|
|
|
|
|
|
|
|
|
|
/* 端口状态, 主要是 ADC 原始值和校准后的值.*/
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint16_t value_adc;
|
|
|
|
|
int16_t value_adj;
|
|
|
|
|
} debug_pkt_port_state_t;
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
|
debug_pkt_port_state_t vport[PD_PORT_SUM];
|
|
|
|
|
} debug_pkt_port_t;
|
|
|
|
|
|
|
|
|
|
/* 设备状态. */
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint32_t idx; // 编号.
|
|
|
|
|
uint32_t UTC_TimeScale; // UTC 时标
|
|
|
|
|
float F50Hz_Frequency; // 同步 50Hz 频率.
|
|
|
|
|
uint8_t F50Hz_SynStatus; // 同步状态.
|
|
|
|
|
uint8_t dau_status; // 插件状态.
|
|
|
|
|
uint16_t sensor_status; // 传感器断线状态.
|
|
|
|
|
uint16_t is_server_link; // 是否连接上后台.
|
|
|
|
|
uint16_t version; // 软件版本
|
|
|
|
|
uint32_t communication_time; // 上一次通讯的时间
|
|
|
|
|
uint32_t run_time; // 设备运行时间
|
|
|
|
|
} debug_pkt_status_t;
|
|
|
|
|
|
|
|
|
|
/* 报文头. */
|
|
|
|
|
typedef struct{
|
|
|
|
|
uint16_t head; // 0x55aa.
|
|
|
|
|
uint16_t cmd; // 命令.
|
|
|
|
|
uint32_t len; // 包长.
|
|
|
|
|
} debug_pkt_head_t;
|
|
|
|
|
|
|
|
|
|
/* 调试工具全局结构 */
|
|
|
|
|
typedef struct{
|
|
|
|
|
int fd; // TCP server 监听使用的 socket.
|
|
|
|
|
int fd_client; // TCP client 通讯使用的 socket.
|
|
|
|
|
char buf[DEBUG_BUG_SIZE]; // 通讯使用收法包 buffer.
|
|
|
|
|
char buf_post[DEBUG_BUG_SIZE]; // 主动上传通讯使用收法包 buffer.
|
|
|
|
|
int is_manual_col; // 是否手动采集.
|
|
|
|
|
} debug_ctrl_t;
|
|
|
|
|
|
|
|
|
|
/* 报文头结构. */
|
|
|
|
|
typedef struct{
|
|
|
|
|
uint16_t head; // 0x55aa.
|
|
|
|
|
|
|
|
|
|
uint32_t len;
|
|
|
|
|
uint8_t dev_type_m;
|
|
|
|
|
uint8_t dev_type_s;
|
|
|
|
|
uint16_t dev_id;
|
|
|
|
|
uint8_t cmd_type;
|
|
|
|
|
uint8_t cmd;
|
|
|
|
|
uint16_t pkt_id;
|
|
|
|
|
uint8_t reserve[18];
|
|
|
|
|
} dbg_pkt_head_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 基础信息 */
|
|
|
|
|
typedef struct{
|
|
|
|
|
uint8_t type_m; // 主设备号
|
|
|
|
|
uint8_t type_s; // 次设备号
|
|
|
|
|
uint8_t reserved1[2]; // 保留
|
|
|
|
|
uint32_t dev_id; // 设备ID
|
|
|
|
|
char hostname[FILE_NAME_LEN]; // 设备名 128byte
|
|
|
|
|
uint32_t factory_date; // 出厂日期.
|
|
|
|
|
uint32_t deployment_date; // 部署日期.
|
|
|
|
|
uint8_t app_version[32]; // 软件版本
|
|
|
|
|
uint8_t app_compile_time[32]; // 软件编译时间
|
|
|
|
|
uint8_t hardware_version[32]; // 硬件版本
|
|
|
|
|
uint8_t FPGA_version[32]; // fpga版本
|
|
|
|
|
uint32_t ip; // 本机(服务器) IP.
|
|
|
|
|
uint32_t mask; // 本机(服务器) MASK.
|
|
|
|
|
uint32_t gw; // 本机(服务器)网关
|
|
|
|
|
uint8_t mac[6]; // MAC地址.
|
|
|
|
|
uint16_t csg_port; // 后台端口号.
|
|
|
|
|
uint32_t csg_ipv4; // 后台 IP.
|
|
|
|
|
uint32_t running_time; //运行时间
|
|
|
|
|
} dbg_device_info_t;
|
|
|
|
|
|
|
|
|
|
/* 全局配置 */
|
|
|
|
|
#pragma pack(push, 1)
|
|
|
|
|
typedef struct{
|
|
|
|
|
uint16_t power_frequency; // 工频频率, 单位: 0.1Hz
|
|
|
|
|
uint16_t trend_period; // 趋势数据上送周期, 单位: 秒.
|
|
|
|
|
uint8_t sync_mode; // 同步方式 1: PT 同步 2: 内同步(默认) 3: 外接信号同步.
|
|
|
|
|
uint8_t heartbeat_period; // 心跳包周期, 单位: 分钟.
|
|
|
|
|
uint8_t pps_mode; // pps 主从模式 PD_PPS_XXX.
|
|
|
|
|
uint8_t reserved[1];
|
|
|
|
|
uint16_t trend_storage; // 趋势存储文件数量阈值.
|
|
|
|
|
uint16_t event_storage; // 事件存储文件数量阈值
|
|
|
|
|
uint8_t is_4G_enable; // 是否使用 4G 模块
|
|
|
|
|
char APN[PD_4G_APN_LEN]; // 4G 模块 APN
|
|
|
|
|
} dbg_global_config_t;
|
|
|
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 端口配置. */
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint8_t vport; // 通道编号.
|
|
|
|
|
uint8_t port_type; // 采集通道类型 , 1 表示特高频局放 2 表示超声局放 3 表示 TEV 4 表示高频.
|
|
|
|
|
uint8_t filter; // 滤波器类型 1: 低频段 2: 全频段 3: 窄频段 4: 高频段
|
|
|
|
|
uint8_t sensor_type; // 0: 无配置; 1: UHF信号传感器; 2: UHF噪声传感器 ; 3: UHF信号传感器, 关联噪声降噪.
|
|
|
|
|
uint8_t is_auto_noise; // 是否自动调整降噪等级.
|
|
|
|
|
uint8_t denoise_type; // 0-无配置 1-自动 2-手动降噪
|
|
|
|
|
uint8_t reserved0[2];
|
|
|
|
|
|
|
|
|
|
uint32_t event_counter_h; // 事件次数阀值高.
|
|
|
|
|
uint16_t event_sec_h; // 事件每秒次数阀值高.
|
|
|
|
|
uint16_t event_thr_h; // 事件值阈值高.
|
|
|
|
|
uint32_t event_counter_thr_h; // 事件值阈值高的次数.
|
|
|
|
|
|
|
|
|
|
uint32_t event_counter_l; // 事件次数阀值低.
|
|
|
|
|
uint16_t event_sec_l; // 事件每秒次数阀值低.
|
|
|
|
|
uint16_t event_thr_l; // 事件值阈值低.
|
|
|
|
|
uint32_t event_counter_thr_l; // 事件值阈值低的次数.
|
|
|
|
|
|
|
|
|
|
uint8_t burst_time; // 事件突发计算时间
|
|
|
|
|
uint8_t reserved1[1];
|
|
|
|
|
uint16_t burst_thr; // 事件突发阈值
|
|
|
|
|
|
|
|
|
|
int16_t denoise_manual; // 手动底噪等级
|
|
|
|
|
int16_t denoise_auto; // 自动降噪水平
|
|
|
|
|
}dbg_port_config_t;
|
|
|
|
|
|
|
|
|
|
/* 高频通道校准系数 */
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint16_t param_a[PD_PORT_SUM]; // 通道线性度校准系数 a.
|
|
|
|
|
uint16_t param_b[PD_PORT_SUM]; // 通道线性度校准系数 b.
|
|
|
|
|
} debug_hf_pkt_adj_vport_t;
|
|
|
|
|
|
|
|
|
|
/* 设备状态. */
|
|
|
|
|
typedef struct {
|
|
|
|
|
uint8_t csg_connect_status; // 后台连接状态.
|
|
|
|
|
uint8_t ec20_connect_status; // 4g模块连接状态
|
|
|
|
|
} debug_pkt_dev_connect_status_t;
|
|
|
|
|
|
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
|
|
|
|
|
|
|
|
/* Extern global variables ---------------------------------------------------*/
|
|
|
|
|
extern debug_ctrl_t debug_ctrl;
|
|
|
|
|
|
|
|
|
|
/* Extern functions ----------------------------------------------------------*/
|
|
|
|
|
extern int32_t debug_handle_init(void);
|
|
|
|
|
extern int32_t debug_handle_init_after(void);
|
|
|
|
|
extern int32_t debug_pkt_port_state_post(void);
|
|
|
|
|
extern void debug_upgrade_result_send(int32_t rv, char *buf);
|
|
|
|
|
#endif
|
|
|
|
|
#endif
|
|
|
|
|
/************************ (C) COPYRIGHT LandPower ***** END OF FILE ****/
|