-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added software module with basic methods. A lot of work still to get this done.
- Loading branch information
Showing
5 changed files
with
102 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::path::PathBuf; | ||
|
||
use ni_syscfg::SessionConfig; | ||
|
||
fn main() { | ||
let session = SessionConfig::new() | ||
.target("192.168.10.102") | ||
.username("admin") | ||
.unwrap() | ||
.password("labview") | ||
.unwrap() | ||
.connect() | ||
.expect("Session failed"); | ||
session | ||
.get_software_image(&PathBuf::from( | ||
r"C:\Users\JamesMcNally\Documents\Delete\TestImage", | ||
)) | ||
.unwrap(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! Module for managing software on NI systems. | ||
//! | ||
use std::ffi::CString; | ||
use std::os::raw::c_char; | ||
use std::path::Path; | ||
|
||
use ni_syscfg_sys::{NISysCfgCreateSystemImageAsFolder, NISysCfgSetSystemImageFromFolder2}; | ||
|
||
use crate::error::{api_status, Result}; | ||
use crate::types::FfiBoolean; | ||
use crate::Session; | ||
|
||
type Uuid = String; | ||
|
||
struct ImageInfo { | ||
name: String, | ||
id: Uuid, | ||
} | ||
|
||
impl Session { | ||
pub fn get_software_image(&self, image: &Path) -> Result<()> { | ||
let handle = self.handle(); | ||
let path = CString::new(image.as_os_str().to_string_lossy().as_ref())?; | ||
let title = std::ptr::null(); | ||
let id = std::ptr::null(); | ||
let version = std::ptr::null(); | ||
let description = std::ptr::null(); | ||
|
||
unsafe { | ||
api_status(NISysCfgCreateSystemImageAsFolder( | ||
*handle, | ||
title, | ||
id, | ||
version, | ||
description, | ||
FfiBoolean::True as i32, | ||
path.as_ptr(), | ||
std::ptr::null(), | ||
0, | ||
std::ptr::null_mut(), | ||
FfiBoolean::False as i32, | ||
))?; | ||
} | ||
Ok(()) | ||
} | ||
pub fn set_software_image(&self, image: &Path) -> Result<()> { | ||
let handle = self.handle(); | ||
let path = CString::new(image.as_os_str().to_string_lossy().as_ref())?; | ||
|
||
unsafe { | ||
api_status(NISysCfgSetSystemImageFromFolder2( | ||
*handle, | ||
FfiBoolean::True as i32, | ||
path.as_ptr(), | ||
std::ptr::null(), | ||
0, | ||
std::ptr::null_mut(), | ||
FfiBoolean::False as i32, | ||
2, | ||
))?; | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
//! Wrappers for a few utility types. | ||
//! | ||
use ni_syscfg_sys::{NISysCfgBool_NISysCfgBoolFalse, NISysCfgBool_NISysCfgBoolTrue}; | ||
|
||
/// Wraps the constant values for true and false elements. | ||
#[repr(i32)] | ||
pub enum FfiBoolean { | ||
True = NISysCfgBool_NISysCfgBoolTrue, | ||
False = NISysCfgBool_NISysCfgBoolFalse, | ||
} |