pub struct DeviceHandle { /* private fields */ }
Expand description

Handle for communicating with a SSP-enabled device over serial.

let _handle = ssp_server::DeviceHandle::new("/dev/ttyUSB0").unwrap();

Implementations§

source§

impl DeviceHandle

source

pub fn new(serial_path: &str) -> Result<Self>

Creates a new DeviceHandle with a serial connection over the supplied serial device.

source

pub fn start_background_polling( &self, stop_polling: Arc<AtomicBool> ) -> Result<()>

Starts background polling routine to regularly send [PollCommand] messages to the device.

Args

  • stop_polling: used to control when the polling routine should stop sending polling messages.

If background polling has already started, the function just returns.

Example:

let stop_polling = Arc::new(AtomicBool::new(false));

let handle = ssp_server::DeviceHandle::new("/dev/ttyUSB0")?;

handle.start_background_polling(Arc::clone(&stop_polling))?;
source

pub fn start_background_polling_with_queue( &self, stop_polling: Arc<AtomicBool>, poll_mode: PollMode ) -> Result<PushEventReceiver>

Starts background polling routine to regularly send [PollCommand] messages to the device, with an additional event queue for sending push events from the device to the host.

Args

  • stop_polling: used to control when the polling routine should stop sending polling messages.

If background polling has already started, the function just returns.

Returns an event queue receiver that the caller can use to receive device-sent events.

Example:

let stop_polling = Arc::new(AtomicBool::new(false));
let poll_mode = ssp_server::PollMode::Interactive;

let handle = ssp_server::DeviceHandle::new("/dev/ttyUSB0")?;

let rx = handle.start_background_polling_with_queue(
    Arc::clone(&stop_polling),
    poll_mode,
)?;

// Pop events from the queue
loop {
    while let Ok(event) = rx.pop_event() {
        log::debug!("Received an event: {event}");
        // do stuff in response to the event...
    }
}
source

pub fn serial_port(&self) -> Result<MutexGuard<'_, TTYPort>>

Get the serial port used for communication with the acceptor device

source

pub fn encryption_key(&self) -> Result<MutexGuard<'_, Option<AesKey>>>

Acquires a lock on the AES encryption key.

source

pub fn new_generator_key(&mut self)

Creates a new GeneratorKey from system entropy.

source

pub fn new_modulus_key(&mut self)

Creates a new ModulusKey from system entropy.

source

pub fn new_random_key(&mut self)

Creates a new RandomKey from system entropy.

source

pub fn stack(&self) -> Result<ChannelValue>

Sends a command to stack a bill in escrow.

source

pub fn set_inhibits( &self, enable_list: EnableBitfieldList ) -> Result<SetInhibitsResponse>

Send a SetInhibitsCommand message to the device.

No response is returned.

The caller should wait a reasonable amount of time for the device to come back online before sending additional messages.

source

pub fn reset(&self) -> Result<()>

Send a ResetCommand message to the device.

No response is returned.

The caller should wait a reasonable amount of time for the device to come back online before sending additional messages.

source

pub fn poll(&self) -> Result<PollResponse>

Send a PollCommand message to the device.

source

pub fn poll_with_ack(&self) -> Result<PollWithAckResponse>

Send a PollWithAckCommand message to the device.

source

pub fn event_ack(&self) -> Result<EventAckResponse>

Send a EventAckCommand message to the device.

source

pub fn reject(&self) -> Result<RejectResponse>

Send a RejectCommand message to the device.

source

pub fn sync(&self) -> Result<SyncResponse>

Send a SyncCommand message to the device.

source

pub fn enable_device( &self, protocol_version: ProtocolVersion ) -> Result<EnableResponse>

Starts the device by performing the full initialization sequence.

source

pub fn enable(&self) -> Result<EnableResponse>

Send a EnableCommand message to the device.

source

pub fn disable(&self) -> Result<DisableResponse>

Send a DisableCommand message to the device.

source

pub fn display_off(&self) -> Result<DisplayOffResponse>

Send a DisplayOffCommand message to the device.

source

pub fn display_on(&self) -> Result<DisplayOnResponse>

Send a DisplayOnCommand message to the device.

source

pub fn empty(&self) -> Result<EmptyResponse>

Send an EmptyCommand message to the device.

source

pub fn smart_empty(&self) -> Result<SmartEmptyResponse>

Send an SmartEmptyCommand message to the device.

source

pub fn host_protocol_version( &self, protocol_version: ProtocolVersion ) -> Result<HostProtocolVersionResponse>

Send an HostProtocolVersionCommand message to the device.

source

pub fn serial_number(&self) -> Result<SerialNumberResponse>

Send a SerialNumberCommand message to the device.

source

pub fn set_generator(&self) -> Result<SetGeneratorResponse>

Send a SetGeneratorCommand message to the device.

If the response is an Err(_), or the response status is not RsponseStatus::Ok, the caller should call new_generator_key, and try again.

source

pub fn set_modulus(&mut self) -> Result<SetModulusResponse>

Send a SetModulusCommand message to the device.

If the response is an Err(_), or the response status is not RsponseStatus::Ok, the caller should call new_modulus_key, and try again.

source

pub fn request_key_exchange(&mut self) -> Result<RequestKeyExchangeResponse>

Send a RequestKeyExchangeCommand message to the device.

If the response is an Err(_), or the response status is not RsponseStatus::Ok, the caller should call new_random_key, and try again.

source

pub fn set_encryption_key(&mut self) -> Result<SetEncryptionKeyResponse>

Send a SetEncryptionKeyCommand message to the device.

If the response is an Err(_), or the response status is not RsponseStatus::Ok, the caller should call new_modulus_key, and try again.

source

pub fn encryption_reset(&mut self) -> Result<EncryptionResetResponse>

Send a EncryptionResetCommand message to the device.

source

pub fn setup_request(&self) -> Result<SetupRequestResponse>

Send a SetupRequestCommand message to the device.

source

pub fn unit_data(&self) -> Result<UnitDataResponse>

Send a UnitDataCommand message to the device.

source

pub fn channel_value_data(&self) -> Result<ChannelValueDataResponse>

Send a ChannelValueDataCommand message to the device.

source

pub fn last_reject_code(&self) -> Result<LastRejectCodeResponse>

Send a LastRejectCodeCommand message to the device.

source

pub fn hold(&self) -> Result<HoldResponse>

Send a HoldCommand message to the device.

source

pub fn get_barcode_reader_configuration( &self ) -> Result<GetBarcodeReaderConfigurationResponse>

Send a GetBarcodeReaderConfigurationCommand message to the device.

source

pub fn has_barcode_reader(&self) -> Result<bool>

Gets whether the device has barcode readers present.

source

pub fn set_barcode_reader_configuration( &self, config: BarcodeConfiguration ) -> Result<SetBarcodeReaderConfigurationResponse>

Send a SetBarcodeReaderConfigurationCommand message to the device.

source

pub fn get_barcode_inhibit(&self) -> Result<GetBarcodeInhibitResponse>

Send a GetBarcodeInhibitCommand message to the device.

source

pub fn set_barcode_inhibit( &self, inhibit: BarcodeCurrencyInhibit ) -> Result<SetBarcodeInhibitResponse>

Send a SetBarcodeInhibitCommand message to the device.

source

pub fn get_barcode_data(&self) -> Result<GetBarcodeDataResponse>

Send a GetBarcodeDataCommand message to the device.

source

pub fn configure_bezel( &self, rgb: RGB, storage: BezelConfigStorage ) -> Result<ConfigureBezelResponse>

Send a ConfigureBezelCommand message to the device.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V