Skip to content

Commit

Permalink
refactor(send_custom_fc): remove the blocking of standard function co…
Browse files Browse the repository at this point in the history
…des when sending a CFC request
  • Loading branch information
dkoehler-dev committed Mar 12, 2024
1 parent 790eb3b commit afbfbca
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions rodbus/examples/custom_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,13 @@ async fn run_channel(mut channel: Channel) -> Result<(), Box<dyn std::error::Err
let byte_count_out = u8::from_str_radix(bytes_out_str.trim_start_matches("0x"), 16).unwrap();
let values: Vec<u16> = values.iter().filter_map(|&v| u16::from_str_radix(v.trim_start_matches("0x"), 16).ok()).collect();

if (fc >= 65 && fc <= 72) || (fc >= 100 && fc <= 110) {
let result = channel
.send_custom_function_code(
params,
CustomFunctionCode::new(fc, byte_count_in, byte_count_out, values)
)
.await;
print_write_result(result);
} else {
println!("Error: CFC number is not inside the range of 65-72 or 100-110.");
}
let result = channel
.send_custom_function_code(
params,
CustomFunctionCode::new(fc, byte_count_in, byte_count_out, values)
)
.await;
print_write_result(result);
}
_ => println!("unknown command"),
}
Expand Down

0 comments on commit afbfbca

Please sign in to comment.