Browse Source

update

master
zhaohe 1 year ago
parent
commit
b57f02a9c1
  1. 16
      src/xsync_v2.cpp
  2. 2
      src/xsync_v2_sig_type.cpp

16
src/xsync_v2.cpp

@ -4,12 +4,15 @@
#include <map>
#include "../src/logger.hpp"
// #include "../src/logger.hpp"
#include "xsync_errcode.hpp"
#include "xsync_regs.hpp"
#include "xsync_utils.hpp"
#include "xsync_v2_sig_type.hpp"
#define VERSION(main, sub, fix) (main << 16 | sub << 8 | fix << 0)
#define PC_VERSION VERSION(3, 3, 0)
#define TAG "XSYNC"
using namespace xsync;
@ -106,6 +109,7 @@ class Xsync : public IXsync {
xsync_on_timecode_msg_t m_on_timecode_msg_cb = nullptr;
xsync_on_record_sig_change_msg_t m_on_record_sig_change_msg_cb = nullptr;
xsync_on_connect_state_change_t m_on_connect_state_change_cb = nullptr;
I_XSUDP::onMessage_t m_on_timecode_raw_msg_cb = nullptr;
int txpacket_index = 0;
uint8_t m_xync_cmd_rxdata_cache[2560];
@ -201,6 +205,7 @@ class Xsync : public IXsync {
XsyncTimecode_t timecode = timecode64ToXsyncTimeCode(tc64);
if (m_on_timecode_msg_cb) m_on_timecode_msg_cb(&timecode);
if (m_on_timecode_raw_msg_cb) m_on_timecode_raw_msg_cb(from, data, length);
} else if (packet->eventid == kxsync_work_state_report_event) {
// 信号发生器状态改变
Timecode64_t tc64 = {0};
@ -359,6 +364,7 @@ class Xsync : public IXsync {
virtual void registerOnCameraSyncMsgCallback(xsync_on_camera_sync_msg_t cb) override { m_on_camera_sync_msg_cb = cb; }
virtual void registerOnRecordSigChangeMsgCallback(xsync_on_record_sig_change_msg_t cb) override { m_on_record_sig_change_msg_cb = cb; }
virtual void registerOnConnectStateChangeCallback(xsync_on_connect_state_change_t cb) override { m_on_connect_state_change_cb = cb; };
virtual void registerOnTimecodeRawMsgCallback(I_XSUDP::onMessage_t onraw) override { m_on_timecode_raw_msg_cb = onraw; }
virtual xs_error_code_t generatorNewMac() override;
virtual xs_error_code_t factoryReset() override;
@ -497,7 +503,7 @@ class Xsync : public IXsync {
source == SIGNAL_BUSINESS_RECORD_SIG) {
DO_XSYNC(reg_write(reg::kreg_ttlout1_signal_process_mode + (index - 1) * 16, 3, 10)); // 转发模式
} else {
ZLOGI(TAG, "TTLOutputModule_setSrcSigType %d %d", index, source);
// ZLOGI(TAG, "TTLOutputModule_setSrcSigType %d %d", index, source);
DO_XSYNC(reg_write(reg::kreg_ttlout1_signal_process_mode + (index - 1) * 16, 2, 10)); // 分频倍频模式
}
REG_WRITE(reg::kreg_ttlout1_input_signal_select + (index - 1) * 16, source);
@ -539,6 +545,7 @@ class Xsync : public IXsync {
if (index < 1 || index > 4) return kxs_ec_param_error;
DO_XSYNC(reg_write(reg::kreg_ttlout1_pllout_polarity_ctrl + (index - 1) * 16, polarity, 10));
DO_XSYNC(reg_write(reg::kreg_ttlout1_forward_mode_polarity_ctrl + (index - 1) * 16, polarity, 10));
return kxs_ec_success;
}
virtual xs_error_code_t TTLOutputModule_getPolarity(int index, uint32_t &polarity) override {
if (index < 1 || index > 4) return kxs_ec_param_error;
@ -779,7 +786,7 @@ xs_error_code_t Xsync::readSn(string &sn) {
DO_XSYNC(reg_read(reg::ksn_id2, sn2));
char buf[128] = {0};
sprintf(buf, "%02d%02d%04d", sn0, sn1, sn2);
snprintf(buf, 128, "%02d%02d%04d", sn0, sn1, sn2);
sn = buf;
return kxs_ec_success;
@ -793,7 +800,7 @@ xs_error_code_t Xsync::readMac(string &mac) {
DO_XSYNC(reg_read(reg::kmac1, mac1));
char buf[128] = {0};
sprintf(buf, "%02x-%02x-%02x-%02x-%02x-%02x", (mac0 >> 0) & 0xff, (mac0 >> 8) & 0xff, (mac0 >> 16) & 0xff, (mac0 >> 24) & 0xff, (mac1 >> 0) & 0xff, (mac1 >> 8) & 0xff);
snprintf(buf, 128, "%02x-%02x-%02x-%02x-%02x-%02x", (mac0 >> 0) & 0xff, (mac0 >> 8) & 0xff, (mac0 >> 16) & 0xff, (mac0 >> 24) & 0xff, (mac1 >> 0) & 0xff, (mac1 >> 8) & 0xff);
mac = buf;
return kxs_ec_success;
@ -1055,3 +1062,4 @@ namespace xsync {
void XsyncInit(I_XSUDPFactory *xsync_udp_factory) { g_xsync_udp_factory = xsync_udp_factory; }
IXsync *XsyncIns() { return &Xsync::Ins(); }
} // namespace xsync
// #include "pch.h"

2
src/xsync_v2_sig_type.cpp

@ -37,7 +37,7 @@ list<string> TimecodeFormatStrSet() {
string XsyncTimecodeToStr(XsyncTimecode_t timecode) {
char buf[32] = {0};
sprintf(buf, "%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame);
snprintf(buf, 32,"%02d:%02d:%02d:%02d", timecode.hour, timecode.minute, timecode.second, timecode.frame);
return string(buf);
}
XsyncTimecode_t Str2XsyncTimecode(string timecode) {

Loading…
Cancel
Save