-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from avsaase/update-mavlink-0.12
Update to mavlink 0.12
- Loading branch information
Showing
5 changed files
with
18 additions
and
22 deletions.
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
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
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 |
---|---|---|
@@ -1,18 +1,14 @@ | ||
/// Extract String from mavlink's PARAM_VALUE_DATA struct | ||
pub fn to_string(input_slice: &[char]) -> String { | ||
input_slice | ||
.iter() | ||
.filter(|c| **c != char::from(0)) | ||
.collect() | ||
/// Decode param_id from mavlink's PARAM_VALUE_DATA struct | ||
pub fn decode_param_id(bytes: &[u8; 16]) -> String { | ||
std::str::from_utf8(bytes) | ||
.unwrap() | ||
.trim_end_matches('\0') | ||
.to_string() | ||
} | ||
|
||
/// Create char array for mavlink's PARAM_VALUE_DATA struct | ||
pub fn to_char_arr(input: &str) -> [char; 16] { | ||
let mut result = [' '; 16]; | ||
input | ||
.chars() | ||
.enumerate() | ||
.take(16) | ||
.for_each(|(i, e)| result[i] = e); | ||
result | ||
/// Encode param_id from mavlink's PARAM_VALUE_DATA struct | ||
pub fn encode_param_id(name: &str) -> [u8; 16] { | ||
let mut bytes = [0u8; 16]; | ||
bytes[..name.len()].copy_from_slice(name.as_bytes()); | ||
bytes | ||
} |