-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get the transport layer vaguely parsing
That is to say, it can nearly correctly parse my test data, though there's still a bunch of `todo!()`s in there that need fixing and of course the BCD problems
- Loading branch information
1 parent
b507f11
commit c3af71b
Showing
7 changed files
with
369 additions
and
66 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// Copyright 2024 Lexi Robinson | ||
// Licensed under the EUPL-1.2 | ||
pub mod control_info; | ||
pub mod header; | ||
pub mod manufacturer; | ||
|
||
pub use control_info::CICode; |
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright 2024 Lexi Robinson | ||
// Licensed under the EUPL-1.2 | ||
#![allow(dead_code)] | ||
|
||
use winnow::binary; | ||
use winnow::PResult; | ||
use winnow::Parser; | ||
|
||
use super::header::LongHeader; | ||
use super::header::TPLHeader; | ||
|
||
#[derive(Debug)] | ||
pub enum BaudRate { | ||
Rate300, | ||
Rate600, | ||
Rate1200, | ||
Rate2400, | ||
Rate4800, | ||
Rate9600, | ||
Rate19200, | ||
Rate38400, | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum CICode { | ||
Dlms(u8, TPLHeader), // TODO: Unsupported "see EN 13757–1" | ||
Reserved, | ||
ApplicationReset(TPLHeader), // or "Select To Device", EN 13757–3:2018, Clause 7 | ||
CommandToDevice(TPLHeader), // EN 13757–3:2018, Clause 6 | ||
ResponseFromDevice(TPLHeader), // EN 13757–3:2018, Clause 6, Annex G | ||
SelectionOfDevice, // EN 13757-7:2018, Clause 8.4 | ||
SelectedApplicationRequest(TPLHeader), // EN 13757–3:2018, Clause 7 | ||
SelectedApplicationResponse(TPLHeader), // EN 13757–3:2018, Clause 7 | ||
SynchroniseAction, // EN 13757–3:2018, Clause 12 | ||
SpecificUsage(u8), // "Used for specific national implementations" | ||
TimeSyncToDevice(TPLHeader), // EN 13757–3:2018, Clause 8 | ||
TimeAdjustmentToDevice(TPLHeader), // EN 13757–3:2018, Clause 8 | ||
ApplicationErrorFromDevice(TPLHeader), // EN 13757–3:2018, Clause 10 | ||
AlarmFromDevice(TPLHeader), // EN 13757–3:2018, Clause 9 | ||
Wireless(u8, TPLHeader), // TODO: Unsupported - EN 13757–4, EN 13757–5 | ||
Afl, // EN 13757-7:2018, Clause 6 | ||
ManufacturerSpecific(u8), | ||
SetBaudRate(BaudRate), | ||
ImageTransfer(u8), // TODO: Unsupported - EN 13757–3:2018, Annex 1 | ||
SecurityTransfer(u8), // TODO: Unsupported - EN 13757–3:2018, Annex A | ||
} | ||
|
||
impl CICode { | ||
pub fn parse(input: &mut &[u8]) -> PResult<CICode> { | ||
let ci = binary::u8.parse_next(input)?; | ||
Ok(match ci { | ||
0x72 => CICode::ResponseFromDevice(LongHeader::parse.parse_next(input)?), | ||
_ => todo!(), | ||
}) | ||
} | ||
} |
Oops, something went wrong.