Crate ebds

Source
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
DeviceType
Device type control bits
MessageType
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§

MessageOps
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.