Expand description
§EBDS Serial Protocol
This crate implements the EBDS serial protocol messages, and related types for communication with bill acceptor unit devices.
The currently supported messages are implemented in the various modules in this crate, along with some common types used across multiple messages.
If adding a new message, please follow the existing pattern of placing ...Command
(host-initiated) messages in <message-type>/command.rs
files, and ...Reply
(device-initiated) messages in <message-type>/reply.rs
files.
There are some exceptions to the general rule, e.g. when the types in the documenation do not follow the Command/Reply
naming convention.
In those cases, the suffix is omitted to aid in readability when comparing with the EBDS specification.
§Macros
Some simple macros exist for implementing traits over the various message types. All message types should implement MessageOps
, and all reply types should implement OmnibusReplyOps
.
MessageOps
can be implemented with the helper macro impl_message_ops!
, e.g. for a new SomeNewReply
message:
use ebds::impl_message_ops;
pub struct SomeNewReply {
// For the example, we are just using a number for the length.
// In real implementations, please add a constant to the `len` module.
buf: [u8; 11],
}
impl_message_ops!(SomeNewReply);
This will implement the MessageOps
trait for SomeNewReply
, and provide all of the associated functions. Traits are how Rust does polymorphism, similar to Go’s interface
and C++’s template
, with important differences.
All of the macro implementations live in src/macros.rs
.
§Using with std
This library is no-std
compatible by default. To use std
-only features, add the std
feature to the dependency:
ebds = { version = "0.1", features = ["std"] }
Re-exports§
pub use crate::error::Error;
pub use crate::error::JsonRpcError;
pub use crate::error::JsonRpcResult;
pub use crate::error::Result;
pub use banknote::*;
pub use cash::*;
pub use denomination::*;
pub use error::*;
pub use hardware::*;
pub use logging::*;
pub use status::*;
pub use advanced_bookmark_mode::*;
pub use aux_command::*;
pub use clear_audit_data::*;
pub use extended_command::*;
pub use extended_note_inhibits::*;
pub use extended_note_specification::*;
pub use extended_reply::*;
pub use flash_download::*;
pub use note_retrieved::*;
pub use omnibus::*;
pub use part_number::*;
pub use query_application_id::*;
pub use query_application_part_number::*;
pub use query_boot_part_number::*;
pub use query_device_capabilities::*;
pub use query_software_crc::*;
pub use query_value_table::*;
pub use query_variant_id::*;
pub use query_variant_name::*;
pub use query_variant_part_number::*;
pub use set_escrow_timeout::*;
pub use soft_reset::*;
pub use variant::*;
Modules§
- Advanced Bookmark Mode - Extended (Type 0x07, Subtype 0x0D)
- Generic types for Auxilliary Command/Reply messages - Auxilliary (Type 0x06)
- Banknote types used across multiple messages
- Cash types used across multiple messages
- Clear Audit Data - Extended (Type 0x07, Subtype 0x1D)
- Denomination types used
- Library error types
- Generic types for Extended Command messages - Extended (Type 0x07)
- Extended Note Inhibits - Extended (Type 0x07, Subtype 0x03)
- Extended Note Specification - Extended (Type 0x07, Subtype 0x02)
- Generic types for Extended Reply messages - Extended (Type 0x07)
- Flash Download - (Type 0x05)
- Hardware status and related types
- Total message lengths for various messages
- Logging convenience helpers
- Note Retrieved - Extended (Type 0x07, Subtype 0x0B)
- Omnibus - Command (Type 0x01), Reply (Type 0x02)
- Part number type definitions, used across multiple messages
- Query Application ID - Auxilliary (Type 0x06, Subtype 0x0E)
- Query Application Part Number - Auxilliary (Type 0x06, Subtype 0x07)
- Query Boot Part Number - Auxilliary (Type 0x06, Subtype 0x06)
- Query Device Capabilities - Auxilliary (Type 0x06, Subtype 0x0D)
- Query Software CRC - Auxilliary (Type 0x06, Subtype 0x00)
- Query Value Table - Extended (Type 0x07, Subtype 0x06)
- Query Variant ID - Auxilliary (Type 0x06, Subtype 0x0F)
- Query Variant Name - Auxilliary (Type 0x06, Subtype 0x08)
- Query Variant Part Number - Auxilliary (Type 0x06, Subtype 0x09)
- Set Escrow Timeout - Extended (Type 0x07, Subtype 0x04)
- Soft Reset - Auxilliary (Type 0x06, Subtype 0x7F)
- Device status types
- Message variant for building messages from raw bytes Message variant types for crate messages.
Macros§
- Creates an named boolean-like enum (set or unset enums).
- Implements the defaults for the AuxCommandOps trait for a named type in the Auxilliary messages subset.
- Implements the Default trait for a named type with a
Self::new()
function. - Implements the defaults for the ExtendedCommandOps trait for a named type in the Extended messages subset.
- Implements the defaults for the ExtendedReplyOps trait for a named type in the Extended messages subset.
- Implements the MessageOps trait for a named type.
- Implements the defaults for the OmnibusCommandOps trait for a named type.
- Implements the defaults for the OmnibusCommandOps trait for a named type that is in the subset of Extended Commands.
- Implements the defaults for the OmnibusReplyOps trait for a named type that is in the subset of Extended Replies.
- Implements the defaults for the OmnibusReplyOps trait for a named type.
- Provides convenience functions to deconstruct an enum with new-type variants.
Structs§
- Control field for EBDS messages
Enums§
- Set the ACK field in the control byte
- Device type control bits
- Various message types for different device interactions
Constants§
- Magic byte for Special Interrupt Mode (not supported).
- Constant for the environment variable defining the default Currency set
- End byte for EBDS packet
- Start byte for EBDS packet
Traits§
- Generic functions for all EBDS message types
Functions§
- Calculate the XOR checksum of a byte range
- Validates a checksum matches the expected value.