pub struct Request { /* private fields */ }Expand description
A frame to send and how long to wait for its reply.
Implementations§
Source§impl Request
impl Request
Sourcepub fn bytes(&self) -> &[u8] ⓘ
pub fn bytes(&self) -> &[u8] ⓘ
The bytes to write to the bus.
Examples found in repository?
examples/master.rs (line 24)
18fn main() {
19 let mut bus = Scripted::default();
20
21 // 1. Read meter 1 completely: SND_NKE, then REQ_UD2 until no more records follow.
22 let mut readout = Readout::new(Target::Primary(1));
23 while let Some(request) = readout.next_request() {
24 let reply = bus.transfer(request.bytes(), request.timeout_ms(Baud::B2400));
25 let event = if reply.is_empty() { readout.timeout(&reply) } else { readout.reply(&reply) };
26 if let Event::Telegram(app) = event {
27 println!("telegram from {}", app.meter().map_or("?".into(), |m| m.to_string()));
28 for record in app.records().into_iter().flatten().flatten() {
29 println!(" {record}");
30 }
31 }
32 }
33 println!("{} telegrams\n", readout.telegrams());
34
35 // 2. Find every meter on the bus by secondary address.
36 let mut search = Search::new();
37 while let Some(request) = search.next_request() {
38 let reply = bus.transfer(request.bytes(), request.timeout_ms(Baud::B2400));
39 let event = if reply.is_empty() { search.timeout(&reply) } else { search.reply(&reply) };
40 if let Event::Found(meter) = event {
41 println!("found {meter}");
42 }
43 }
44 println!("{} selections", search.selections());
45}Sourcepub const fn timeout_ms(&self, baud: Baud) -> u32
pub const fn timeout_ms(&self, baud: Baud) -> u32
How long to wait for the start of the reply at baud, in milliseconds
(response_timeout_ms); 0 when no reply is expected (broadcast).
Examples found in repository?
examples/master.rs (line 24)
18fn main() {
19 let mut bus = Scripted::default();
20
21 // 1. Read meter 1 completely: SND_NKE, then REQ_UD2 until no more records follow.
22 let mut readout = Readout::new(Target::Primary(1));
23 while let Some(request) = readout.next_request() {
24 let reply = bus.transfer(request.bytes(), request.timeout_ms(Baud::B2400));
25 let event = if reply.is_empty() { readout.timeout(&reply) } else { readout.reply(&reply) };
26 if let Event::Telegram(app) = event {
27 println!("telegram from {}", app.meter().map_or("?".into(), |m| m.to_string()));
28 for record in app.records().into_iter().flatten().flatten() {
29 println!(" {record}");
30 }
31 }
32 }
33 println!("{} telegrams\n", readout.telegrams());
34
35 // 2. Find every meter on the bus by secondary address.
36 let mut search = Search::new();
37 while let Some(request) = search.next_request() {
38 let reply = bus.transfer(request.bytes(), request.timeout_ms(Baud::B2400));
39 let event = if reply.is_empty() { search.timeout(&reply) } else { search.reply(&reply) };
40 if let Event::Found(meter) = event {
41 println!("found {meter}");
42 }
43 }
44 println!("{} selections", search.selections());
45}Sourcepub fn with_fcb(self, fcb: bool) -> Self
pub fn with_fcb(self, fcb: bool) -> Self
The same frame with the frame count bit set or cleared (checksum recomputed).
EN 13757-2: after SND_NKE, and to address FD after every selection, the next
SND_UD carries FCB = 1; it toggles after each acknowledged one.
Sourcepub const fn expects_reply(&self) -> bool
pub const fn expects_reply(&self) -> bool
Whether a reply is expected at all.
Trait Implementations§
impl Copy for Request
impl Eq for Request
impl StructuralPartialEq for Request
Auto Trait Implementations§
impl Forget for Request
impl Freeze for Request
impl Move for Request
impl RefUnwindSafe for Request
impl Send for Request
impl Sync for Request
impl Unpin for Request
impl UnsafeUnpin for Request
impl UnwindSafe for Request
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more