Merge pull request #111 from kevans91/fwver

Report firmware version after login
This commit is contained in:
George Hilliard authored and GitHub committed 2020-12-20 20:18:38 -06:00
commit 055d731fec
5 files changed
+78 -1

No files matched your search

+1
View File
@@ -5,6 +5,7 @@ pub(super) const MAGIC_HEADER: u32 = 0xabcdef0;
pub const MSG_ID_LOGIN: u32 = 1;
pub const MSG_ID_VIDEO: u32 = 3;
pub const MSG_ID_VERSION: u32 = 80;
pub const MSG_ID_PING: u32 = 93;
pub const MSG_ID_GET_GENERAL: u32 = 104;
pub const MSG_ID_SET_GENERAL: u32 = 105;
+13
View File
@@ -35,6 +35,8 @@ pub struct BcXml {
pub login_net: Option<LoginNet>,
#[yaserde(rename = "DeviceInfo")]
pub device_info: Option<DeviceInfo>,
#[yaserde(rename = "VersionInfo")]
pub version_info: Option<VersionInfo>,
#[yaserde(rename = "Preview")]
pub preview: Option<Preview>,
#[yaserde(rename = "SystemGeneral")]
@@ -103,6 +105,17 @@ pub struct DeviceInfo {
pub resolution: Resolution,
}
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct VersionInfo {
pub name: String,
pub serialNumber: String,
pub buildDay: String,
pub hardwareVersion: String,
pub cfgVersion: String,
pub firmwareVersion: String,
pub detail: String,
}
#[derive(PartialEq, Eq, Default, Debug, YaDeserialize, YaSerialize)]
pub struct Resolution {
#[yaserde(rename = "resolutionName")]
+45
View File
@@ -250,6 +250,51 @@ impl BcCamera {
Ok(())
}
pub fn version(&self) -> Result<VersionInfo> {
let connection = self
.connection
.as_ref()
.expect("Must be connected to get version info");
let sub_version = connection.subscribe(MSG_ID_VERSION)?;
let version = Bc {
meta: BcMeta {
msg_id: MSG_ID_VERSION,
client_idx: 0,
encrypted: true,
class: 0x6414,
},
body: BcBody::ModernMsg(ModernMsg {
..Default::default()
}),
};
sub_version.send(version)?;
let modern_reply = sub_version.rx.recv_timeout(RX_TIMEOUT)?;
let version_info;
match modern_reply.body {
BcBody::ModernMsg(ModernMsg {
xml:
Some(BcXml {
version_info: Some(info),
..
}),
..
}) => {
version_info = info;
}
_ => {
return Err(Error::UnintelligibleReply {
reply: modern_reply,
why: "Expected a VersionInfo message",
})
}
}
Ok(version_info)
}
pub fn ping(&self) -> Result<()> {
let connection = self.connection.as_ref().expect("Must be connected to ping");
let sub_ping = connection.subscribe(MSG_ID_PING)?;
+1 -1
View File
@@ -225,7 +225,7 @@ pub fn adpcm_to_pcm(bytes: &[u8]) -> Result<Vec<u8>, Error> {
// Some formats e.g. OKI are not in the full PCM range of values
// To convert we must scale it to the i16 range
// We also cast to i16 at this point ready for the conversion to u8 bytes of the output
let scaled_sample = (sample as i32 * (i16::MAX as i32)
let scaled_sample = (sample as i32 * (std::i16::MAX as i32)
/ (context.max_sample_size - 1) as i32)
as i16;
+18
View File
@@ -260,5 +260,23 @@ fn do_camera_management(
);
}
}
use neolink::bc::xml::VersionInfo;
if let Ok(VersionInfo {
firmwareVersion: firmware_version,
..
}) = camera.version()
{
info!(
"{}: Camera reports firmware version {}",
camera_config.name, firmware_version
);
} else {
info!(
"{}: Could not fetch version information",
camera_config.name
);
}
Ok(())
}