Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TwinCAT/BSD for OS Version #35

Merged
merged 7 commits into from
Dec 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,10 @@ pub fn get_info(target: (&str, u16)) -> Result<SysInfo> {
(0, 0, 0)
};

// Parse OS version. This is a Windows OSVERSIONINFO structure, which
// Parse OS version. If Windows OSVERSIONINFO structure, it will
// consists of major/minor/build versions, the platform, and a "service
// pack" string, coded as UTF-16. It is not known how the data looks on
// non-Windows devices, but hopefully the format is kept the same.
// pack" string, coded as UTF-16.
// If TwinCAT/BSD currently it will give major minor and build that is displayed
let os_version = if let Some(mut bytes) = reply.get_bytes(Tag::OSVersion) {
if bytes.len() >= 22 {
// Size of the structure (redundant).
Expand All @@ -272,13 +272,17 @@ pub fn get_info(target: (&str, u16)) -> Result<SysInfo> {
let minor = bytes.read_u32::<LE>().expect("size");
let build = bytes.read_u32::<LE>().expect("size");
let platform = match bytes.read_u32::<LE>().expect("size") {
0 => "TwinCAT/BSD",
1 => "TC/RTOS",
2 => "Windows NT",
3 => "Windows CE",
_ => "Unknown platform",
};
let string = if platform == "TC/RTOS" {
bytes.iter().take_while(|&&b| b != 0).map(|&b| b as char).collect()
} else if platform == "TwinCAT/BSD" {
// The following data is TwinCAT/BSD in bytes. But we know the platform from 0.
"".into()
} else {
iter::from_fn(|| bytes.read_u16::<LE>().ok())
.take_while(|&ch| ch != 0)
Expand Down
Loading