|
|
@ -36,6 +36,7 @@
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "stdio.h"
|
|
|
|
#include "string.h"
|
|
|
|
#include "string.h"
|
|
|
|
|
|
|
|
#include "math.h"
|
|
|
|
|
|
|
|
|
|
|
|
#include "usart.h"
|
|
|
|
#include "usart.h"
|
|
|
|
|
|
|
|
|
|
|
@ -46,7 +47,7 @@
|
|
|
|
#include "wireless.h"
|
|
|
|
#include "wireless.h"
|
|
|
|
#include "flash_if.h"
|
|
|
|
#include "flash_if.h"
|
|
|
|
#include "flash_log.h"
|
|
|
|
#include "flash_log.h"
|
|
|
|
#include "dau.h"
|
|
|
|
#include "dau.h"
|
|
|
|
|
|
|
|
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
/* Private define ------------------------------------------------------------*/
|
|
|
|
#define DEBUG_FLASH_BUF_SIZE DEBUG_DATA_SIZE
|
|
|
|
#define DEBUG_FLASH_BUF_SIZE DEBUG_DATA_SIZE
|
|
|
@ -85,19 +86,15 @@ typedef struct
|
|
|
|
/* RS485 调试通讯协议配置信息. */
|
|
|
|
/* RS485 调试通讯协议配置信息. */
|
|
|
|
typedef struct
|
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint16_t flag;
|
|
|
|
uint8_t debug_mode; // 调试模式.
|
|
|
|
uint8_t energy_mode;
|
|
|
|
uint8_t work_mode; // 工作模式.
|
|
|
|
uint8_t is_voltage_col;
|
|
|
|
uint16_t col_inr; // 采集间隔, 单位: 分钟.
|
|
|
|
uint8_t sensor_id[SENSOR_SUM];
|
|
|
|
uint16_t live_inr; // 保活间隔, 单位: 分钟.
|
|
|
|
uint16_t collect_interval;
|
|
|
|
uint16_t power_thr; // 工频阈值, 单位: A.
|
|
|
|
uint16_t wave_interval;
|
|
|
|
uint16_t defect_thr; // 隐患阈值, 单位: mA.
|
|
|
|
uint16_t collect_threshold;
|
|
|
|
uint16_t fault_thr; // 故障阈值, 单位: A.
|
|
|
|
uint16_t wave_threshold;
|
|
|
|
uint8_t APN[DEV_APN_LEN]; // APN 名字.
|
|
|
|
uint8_t main_cable;
|
|
|
|
uint8_t reserve[20];
|
|
|
|
uint8_t normal_sleep;
|
|
|
|
|
|
|
|
uint8_t is_temp_col;
|
|
|
|
|
|
|
|
uint8_t is_wave_col;
|
|
|
|
|
|
|
|
uint8_t APN[DEV_APN_LEN];
|
|
|
|
|
|
|
|
} debug_config_t;
|
|
|
|
} debug_config_t;
|
|
|
|
|
|
|
|
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
|
/* Private macro -------------------------------------------------------------*/
|
|
|
@ -112,7 +109,9 @@ static UART_HandleTypeDef *debug_adj_uart = &huart4;
|
|
|
|
static uint8_t debug_state = 0;
|
|
|
|
static uint8_t debug_state = 0;
|
|
|
|
/* 远程升级 flash 数据校验使用. */
|
|
|
|
/* 远程升级 flash 数据校验使用. */
|
|
|
|
static uint8_t debug_flash[DEBUG_FLASH_BUF_SIZE];
|
|
|
|
static uint8_t debug_flash[DEBUG_FLASH_BUF_SIZE];
|
|
|
|
extern int8_t g_is_adj_status;
|
|
|
|
static dev_adj_defect_zero_t debug_adj_defect;
|
|
|
|
|
|
|
|
dev_adj_fault_zero_t debug_adj_fault;
|
|
|
|
|
|
|
|
dev_adj_power_t debug_adj_power;
|
|
|
|
|
|
|
|
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Private function prototypes -----------------------------------------------*/
|
|
|
|
/* Internal functions --------------------------------------------------------*/
|
|
|
|
/* Internal functions --------------------------------------------------------*/
|
|
|
@ -537,19 +536,38 @@ static void _debug_pkt_config_get(void)
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
debug_config_t *data = (debug_config_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
debug_config_t *data = (debug_config_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(debug_config_t), DEBUG_CT_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(debug_config_t), DEBUG_CT_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装数据. */
|
|
|
|
/* 封装数据. */
|
|
|
|
data->flag = dev_config.flag;
|
|
|
|
if (IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_CLI))
|
|
|
|
for(i = 0; i < SENSOR_SUM; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
data->debug_mode = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
data->sensor_id[i] = 0;
|
|
|
|
data->debug_mode = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
data->collect_interval = dev_config.collect_interval;
|
|
|
|
|
|
|
|
data->wave_interval = 12;
|
|
|
|
if (IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->work_mode = 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_FACTORY))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->work_mode = 2;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->work_mode = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data->col_inr = dev_config.collect_interval;
|
|
|
|
|
|
|
|
data->live_inr = dev_config.keepalive;
|
|
|
|
|
|
|
|
data->power_thr = dev_config.power_threshold;
|
|
|
|
|
|
|
|
data->defect_thr = dev_config.defect_threshold;
|
|
|
|
|
|
|
|
data->fault_thr = dev_config.fault_threshold;
|
|
|
|
memcpy(data->APN, dev_config.APN, DEV_APN_LEN);
|
|
|
|
memcpy(data->APN, dev_config.APN, DEV_APN_LEN);
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
@ -567,18 +585,37 @@ static void _debug_pkt_config_set(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
debug_config_t *data = (debug_config_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
debug_config_t *data = (debug_config_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint16_t flag = 0;
|
|
|
|
uint8_t is_reboot = FALSE;
|
|
|
|
uint8_t is_reboot = FALSE;
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存数据. */
|
|
|
|
/* 保存数据. */
|
|
|
|
if (dev_config.flag != data->flag)
|
|
|
|
if (0 == data->debug_mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MONITOR_BITMAP_SET(flag, DEV_FLAG_CLI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (1 == data->work_mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MONITOR_BITMAP_SET(flag, DEV_FLAG_ADJ);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if(2 == data->work_mode)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
MONITOR_BITMAP_SET(flag, DEV_FLAG_FACTORY);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dev_config.flag != flag)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
is_reboot = TRUE;
|
|
|
|
is_reboot = TRUE;
|
|
|
|
dev_config_flag_assgin(data->flag);
|
|
|
|
dev_config_flag_assgin(flag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
dev_config.collect_interval = data->collect_interval;
|
|
|
|
dev_config.collect_interval = data->col_inr;
|
|
|
|
|
|
|
|
dev_config.keepalive = data->live_inr;
|
|
|
|
|
|
|
|
dev_config.power_threshold = data->power_thr;
|
|
|
|
|
|
|
|
dev_config.defect_threshold = data->defect_thr;
|
|
|
|
|
|
|
|
dev_config.fault_threshold = data->fault_thr;
|
|
|
|
memcpy(dev_config.APN, data->APN, DEV_APN_LEN);
|
|
|
|
memcpy(dev_config.APN, data->APN, DEV_APN_LEN);
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
@ -608,20 +645,15 @@ static void _debug_pkt_config_set(void)
|
|
|
|
static void _debug_pkt_adj_get(void)
|
|
|
|
static void _debug_pkt_adj_get(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
dev_adj_t *data = (dev_adj_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
dev_adj_cfg_t *data = (dev_adj_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_adj_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_adj_cfg_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装数据, 这里减 4 是因为结构体最后 4byte 位置特殊. */
|
|
|
|
/* 封装数据, 这里减 4 是因为结构体最后 4byte 位置特殊. */
|
|
|
|
memcpy(data->ADCRatio, dev_config.ADC_ratio, sizeof(dev_config.ADC_ratio));
|
|
|
|
memcpy(data->power_adj, dev_config.power_adj, 64);
|
|
|
|
memcpy(data->ADCBase_elec, dev_config.ADC_base_elec, sizeof(dev_config.ADC_base_elec));
|
|
|
|
|
|
|
|
memcpy(data->ADCAdj, dev_config.ADC_adj, sizeof(dev_config.ADC_adj));
|
|
|
|
|
|
|
|
memcpy(data->ADCBase, dev_config.ADC_base, sizeof(dev_config.ADC_base));
|
|
|
|
|
|
|
|
data->vin = dev_config.vin;
|
|
|
|
|
|
|
|
data->vin_adj = dev_config.vin_adj;
|
|
|
|
data->vin_adj = dev_config.vin_adj;
|
|
|
|
memcpy(data->ADC_turns, dev_config.ADC_turns, DAU_PORT_POWER_CNT);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -634,20 +666,67 @@ static void _debug_pkt_adj_get(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 校准参数设置报文处理. */
|
|
|
|
/* 校准参数设置报文处理. */
|
|
|
|
static void _debug_pkt_adj_set(void)
|
|
|
|
static void _debug_pkt_adj_set_power(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
dev_adj_t *data = (dev_adj_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
dev_adj_power_cfg_t *data = (dev_adj_power_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置参数. */
|
|
|
|
/* 配置参数. */
|
|
|
|
memcpy(dev_config.ADC_ratio, data->ADCRatio, sizeof(dev_config.ADC_ratio));
|
|
|
|
memcpy(dev_config.power_adj, data->power_adj, 32);
|
|
|
|
memcpy(dev_config.ADC_base_elec, data->ADCBase_elec, sizeof(dev_config.ADC_base_elec));
|
|
|
|
|
|
|
|
memcpy(dev_config.ADC_adj, data->ADCAdj, sizeof(dev_config.ADC_adj));
|
|
|
|
|
|
|
|
memcpy(dev_config.ADC_base, data->ADCBase, sizeof(dev_config.ADC_base));
|
|
|
|
|
|
|
|
dev_config.vin = data->vin;
|
|
|
|
|
|
|
|
dev_config.vin_adj = data->vin_adj;
|
|
|
|
dev_config.vin_adj = data->vin_adj;
|
|
|
|
memcpy(dev_config.ADC_turns, data->ADC_turns, DAU_PORT_POWER_CNT);
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存参数. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 校准参数设置报文处理. */
|
|
|
|
|
|
|
|
static void _debug_pkt_adj_set_defect(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_defect_cfg_t *data = (dev_adj_defect_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置参数. */
|
|
|
|
|
|
|
|
memcpy(dev_config.defect_base, data->defect_base, sizeof(dev_adj_defect_cfg_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存参数. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 校准参数设置报文处理. */
|
|
|
|
|
|
|
|
static void _debug_pkt_adj_set_fault(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_fault_cfg_t *data = (dev_adj_fault_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置参数. */
|
|
|
|
|
|
|
|
memcpy(dev_config.fault_base, data->fault_base, sizeof(dev_adj_fault_cfg_t));
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
@ -752,9 +831,9 @@ static HAL_StatusTypeDef _debug_adj_source_set(uint8_t ch_bitmap, uint8_t index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
turn_num = 20;
|
|
|
|
turn_num = 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] = %d turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index], turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] = %d turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index], turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] / turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index]/turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] / turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index]/turn_num);
|
|
|
|
|
|
|
|
|
|
|
|
/* 填充 buf, 设置电流电压. */
|
|
|
|
/* 填充 buf, 设置电流电压. */
|
|
|
|
_debug_adj_source_set_buf(2200000, dev_config.ADC_base_elec[ch][index] / turn_num);
|
|
|
|
_debug_adj_source_set_buf(2200000, dev_config.ADC_base_elec[ch][index] / turn_num);
|
|
|
@ -788,7 +867,7 @@ static HAL_StatusTypeDef _debug_adj_source_set(uint8_t ch_bitmap, uint8_t index)
|
|
|
|
osDelay(4000);
|
|
|
|
osDelay(4000);
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HAL_StatusTypeDef _debug_adj_source_setEx(uint8_t ch_bitmap, uint8_t index, uint16_t elec)
|
|
|
|
static HAL_StatusTypeDef _debug_adj_source_setEx(uint8_t ch_bitmap, uint8_t index, uint16_t elec)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
debug_adj_head_t *head = (debug_adj_head_t*)&debug_flash[1];
|
|
|
|
debug_adj_head_t *head = (debug_adj_head_t*)&debug_flash[1];
|
|
|
@ -814,9 +893,9 @@ static HAL_StatusTypeDef _debug_adj_source_setEx(uint8_t ch_bitmap, uint8_t inde
|
|
|
|
{
|
|
|
|
{
|
|
|
|
turn_num = 20;
|
|
|
|
turn_num = 20;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] = %d turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index], turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] = %d turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index], turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] / turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index]/turn_num);
|
|
|
|
DBG(DBG_M_RS485_SEN, "ADC_base_elec[%d][%d] / turn_num = %d\r\n", ch, index, dev_config.ADC_base_elec[ch][index]/turn_num);
|
|
|
|
|
|
|
|
|
|
|
|
/* 填充 buf, 设置电流电压. */
|
|
|
|
/* 填充 buf, 设置电流电压. */
|
|
|
|
_debug_adj_source_set_buf(2200000, elec);
|
|
|
|
_debug_adj_source_set_buf(2200000, elec);
|
|
|
@ -849,8 +928,8 @@ static HAL_StatusTypeDef _debug_adj_source_setEx(uint8_t ch_bitmap, uint8_t inde
|
|
|
|
/* 等待电压电流稳定. */
|
|
|
|
/* 等待电压电流稳定. */
|
|
|
|
osDelay(4000);
|
|
|
|
osDelay(4000);
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 自动校准仪器连接. */
|
|
|
|
/* 自动校准仪器连接. */
|
|
|
|
static HAL_StatusTypeDef _debug_adj_connect(void)
|
|
|
|
static HAL_StatusTypeDef _debug_adj_connect(void)
|
|
|
@ -943,6 +1022,77 @@ static HAL_StatusTypeDef _debug_adj_start(void)
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 工频系数自动计算. */
|
|
|
|
|
|
|
|
void _debug_adj_power_cal(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int16_t (*val)[DAU_POWER_DATE_LEN] = dau_ctrl.reg_power;
|
|
|
|
|
|
|
|
uint8_t ch = 0;
|
|
|
|
|
|
|
|
uint16_t i = 0;
|
|
|
|
|
|
|
|
uint64_t square_sum = 0;
|
|
|
|
|
|
|
|
int32_t mean = 0;
|
|
|
|
|
|
|
|
float base_elec = 0;
|
|
|
|
|
|
|
|
float temp = 0;
|
|
|
|
|
|
|
|
int16_t min = 32767;
|
|
|
|
|
|
|
|
int16_t max = -32768;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 遍历通道, 计算有效值 */
|
|
|
|
|
|
|
|
for(ch = 0; ch < DAU_PORT_POWER_CNT; ch++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!IS_MONITOR_BIT_SET(debug_adj_power.bitmap, ch))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算所有值的算术平均值 */
|
|
|
|
|
|
|
|
mean = 0;
|
|
|
|
|
|
|
|
min = 32767;
|
|
|
|
|
|
|
|
max = -32768;
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_POWER_DATE_LEN; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (val[ch][i] < min)
|
|
|
|
|
|
|
|
min = val[ch][i];
|
|
|
|
|
|
|
|
if (val[ch][i] > max)
|
|
|
|
|
|
|
|
max = val[ch][i];
|
|
|
|
|
|
|
|
mean += val[ch][i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mean = mean / DAU_POWER_DATE_LEN;
|
|
|
|
|
|
|
|
vty_print("#DE P%d %d %d %d", ch, mean, min, max);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 遍历通道所有值, 求和, 并计算出最大值和最小值. */
|
|
|
|
|
|
|
|
square_sum = 0;
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_POWER_DATE_LEN; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
val[ch][i] -= mean;
|
|
|
|
|
|
|
|
square_sum += val[ch][i] * val[ch][i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 根据数据查找数据落在哪个分段点上. */
|
|
|
|
|
|
|
|
temp = (double)sqrt(square_sum / DAU_POWER_DATE_LEN);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算系数. */
|
|
|
|
|
|
|
|
if (ch < 4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dev_config.power_adj[ch] = (uint16_t)(temp * 8000 / (debug_adj_power.elec * 10));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
dev_config.power_adj[ch] = (uint16_t)(temp * 120000 / (debug_adj_power.elec * 10));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (ch < 4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base_elec = debug_adj_power.elec * 14.14 * 2;
|
|
|
|
|
|
|
|
dev_config.power_adj_point[ch] = (uint16_t)((max - min) * 8000 / base_elec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
base_elec = debug_adj_power.elec * 1.414 * 2;
|
|
|
|
|
|
|
|
dev_config.power_adj_point[ch] = (uint16_t)((max - min) * 12000 / base_elec);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 自动校准处理. */
|
|
|
|
/* 自动校准处理. */
|
|
|
|
static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -954,15 +1104,15 @@ static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 设置开始操作. */
|
|
|
|
/* 设置开始操作. */
|
|
|
|
HAL_E_RETURN(_debug_adj_start());
|
|
|
|
HAL_E_RETURN(_debug_adj_start());
|
|
|
|
|
|
|
|
|
|
|
|
//for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
//for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
for(i = 0; i < 1; i++)
|
|
|
|
for(i = 0; i < 1; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i) || 0 == dev_config.ADC_ratio[i])
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -971,8 +1121,7 @@ static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
bitmap_new = 0;
|
|
|
|
bitmap_new = 0;
|
|
|
|
for (j = i; j < DAU_PORT_POWER_CNT; j++)
|
|
|
|
for (j = i; j < DAU_PORT_POWER_CNT; j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, j)
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, j))
|
|
|
|
|| dev_config.ADC_ratio[i] != dev_config.ADC_ratio[j])
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -985,15 +1134,15 @@ static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
for (j = 0; j < 1; j++) // 只校准一个分段点 2024/12/11
|
|
|
|
for (j = 0; j < 1; j++) // 只校准一个分段点 2024/12/11
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HAL_E_RETURN(_debug_adj_source_set(bitmap_new, j));
|
|
|
|
HAL_E_RETURN(_debug_adj_source_set(bitmap_new, j));
|
|
|
|
osDelay(3000);
|
|
|
|
osDelay(3000);
|
|
|
|
g_is_adj_status = 1;
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_POWER;
|
|
|
|
while (g_is_adj_status != 2)
|
|
|
|
while (dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
osDelay(2000);
|
|
|
|
osDelay(2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBG(DBG_M_RS485_DEBUG, "capture end...\r\n");
|
|
|
|
DBG(DBG_M_RS485_DEBUG, "capture end...\r\n");
|
|
|
|
HAL_E_RETURN(_dau_base_auto(bitmap_new, j + 1));
|
|
|
|
_debug_adj_power_cal();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1002,7 +1151,7 @@ static HAL_StatusTypeDef _debug_adj_auto(uint8_t bitmap)
|
|
|
|
|
|
|
|
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_t index)
|
|
|
|
static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_t index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t i = 0;
|
|
|
|
uint8_t i = 0;
|
|
|
@ -1016,12 +1165,12 @@ static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_
|
|
|
|
|
|
|
|
|
|
|
|
/* 设置开始操作. */
|
|
|
|
/* 设置开始操作. */
|
|
|
|
HAL_E_RETURN(_debug_adj_start());
|
|
|
|
HAL_E_RETURN(_debug_adj_start());
|
|
|
|
|
|
|
|
|
|
|
|
//for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
//for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
for(i = 0; i < 1; i++)
|
|
|
|
for(i = 0; i < 1; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i) || 0 == dev_config.ADC_ratio[i])
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1030,8 +1179,7 @@ static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_
|
|
|
|
bitmap_new = 0;
|
|
|
|
bitmap_new = 0;
|
|
|
|
for (j = i; j < DAU_PORT_POWER_CNT; j++)
|
|
|
|
for (j = i; j < DAU_PORT_POWER_CNT; j++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, j)
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, j))
|
|
|
|
|| dev_config.ADC_ratio[i] != dev_config.ADC_ratio[j])
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1045,15 +1193,14 @@ static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HAL_E_RETURN(_debug_adj_source_setEx(bitmap_new, index-1, elec));
|
|
|
|
HAL_E_RETURN(_debug_adj_source_setEx(bitmap_new, index-1, elec));
|
|
|
|
osDelay(5000);
|
|
|
|
osDelay(5000);
|
|
|
|
g_is_adj_status = 1;
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_POWER;
|
|
|
|
while (g_is_adj_status != 2)
|
|
|
|
while (dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
osDelay(2000);
|
|
|
|
osDelay(2000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DBG(DBG_M_RS485_DEBUG, "capture end...\r\n");
|
|
|
|
DBG(DBG_M_RS485_DEBUG, "capture end...\r\n");
|
|
|
|
HAL_E_RETURN(_dau_base_auto(bitmap_new, index));
|
|
|
|
_debug_adj_power_cal();
|
|
|
|
g_is_adj_status = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1062,54 +1209,8 @@ static HAL_StatusTypeDef _debug_adj_autoEx(uint8_t bitmap, uint16_t elec, uint8_
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 自动校准报文处理. */
|
|
|
|
|
|
|
|
void _debug_pkt_adj_auto(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
debug_adj_set *data = (debug_adj_set*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *rt = (uint32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
HAL_StatusTypeDef rv = HAL_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 开始自动校准. */
|
|
|
|
|
|
|
|
//data->ch_selecet = 1;
|
|
|
|
|
|
|
|
rv = _debug_adj_auto(data->ch_selecet);
|
|
|
|
|
|
|
|
if (rv == HAL_OK)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
/* 完成后保存配置. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 电池电压自动校准. */
|
|
|
|
|
|
|
|
if (data->is_voltage_sel)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ADC_vbat_auto(dev_config.vin);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
rv = HAL_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
*rt = rv;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + 4, DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void _debug_pkt_adj_autoEx(uint16_t elec, uint8_t index)
|
|
|
|
void _debug_pkt_adj_autoEx(uint16_t elec, uint8_t index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
@ -1117,15 +1218,15 @@ void _debug_pkt_adj_autoEx(uint16_t elec, uint8_t index)
|
|
|
|
uint32_t *rt = (uint32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *rt = (uint32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
HAL_StatusTypeDef rv = HAL_ERROR;
|
|
|
|
HAL_StatusTypeDef rv = HAL_ERROR;
|
|
|
|
|
|
|
|
|
|
|
|
if (IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ))
|
|
|
|
if (IS_MONITOR_BIT_SET(dev_config.flag, DEV_FLAG_ADJ))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 开始自动校准. */
|
|
|
|
/* 开始自动校准. */
|
|
|
|
data->ch_selecet = 1;
|
|
|
|
data->ch_selecet = 1;
|
|
|
|
if (data->ch_selecet == 1)
|
|
|
|
if (data->ch_selecet == 1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
HAL_GPIO_WritePin(LED_RUN_GPIO_Port, LED_RUN_Pin, GPIO_PIN_SET);
|
|
|
|
HAL_GPIO_WritePin(LED_RUN_GPIO_Port, LED_RUN_Pin, GPIO_PIN_SET);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rv = _debug_adj_autoEx(data->ch_selecet, elec, index);
|
|
|
|
rv = _debug_adj_autoEx(data->ch_selecet, elec, index);
|
|
|
|
if (rv == HAL_OK)
|
|
|
|
if (rv == HAL_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1136,7 +1237,6 @@ void _debug_pkt_adj_autoEx(uint16_t elec, uint8_t index)
|
|
|
|
/* 电池电压自动校准. */
|
|
|
|
/* 电池电压自动校准. */
|
|
|
|
if (data->is_voltage_sel)
|
|
|
|
if (data->is_voltage_sel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ADC_vbat_auto(dev_config.vin);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -1156,8 +1256,8 @@ void _debug_pkt_adj_autoEx(uint16_t elec, uint8_t index)
|
|
|
|
//_debug_pkt_send(head->len + 4, 20);
|
|
|
|
//_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 实时数据获取报文处理. */
|
|
|
|
/* 实时数据获取报文处理. */
|
|
|
|
static void _debug_pkt_data_get(void)
|
|
|
|
static void _debug_pkt_data_get(void)
|
|
|
@ -1174,12 +1274,18 @@ static void _debug_pkt_data_get(void)
|
|
|
|
data->temperature = ADC_ctrl.ADCi_temp;
|
|
|
|
data->temperature = ADC_ctrl.ADCi_temp;
|
|
|
|
data->vbat = ADC_ctrl.ADCi_vbat;
|
|
|
|
data->vbat = ADC_ctrl.ADCi_vbat;
|
|
|
|
data->vin = ADC_ctrl.ADCi_vin;
|
|
|
|
data->vin = ADC_ctrl.ADCi_vin;
|
|
|
|
data->vsc = ADC_ctrl.ADCi_vsc;
|
|
|
|
|
|
|
|
data->CSQ = wl_ctrl.CSQ;
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//data->elec[i] = ADC_ctrl.ADC_elec[i];
|
|
|
|
data->elec[i] = dau_ctrl.reg_elec[i];
|
|
|
|
|
|
|
|
data->elec_fault[i] = dau_ctrl.fault_elec[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_DEFECT_MAX; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->elec_defect_max[i] = dau_ctrl.reg_defect_max[i];
|
|
|
|
|
|
|
|
data->elec_fault_max[i] = dau_ctrl.fault_max[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
data->fault_utc = dau_ctrl.fault_utc;
|
|
|
|
|
|
|
|
data->fault_ns = dau_ctrl.fault_ns;
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1297,32 +1403,22 @@ static void _debug_pkt_wave_get(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
static void _debug_pkt_dev_state_get(void)
|
|
|
|
static void _debug_pkt_wave_col(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
dev_state_t *data = (dev_state_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
st_data.wave_time = 0;
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_state_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
st_data.wave_start = TRUE;
|
|
|
|
|
|
|
|
st_data.wave_up_start = TRUE;
|
|
|
|
|
|
|
|
st_data.wave_index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/* 装填数据. */
|
|
|
|
flash_log_write(FLASH_LOG_TYPE_INFO, "Force wavc collect system reset!\r\n");
|
|
|
|
data->is_adc_up = ADC_ctrl.up_finish;
|
|
|
|
common_sys_set(COM_SYS_RESET, (void*)&reset_delay);
|
|
|
|
data->adci_cnt = ADC_ctrl.ADCi_err_cnt;
|
|
|
|
|
|
|
|
data->adci_state = ADC_ctrl.ADCi_state;
|
|
|
|
/* 封装报文头. */
|
|
|
|
data->adc_cnt = ADC_ctrl.ADC_err_cnt;
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
data->adc_state = ADC_ctrl.ADC_state;
|
|
|
|
|
|
|
|
data->is_adc_thr = ADC_ctrl.is_ADC_thr;
|
|
|
|
|
|
|
|
data->wave_time = st_data.wave_time;
|
|
|
|
|
|
|
|
data->wave_start = st_data.wave_start;
|
|
|
|
|
|
|
|
data->wave_up_start = st_data.wave_up_start;
|
|
|
|
|
|
|
|
data->wave_idx = st_data.wave_index;
|
|
|
|
|
|
|
|
data->wave_force = st_data.wave_force;
|
|
|
|
|
|
|
|
data->wl_state = wl_ctrl.state;
|
|
|
|
|
|
|
|
data->wl_cnt = wl_ctrl.send_cnt;
|
|
|
|
|
|
|
|
data->force_sleep_up = st_data.force_sleep_up;
|
|
|
|
|
|
|
|
data->is_bat_charge = HAL_GPIO_ReadPin(BAT_CHECK_GPIO_Port, BAT_CHECK_Pin);
|
|
|
|
|
|
|
|
data->sys_time = HAL_GetTick() / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1335,19 +1431,32 @@ static void _debug_pkt_dev_state_get(void)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
static void _debug_pkt_wave_col(void)
|
|
|
|
static void _debug_pkt_adj_defect_zero(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_defect_zero_t *data = (dev_adj_defect_zero_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t reset_delay = 2;
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
st_data.wave_time = 0;
|
|
|
|
/* 解析数据. */
|
|
|
|
st_data.wave_start = TRUE;
|
|
|
|
memcpy(&debug_adj_defect, data, sizeof(dev_adj_defect_zero_t));
|
|
|
|
st_data.wave_up_start = TRUE;
|
|
|
|
|
|
|
|
st_data.wave_index = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
flash_log_write(FLASH_LOG_TYPE_INFO, "Force wavc collect system reset!\r\n");
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_DEFECT_ZERO;
|
|
|
|
common_sys_set(COM_SYS_RESET, (void*)&reset_delay);
|
|
|
|
while(dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_DEFECT_CNT; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!IS_MONITOR_BIT_SET(debug_adj_defect.bitmap, i))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dev_config.defect_base[i] = dau_ctrl.reg_port_state.DAVR[i];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
@ -1362,14 +1471,39 @@ static void _debug_pkt_wave_col(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 校准参数设置报文处理. */
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
static void _debug_pkt_wave_cal(void)
|
|
|
|
static void _debug_pkt_adj_defect(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_defect_cfg_t *data = (dev_adj_defect_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
uint32_t temp = 0;
|
|
|
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_DEFECT;
|
|
|
|
|
|
|
|
while(dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_DEFECT_CNT; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!IS_MONITOR_BIT_SET(debug_adj_defect.bitmap, i))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
temp = dau_ctrl.reg_port_state.DAVR[i] - dev_config.defect_base[i];
|
|
|
|
|
|
|
|
temp = 3276;
|
|
|
|
|
|
|
|
dev_config.defect_adj[i] = debug_adj_defect.defect_elec * 32768 / temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_adj_defect_cfg_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 配置参数. */
|
|
|
|
|
|
|
|
memcpy(data->defect_base, dev_config.defect_base, sizeof(dev_adj_defect_cfg_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1377,6 +1511,9 @@ static void _debug_pkt_wave_cal(void)
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
/* 发送报文 */
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存参数. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1544,7 +1681,7 @@ static HAL_StatusTypeDef _debug_adj_manual(uint8_t bitmap, uint8_t index)
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
for(i = 0; i < DAU_PORT_POWER_CNT; i++)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
/* 过滤不需要的通道. */
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i) || 0 == dev_config.ADC_ratio[i])
|
|
|
|
if (!IS_MONITOR_BIT_SET(bitmap, i))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1565,7 +1702,7 @@ static HAL_StatusTypeDef _debug_adj_manual(uint8_t bitmap, uint8_t index)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
HAL_E_RETURN(_dau_base_auto(bitmap, index + 1));
|
|
|
|
_debug_adj_power_cal();
|
|
|
|
|
|
|
|
|
|
|
|
return HAL_OK;
|
|
|
|
return HAL_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1608,14 +1745,25 @@ static void _debug_pkt_adj_manual(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 南网配置获取报文处理. */
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
static void _debug_pkt_csg_config_get(void)
|
|
|
|
static void _debug_pkt_adj_fault_zero(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_fault_zero_t *data = (dev_adj_fault_zero_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 解析数据. */
|
|
|
|
|
|
|
|
memcpy(&debug_adj_fault, data, sizeof(dev_adj_fault_zero_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_FAULT_ZERO;
|
|
|
|
|
|
|
|
while(dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(debug_csg_config_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1627,14 +1775,43 @@ static void _debug_pkt_csg_config_get(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 修改南网配置报文处理. */
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
static void _debug_pkt_csg_config_set(void)
|
|
|
|
static void _debug_pkt_adj_fault(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_fault_cfg_t *data = (dev_adj_fault_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
uint8_t i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dau_adj_state = DAU_ADJ_STATE_FAULT;
|
|
|
|
|
|
|
|
while(dau_adj_state != DAU_ADJ_STATE_NONE)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
osDelay(1000);
|
|
|
|
|
|
|
|
common_watchdog_set(COM_WDG_CLI);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(i = 0; i < DAU_PORT_FAULT_CNT; i++)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->fault_base[i] = dev_config.fault_base[i];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!IS_MONITOR_BIT_SET(debug_adj_fault.bitmap, i))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->fault_adj[i] = dev_config.fault_adj[i];
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!((dau_ctrl.reg_global.GFTR & DAU_GFTR_FAULT_Msk) >> DAU_GFTR_FAULT_Pos))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
data->fault_adj[i] = 0;
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//data->fault_adj[i] = abs_cal_u(dau_ctrl.reg_port_state.FMAX[i] - dev_config.fault_base[i]);
|
|
|
|
|
|
|
|
data->fault_adj[i] = 13107;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_adj_fault_cfg_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1650,14 +1827,48 @@ static void _debug_pkt_csg_config_set(void)
|
|
|
|
static void _debug_pkt_update_fpga_result()
|
|
|
|
static void _debug_pkt_update_fpga_result()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
int32_t *res = (int32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
int32_t *res = (int32_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
/* 封装报文头. */
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(int32_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(int32_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
head->cmd_type = DEBUG_CT_PRV_REPLY;
|
|
|
|
head->cmd_type = DEBUG_CT_PRV_REPLY;
|
|
|
|
head->cmd = DEBUG_PRV_UPDATE_RT;
|
|
|
|
head->cmd = DEBUG_PRV_UPDATE_RT;
|
|
|
|
*res = (dau_ctrl.update_rt != DAU_UPD_OK);
|
|
|
|
*res = (dau_ctrl.update_rt != DAU_UPD_OK);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 自动校准报文处理. */
|
|
|
|
|
|
|
|
void _debug_pkt_adj_auto(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_adj_power_t *data = (dev_adj_power_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
dev_adj_power_cfg_t *cfg = (dev_adj_power_cfg_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 解析数据. */
|
|
|
|
|
|
|
|
memcpy(&debug_adj_power, data, sizeof(dev_adj_power_t));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 组装数据 */
|
|
|
|
|
|
|
|
//cfg->return_value = _debug_adj_auto(debug_adj_power.bitmap);
|
|
|
|
|
|
|
|
cfg->return_value = 0;
|
|
|
|
|
|
|
|
if (debug_adj_power.is_voltage_adj)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
ADC_vbat_auto(5000);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
memcpy(cfg->power_adj, dev_config.power_adj, 32);
|
|
|
|
|
|
|
|
cfg->vin_adj = dev_config.vin_adj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_adj_power_cfg_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
/* 计算校验和. */
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
@ -1665,10 +1876,50 @@ static void _debug_pkt_update_fpga_result()
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
/* 发送报文 */
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 保存参数. */
|
|
|
|
|
|
|
|
common_sys_set(COM_SYS_SAVE_CONFIG, 0);
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 设备状态获取报文处理. */
|
|
|
|
|
|
|
|
static void _debug_pkt_dev_state_get(void)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
proto_head_t *head = (proto_head_t*)debug_buf.buf;
|
|
|
|
|
|
|
|
dev_state_t *data = (dev_state_t*)(debug_buf.buf + sizeof(proto_head_t));
|
|
|
|
|
|
|
|
uint32_t *crc = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 封装报文头. */
|
|
|
|
|
|
|
|
_debug_pkt_head_init(sizeof(proto_head_t) + sizeof(dev_state_t), DEBUG_CT_PRV_REPLY);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 装填数据. */
|
|
|
|
|
|
|
|
data->is_adc_up = ADC_ctrl.up_finish;
|
|
|
|
|
|
|
|
data->adci_cnt = ADC_ctrl.ADCi_err_cnt;
|
|
|
|
|
|
|
|
data->adci_state = ADC_ctrl.ADCi_state;
|
|
|
|
|
|
|
|
data->adc_cnt = ADC_ctrl.ADC_err_cnt;
|
|
|
|
|
|
|
|
data->adc_state = ADC_ctrl.ADC_state;
|
|
|
|
|
|
|
|
data->is_adc_thr = ADC_ctrl.is_ADC_thr;
|
|
|
|
|
|
|
|
data->wave_time = st_data.wave_time;
|
|
|
|
|
|
|
|
data->wave_start = st_data.wave_start;
|
|
|
|
|
|
|
|
data->wave_up_start = st_data.wave_up_start;
|
|
|
|
|
|
|
|
data->wave_idx = st_data.wave_index;
|
|
|
|
|
|
|
|
data->wave_force = st_data.wave_force;
|
|
|
|
|
|
|
|
data->wl_state = wl_ctrl.state;
|
|
|
|
|
|
|
|
data->wl_cnt = wl_ctrl.send_cnt;
|
|
|
|
|
|
|
|
data->force_sleep_up = st_data.force_sleep_up;
|
|
|
|
|
|
|
|
data->is_bat_charge = HAL_GPIO_ReadPin(BAT_CHECK_GPIO_Port, BAT_CHECK_Pin);
|
|
|
|
|
|
|
|
data->sys_time = HAL_GetTick() / 1000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 计算校验和. */
|
|
|
|
|
|
|
|
crc = (uint32_t*)(debug_buf.buf + head->len);
|
|
|
|
|
|
|
|
*crc = crc32(debug_buf.buf, head->len);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* 发送报文 */
|
|
|
|
|
|
|
|
_debug_pkt_send(head->len + 4, 20);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 收包报文处理. */
|
|
|
|
/* 收包报文处理. */
|
|
|
|
static void _debug_pkt_process(void)
|
|
|
|
static void _debug_pkt_process(void)
|
|
|
@ -1729,23 +1980,26 @@ static void _debug_pkt_process(void)
|
|
|
|
case DEBUG_PRV_DEFECT:
|
|
|
|
case DEBUG_PRV_DEFECT:
|
|
|
|
_debug_pkt_wave_get();
|
|
|
|
_debug_pkt_wave_get();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_INFO:
|
|
|
|
case DEBUG_PRV_ADJ_GET:
|
|
|
|
_debug_pkt_adj_get();
|
|
|
|
_debug_pkt_adj_get();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_INFO_SET:
|
|
|
|
case DEBUG_PRV_ADJ_SET_POWER:
|
|
|
|
_debug_pkt_adj_set();
|
|
|
|
_debug_pkt_adj_set_power();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_ADJ_AUTO:
|
|
|
|
case DEBUG_PRV_ADJ_SET_DEFECT:
|
|
|
|
_debug_pkt_adj_auto();
|
|
|
|
_debug_pkt_adj_set_defect();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_DEV_STATE:
|
|
|
|
case DEBUG_PRV_ADJ_SET_FAULT:
|
|
|
|
_debug_pkt_dev_state_get();
|
|
|
|
_debug_pkt_adj_set_fault();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_WAVE_COL:
|
|
|
|
case DEBUG_PRV_WAVE_COL:
|
|
|
|
_debug_pkt_wave_col();
|
|
|
|
_debug_pkt_wave_col();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_WAVE_CAL:
|
|
|
|
case DEBUG_PRV_ADJ_DECFECT_ZERO:
|
|
|
|
_debug_pkt_wave_cal();
|
|
|
|
_debug_pkt_adj_defect_zero();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEBUG_PRV_ADJ_DECFECT:
|
|
|
|
|
|
|
|
_debug_pkt_adj_defect();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_LOG:
|
|
|
|
case DEBUG_PRV_LOG:
|
|
|
|
_debug_pkt_log_get();
|
|
|
|
_debug_pkt_log_get();
|
|
|
@ -1756,15 +2010,21 @@ static void _debug_pkt_process(void)
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
case DEBUG_PRV_ADJ_MANUAL:
|
|
|
|
_debug_pkt_adj_manual();
|
|
|
|
_debug_pkt_adj_manual();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_CSG_CONFIG:
|
|
|
|
case DEBUG_PRV_ADJ_FAULT_ZERO:
|
|
|
|
_debug_pkt_csg_config_get();
|
|
|
|
_debug_pkt_adj_fault_zero();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_CSG_CONFIG_SET:
|
|
|
|
case DEBUG_PRV_ADJ_FAULT:
|
|
|
|
_debug_pkt_csg_config_set();
|
|
|
|
_debug_pkt_adj_fault();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case DEBUG_PRV_UPDATE_FPGA:
|
|
|
|
case DEBUG_PRV_UPDATE_FPGA:
|
|
|
|
_debug_pkt_update_fpga();
|
|
|
|
_debug_pkt_update_fpga();
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEBUG_PRV_ADJ_AUTO:
|
|
|
|
|
|
|
|
_debug_pkt_adj_auto();
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DEBUG_PRV_DEV_STATE:
|
|
|
|
|
|
|
|
_debug_pkt_dev_state_get();
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1774,7 +2034,7 @@ static void _debug_pkt_process(void)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* Interface functions -------------------------------------------------------*/
|
|
|
|
/* Interface functions -------------------------------------------------------*/
|
|
|
|
/* RS485 传感器主任务循环. */
|
|
|
|
/* RS485 传感器主任务循环. */
|
|
|
|
void debug_start(void)
|
|
|
|
void debug_start(void)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1788,7 +2048,7 @@ void debug_start(void)
|
|
|
|
if (dau_ctrl.update_rt == DAU_UPD_OK)
|
|
|
|
if (dau_ctrl.update_rt == DAU_UPD_OK)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
_debug_pkt_update_fpga_result();
|
|
|
|
_debug_pkt_update_fpga_result();
|
|
|
|
dau_ctrl.update_rt = DAU_UPD_NONE;
|
|
|
|
dau_ctrl.update_rt = DAU_UPD_NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 开启串口空闲中断 DMA 收包. 注意这里会收到空闲中断, DMA 收一半中断, 全收中断, 注意中断处理. */
|
|
|
|
/* 开启串口空闲中断 DMA 收包. 注意这里会收到空闲中断, DMA 收一半中断, 全收中断, 注意中断处理. */
|
|
|
@ -1847,7 +2107,7 @@ void debug_start(void)
|
|
|
|
if (dbg_stat_get(DBG_M_RS485_DEBUG))
|
|
|
|
if (dbg_stat_get(DBG_M_RS485_DEBUG))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
buf_print(debug_buf.buf, 28);
|
|
|
|
buf_print(debug_buf.buf, 28);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* 报文处理. */
|
|
|
|
/* 报文处理. */
|
|
|
|
_debug_pkt_process();
|
|
|
|
_debug_pkt_process();
|
|
|
|