From 1df9a2875669feac159893c32dcd44262391926d Mon Sep 17 00:00:00 2001 From: TinyO Date: Sat, 12 Oct 2019 14:53:45 +0800 Subject: [PATCH] fix(*): isp version use type+version tostring(). --- include/mynteye/device/types.h | 18 ++++++++++++++++-- src/mynteye/device/channel/file_channel.cc | 6 +++--- src/mynteye/device/types.cc | 17 +++++++++++++++++ 3 files changed, 36 insertions(+), 5 deletions(-) diff --git a/include/mynteye/device/types.h b/include/mynteye/device/types.h index 7e156b0..93567d2 100644 --- a/include/mynteye/device/types.h +++ b/include/mynteye/device/types.h @@ -103,7 +103,7 @@ class MYNTEYE_API Version { return (from <= *this) && (*this <= until); } - std::string to_string() const; + virtual std::string to_string() const; static std::vector split(const std::string &s); static value_t parse_part(const std::string &name, size_t part); @@ -112,6 +112,20 @@ class MYNTEYE_API Version { MYNTEYE_PROPERTY(value_t, minor) }; +/** + * ISPVersion version. + */ +class MYNTEYE_API ISPVersion : public Version { + public: + ISPVersion() = default; + ISPVersion(value_t major, value_t minor) + : Version(major, minor) {} + explicit ISPVersion(const std::string &name, value_t flag = 0) + : Version(parse_part(name, 0), parse_part(name, 1)) {} + + std::string to_string() const override; +}; + /** * Hardware version. */ @@ -163,7 +177,7 @@ struct MYNTEYE_API DeviceInfo { Type imu_type; std::uint16_t nominal_baseline; Version auxiliary_chip_version; - Version isp_version; + ISPVersion isp_version; }; #undef MYNTEYE_PROPERTY diff --git a/src/mynteye/device/channel/file_channel.cc b/src/mynteye/device/channel/file_channel.cc index 00193a3..b8831b8 100644 --- a/src/mynteye/device/channel/file_channel.cc +++ b/src/mynteye/device/channel/file_channel.cc @@ -116,7 +116,7 @@ std::size_t DeviceInfoParser::GetFromData( info->isp_version.set_minor(data[i + 1]); i += 2; // firmware_version, 2 - info->firmware_version.set_major(data[i]); + info->firmware_version.set_major(data[i + 1] ? data[i] : 0); info->firmware_version.set_minor(data[i + 1]); i += 2; // hardware_version, 3 @@ -158,8 +158,8 @@ std::size_t DeviceInfoParser::GetFromData( info->auxiliary_chip_version.set_minor(data[i + 1]); i += 2; // isp_version, 2 - info->isp_version.set_major(data[i]); - info->isp_version.set_minor(data[i + 1]); + info->isp_version.set_major(0); + info->isp_version.set_minor(data[i]); i += 2; } else { info->auxiliary_chip_version.set_major(0); diff --git a/src/mynteye/device/types.cc b/src/mynteye/device/types.cc index 36855d4..489cd66 100644 --- a/src/mynteye/device/types.cc +++ b/src/mynteye/device/types.cc @@ -59,4 +59,21 @@ Type::value_t Type::parse_part( return std::stoi(name.substr(pos, count), 0, 16); } +std::string ISPVersion::to_string() const { + std::stringstream s; + if (major() == 0x01) { + s << "S2000-"; + } else if (major() == 0x02) { + s << "S2110-"; + } else if (major() == 0x03) { + s << "S210A-"; + } else if (major() == 0x04) { + s << "S2X0C-"; + } else if (major() == 0x05) { + s << "S200B-"; + } + s << static_cast(minor()); + return s.str(); +} + MYNTEYE_END_NAMESPACE