You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
5.8 KiB
194 lines
5.8 KiB
#pragma once
|
|
#include <stdint.h>
|
|
|
|
/**
|
|
* @brief XSYNC协议端口
|
|
*/
|
|
#define IFLYTOP_XSYNC_SERVICE_XSYNC_PORT 19900 // xsync端端口
|
|
#define IFLYTOP_XSYNC_SERVICE_PC_PORT 19901 // pc 端端口
|
|
|
|
#define IFLYTOP_XSYNC_EVENT_REPORT_XSYNC_PORT 19902 // xsync端端口
|
|
#define IFLYTOP_XSYNC_EVENT_REPORT_PC_PORT 19903 // pc端端口
|
|
|
|
#define IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_XSYNC_PORT 13013 // xsync端端口
|
|
#define IFLYTOP_XSYNC_CAMERA_SYNC_PACKET_PC_PORT 13014 // pc端端口
|
|
|
|
/**
|
|
* @brief
|
|
* 协议说明
|
|
*
|
|
* kxsync_packet_type_reg_read:
|
|
* tx: regadd
|
|
* rx: ecode,regdata
|
|
*
|
|
* kxsync_packet_type_reg_write
|
|
* tx: regadd,regdata
|
|
* rx: ecode,regdata
|
|
*
|
|
* kxsync_packet_type_reg_read_regs
|
|
* tx: regstartadd,nreg
|
|
* rx: ecode,regdatas
|
|
*
|
|
*/
|
|
typedef enum {
|
|
kxsync_packet_type_none = 0,
|
|
kxsync_packet_type_reg_read = 1,
|
|
kxsync_packet_type_reg_write = 2,
|
|
kxsync_packet_type_reg_read_regs = 3,
|
|
kxsync_packet_type_timecode_report = 4,
|
|
} xsync_protocol_cmd_t;
|
|
|
|
typedef enum {
|
|
kxsync_packet_type_cmd = 0,
|
|
kxsync_packet_type_receipt = 1,
|
|
kxsync_packet_type_report = 2,
|
|
} xsync_protocol_packet_type_t;
|
|
|
|
typedef enum {
|
|
kxs_ec_success = 0,
|
|
kxs_ec_overtime = 1,
|
|
kxs_ec_socket_fail = 2,
|
|
kxs_ec_bind_fail = 3,
|
|
kxs_ec_send_fail = 4,
|
|
kxs_ec_receive_fail = 5,
|
|
kxs_ec_setsockopt_rx_timeout_fail = 6,
|
|
kxs_ec_lose_connect = 7,
|
|
kxs_ec_param_error = 8,
|
|
} xs_error_code_t;
|
|
|
|
static inline const char* xs_error_code_2_str(xs_error_code_t ecode) {
|
|
switch (ecode) {
|
|
case kxs_ec_success:
|
|
return "success";
|
|
case kxs_ec_overtime:
|
|
return "overtime";
|
|
case kxs_ec_socket_fail:
|
|
return "socket fail";
|
|
case kxs_ec_bind_fail:
|
|
return "bind fail";
|
|
case kxs_ec_send_fail:
|
|
return "send fail";
|
|
case kxs_ec_receive_fail:
|
|
return "receive fail";
|
|
case kxs_ec_setsockopt_rx_timeout_fail:
|
|
return "setsockopt rx timeout fail";
|
|
case kxs_ec_lose_connect:
|
|
return "lose connect";
|
|
case kxs_ec_param_error:
|
|
return "param error";
|
|
default:
|
|
return "unknown error";
|
|
}
|
|
}
|
|
|
|
#pragma pack(1)
|
|
|
|
typedef struct {
|
|
uint16_t type;
|
|
uint16_t index;
|
|
uint16_t cmd;
|
|
uint16_t ndata;
|
|
uint32_t data[]; // first is always checksum
|
|
} iflytop_xsync_packet_header_t;
|
|
|
|
typedef struct {
|
|
uint32_t eventid;
|
|
uint32_t data[];
|
|
} iflytop_xsync_event_report_packet_t;
|
|
|
|
typedef enum {
|
|
ktimecode_report_event = 0,
|
|
kxsync_work_state_report_event = 1,
|
|
kdevice_online_report_event = 2,
|
|
} iflytop_event_type_t;
|
|
|
|
#define XYSNC_REG_DEVICE_INFO_START_ADD 0
|
|
#define XYSNC_REG_STM32_CONFIG_START_ADD 16
|
|
#define XYSNC_REG_FPGA_REG_START 32
|
|
|
|
#define REG_ADD_OFF_STM32 (0x0000)
|
|
#define REG_ADD_OFF_FPGA_TEST (0x00020)
|
|
// 控制中心寄存器地址
|
|
#define REG_ADD_OFF_CONTROL_SENSOR (0x00030)
|
|
// 输入组件
|
|
#define REG_ADD_OFF_TTLIN1 (0x0100)
|
|
#define REG_ADD_OFF_TTLIN2 (0x0110)
|
|
#define REG_ADD_OFF_TTLIN3 (0x0120)
|
|
#define REG_ADD_OFF_TTLIN4 (0x0130)
|
|
#define REG_ADD_OFF_TIMECODE_IN (0x0140)
|
|
#define REG_ADD_OFF_GENLOCK_IN (0x0150)
|
|
// 输出组件
|
|
#define REG_ADD_OFF_TTLOUT1 (0x0200)
|
|
#define REG_ADD_OFF_TTLOUT2 (0x0210)
|
|
#define REG_ADD_OFF_TTLOUT3 (0x0220)
|
|
#define REG_ADD_OFF_TTLOUT4 (0x0230)
|
|
#define REG_ADD_OFF_TIMECODE_OUT (0x0240)
|
|
#define REG_ADD_OFF_GENLOCK_OUT (0x0250)
|
|
#define REG_ADD_OFF_STM32_IF (0x0260)
|
|
// 调试组件
|
|
#define REG_ADD_OFF_DEBUGER (0x0300)
|
|
|
|
typedef enum {
|
|
/**
|
|
* @brief
|
|
* REG 0(16) 设备信息基础寄存器
|
|
*/
|
|
kxsync_reg_software_version = 0,
|
|
kxsync_reg_manufacturer0 = 1,
|
|
kxsync_reg_manufacturer1 = 2,
|
|
kxsync_reg_product_type_id = 3,
|
|
kxsync_reg_sn_id0 = 4,
|
|
kxsync_reg_sn_id1 = 5,
|
|
kxsync_reg_sn_id2 = 6,
|
|
kxsync_reg_mac0 = 7,
|
|
kxsync_reg_mac1 = 8,
|
|
|
|
/**
|
|
* @brief
|
|
* REG 16(32) STM32配置寄存器0
|
|
*/
|
|
kxsync_reg_stm32_obtaining_ip_mode = XYSNC_REG_STM32_CONFIG_START_ADD + 0,
|
|
kxsync_reg_stm32_ip = XYSNC_REG_STM32_CONFIG_START_ADD + 1,
|
|
kxsync_reg_stm32_gw = XYSNC_REG_STM32_CONFIG_START_ADD + 2,
|
|
kxsync_reg_stm32_netmask = XYSNC_REG_STM32_CONFIG_START_ADD + 3,
|
|
kxsync_reg_stm32_config0 = XYSNC_REG_STM32_CONFIG_START_ADD + 4, // bit0: timecode report enable, bit1: camera sync report enable
|
|
kxsync_reg_stm32_camera_sync_signal_count = XYSNC_REG_STM32_CONFIG_START_ADD + 5, // 写任意数值之后清零
|
|
// kxsync_reg_stm32_camera_sync_signal_report_period = XYSNC_REG_STM32_CONFIG_START_ADD + 6, // 多少帧上报一次
|
|
|
|
kxsync_reg_stm32_action0 = XYSNC_REG_STM32_CONFIG_START_ADD + 14, // action reg
|
|
kxsync_reg_stm32_action_val0 = XYSNC_REG_STM32_CONFIG_START_ADD + 15, // action val reg
|
|
|
|
} xsync_reg_add_t;
|
|
|
|
#define KXSYNC_REG_STM32_CONFIG0_MASK_TIMECODE_REPORT_ENABLE 0x01
|
|
#define KXSYNC_REG_STM32_CONFIG0_MASK_CAMERA_SYNC_REPORT_ENABLE 0x02
|
|
|
|
typedef enum {
|
|
xsync_stm32_action_none, //
|
|
xsync_stm32_action_generator_new_mac, //
|
|
xsync_stm32_action_factory_reset, //
|
|
xsync_stm32_action_reboot, //
|
|
xsync_stm32_action_storage_cfg, //
|
|
} xsync_stm32_action_t;
|
|
|
|
typedef enum {
|
|
kxsync_device_type_none = 0,
|
|
kxsync_device_type_xsync = 1,
|
|
kxsync_device_type_puck_station = 2,
|
|
kxsync_device_type_encoder = 3,
|
|
} xsync_device_type_t;
|
|
|
|
typedef enum { obtaining_ip_mode_type_static = 0, obtaining_ip_mode_type_dhcp = 1, obtaining_ip_mode_type_lla = 2 } obtaining_ip_mode_t;
|
|
static inline const char* obtaining_ip_mode_to_string(obtaining_ip_mode_t mode) {
|
|
switch (mode) {
|
|
case obtaining_ip_mode_type_static:
|
|
return "static";
|
|
case obtaining_ip_mode_type_dhcp:
|
|
return "dhcp";
|
|
case obtaining_ip_mode_type_lla:
|
|
return "lla";
|
|
default:
|
|
return "unknown";
|
|
}
|
|
}
|
|
#pragma pack()
|