Generate packet from struct
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -15,7 +15,9 @@ use improv_setup::improv::{
|
||||
RPCCommand,
|
||||
CurrentState,
|
||||
calculate_checksum,
|
||||
ImprovDataToPacket,
|
||||
ImprovPacket,
|
||||
RequestCurrentStateCommand,
|
||||
};
|
||||
use log::{
|
||||
debug,
|
||||
@@ -117,15 +119,7 @@ async fn main() -> Result<()>{
|
||||
.fold(String::new(), |a, b| a + &b + &String::from("\n")));
|
||||
},
|
||||
Commands::Device {path, baud_rate, device_command} => {
|
||||
let mut data: Vec<u8> = Vec::new();
|
||||
data.push(RPCCommand::RequestCurrentState as u8); // command
|
||||
data.push(0x00); // command data length
|
||||
|
||||
let request_current_state_packet = ImprovPacket {
|
||||
version: IMPROV_VERSION,
|
||||
r#type: PacketType::RPCCommand,
|
||||
data: data,
|
||||
};
|
||||
let request_current_state_packet = (RequestCurrentStateCommand {}).to_packet();
|
||||
|
||||
println!("{}", hex::encode(&request_current_state_packet.to_bytes()));
|
||||
println!("{}", to_ascii_debug(&request_current_state_packet.to_bytes()));
|
||||
|
Reference in New Issue
Block a user