Module x328_proto::master
source · Expand description
The bus controller half of the X3.28 protocol
Example
See crate::master::io::Master
for a more elaborate example of synchronous IO.
use x328_proto::{Master, addr, param, master::SendData};
let mut master = Master::new();
let mut serial = connect_serial_interface()?;
let send = &mut master.write_parameter(addr(10), param(3010), (-30_i16).into());
serial.write_all(send.get_data())?;
let mut recv = send.data_sent();
loop {
let mut buf = [0; 20];
let len = serial.read(&mut buf[..])?;
if len == 0 {
// .. error handling ..
}
if let Some(response) = recv.receive_data(&buf[..len]) {
break response;
}
}?;
Modules
- Sample implementation of the X3.28 bus controller for an IO-channel implementing
std::io::{Read, Write}
.
Structs
- X3.28 bus controller.
Enums
- Error type for the X3.28 bus controller
Traits
- Receives the command response from the node. Keep reading data from the bus until receive_data() returns Some(..).
SendData
holds data that should be transmitted to the nodes.