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 - Advanced Bookmark Mode - Extended (Type 0x07, Subtype 0x0D)
- aux_
command - Generic types for Auxilliary Command/Reply messages - Auxilliary (Type 0x06)
- banknote
- Banknote types used across multiple messages
- cash
- Cash types used across multiple messages
- clear_
audit_ data - Clear Audit Data - Extended (Type 0x07, Subtype 0x1D)
- denomination
- Denomination types used
- error
- Library error types
- extended_
command - Generic types for Extended Command messages - Extended (Type 0x07)
- extended_
note_ inhibits - Extended Note Inhibits - Extended (Type 0x07, Subtype 0x03)
- extended_
note_ specification - Extended Note Specification - Extended (Type 0x07, Subtype 0x02)
- extended_
reply - Generic types for Extended Reply messages - Extended (Type 0x07)
- flash_
download - Flash Download - (Type 0x05)
- hardware
- Hardware status and related types
- index
- len
- Total message lengths for various messages
- logging
- Logging convenience helpers
- note_
retrieved - Note Retrieved - Extended (Type 0x07, Subtype 0x0B)
- omnibus
- Omnibus - Command (Type 0x01), Reply (Type 0x02)
- part_
number - Part number type definitions, used across multiple messages
- query_
application_ id - Query Application ID - Auxilliary (Type 0x06, Subtype 0x0E)
- query_
application_ part_ number - Query Application Part Number - Auxilliary (Type 0x06, Subtype 0x07)
- query_
boot_ part_ number - Query Boot Part Number - Auxilliary (Type 0x06, Subtype 0x06)
- query_
device_ capabilities - Query Device Capabilities - Auxilliary (Type 0x06, Subtype 0x0D)
- query_
software_ crc - Query Software CRC - Auxilliary (Type 0x06, Subtype 0x00)
- query_
value_ table - Query Value Table - Extended (Type 0x07, Subtype 0x06)
- query_
variant_ id - Query Variant ID - Auxilliary (Type 0x06, Subtype 0x0F)
- query_
variant_ name - Query Variant Name - Auxilliary (Type 0x06, Subtype 0x08)
- query_
variant_ part_ number - Query Variant Part Number - Auxilliary (Type 0x06, Subtype 0x09)
- set_
escrow_ timeout - Set Escrow Timeout - Extended (Type 0x07, Subtype 0x04)
- soft_
reset - Soft Reset - Auxilliary (Type 0x06, Subtype 0x7F)
- status
- Device status types
- variant
- Message variant for building messages from raw bytes Message variant types for crate messages.
Macros§
- bool_
enum - Creates an named boolean-like enum (set or unset enums).
- impl_
aux_ ops - Implements the defaults for the AuxCommandOps trait for a named type in the Auxilliary messages subset.
- impl_
default - Implements the Default trait for a named type with a
Self::new()
function. - impl_
extended_ ops - Implements the defaults for the ExtendedCommandOps trait for a named type in the Extended messages subset.
- impl_
extended_ reply_ ops - Implements the defaults for the ExtendedReplyOps trait for a named type in the Extended messages subset.
- impl_
from_ for_ omnibus_ reply - impl_
message_ ops - Implements the MessageOps trait for a named type.
- impl_
omnibus_ command_ ops - Implements the defaults for the OmnibusCommandOps trait for a named type.
- impl_
omnibus_ extended_ command - Implements the defaults for the OmnibusCommandOps trait for a named type that is in the subset of Extended Commands.
- impl_
omnibus_ extended_ reply - Implements the defaults for the OmnibusReplyOps trait for a named type that is in the subset of Extended Replies.
- impl_
omnibus_ nop_ reply - Sets all OmnibusReplyOps functions to
unimplemented
for an AuxCommand reply type. - impl_
omnibus_ reply_ ops - Implements the defaults for the OmnibusReplyOps trait for a named type.
- inner_
enum - Provides convenience functions to deconstruct an enum with new-type variants.
Structs§
- Control
- Control field for EBDS messages
Enums§
- AckNak
- Set the ACK field in the control byte
- Device
Type - Device type control bits
- Message
Type - Various message types for different device interactions
Constants§
- DEFAULT_
CURRENCY - ENQ
- Magic byte for Special Interrupt Mode (not supported).
- ENV_
CURRENCY - Constant for the environment variable defining the default Currency set
- ETX
- End byte for EBDS packet
- STX
- Start byte for EBDS packet
Traits§
- Message
Ops - Generic functions for all EBDS message types
Functions§
- bau_
currency - checksum
- Calculate the XOR checksum of a byte range
- validate_
checksum - Validates a checksum matches the expected value.