Skip to content

Commit

Permalink
Merge pull request #37 from pmnxis/dev/i36_display_hw_info
Browse files Browse the repository at this point in the history
#36 DisplayHwInfo impl and binding
  • Loading branch information
pmnxis committed Oct 22, 2023
2 parents 55961cd + e00b725 commit a57c8e7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 14 deletions.
12 changes: 6 additions & 6 deletions billmock-plug-card/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ impl CardTerminalTxGen for KiccEd785Plug {
&common::RAW_DATA_NACK
}

fn response_device_info<'a>(
fn response_device_info<'a, 'b>(
&self,
buffer: &'a mut [u8],
_model_version: &'a [u8; FW_VER_LEN],
_serial_number: &'a [u8; DEV_SN_LEN],
_model_version: &'b [u8; FW_VER_LEN],
_serial_number: &'b [u8; DEV_SN_LEN],
) -> &'a [u8] {
// implement me for actual usage
&buffer[0..0]
Expand Down Expand Up @@ -122,11 +122,11 @@ impl CardTerminalTxGen for KiccEd785Plug {
&buffer[0..0]
}

fn display_hw_info<'a>(
fn display_hw_info<'a, 'b>(
&self,
buffer: &'a mut [u8],
_model_version: &'a [u8; FW_VER_LEN],
_serial_number: &'a [u8; DEV_SN_LEN],
_model_version: &'b [u8; FW_VER_LEN],
_serial_number: &'b [u8; DEV_SN_LEN],
_terminal_id: &[u8; TID_LEN],
_hw_boot_cnt: u32,
_uptime_minutes: u32,
Expand Down
12 changes: 6 additions & 6 deletions card-terminal-adapter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,11 @@ pub trait CardTerminalTxGen {

/// Generate ResponseDeviceInfo signal to send
/// Response for requesting device information (RequestDeviceInfo)
fn response_device_info<'a>(
fn response_device_info<'a, 'b>(
&self,
buffer: &'a mut [u8],
model_version: &'a [u8; FW_VER_LEN],
serial_number: &'a [u8; DEV_SN_LEN],
model_version: &'b [u8; FW_VER_LEN],
serial_number: &'b [u8; DEV_SN_LEN],
) -> &'a [u8];

/// Generate PushCoinPaperAcceptorIncome signal to send
Expand Down Expand Up @@ -187,11 +187,11 @@ pub trait CardTerminalTxGen {

/// Generate DisplayHwInfo signal to send
/// Display hardware information, boot count, uptime and etc.
fn display_hw_info<'a>(
fn display_hw_info<'a, 'b>(
&self,
buffer: &'a mut [u8],
model_version: &'a [u8; FW_VER_LEN],
serial_number: &'a [u8; DEV_SN_LEN],
model_version: &'b [u8; FW_VER_LEN],
serial_number: &'b [u8; DEV_SN_LEN],
terminal_id: &[u8; TID_LEN],
hw_boot_cnt: u32,
uptime_minutes: u32,
Expand Down
5 changes: 5 additions & 0 deletions src/application/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ impl Application {
.card_reader
.send(CardTerminalTxCmd::DisplayRom)
.await;
} else if appmode == AppMode0V3::DisplayRom {
hardware
.card_reader
.send(CardTerminalTxCmd::DisplayHwInfo)
.await;
}

appmode = appmode_latest;
Expand Down
16 changes: 14 additions & 2 deletions src/components/serial_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,20 @@ impl CardReaderDevice {
)
}
CardTerminalTxCmd::DisplayHwInfo => {
// display_rom
unimplemented!()
let hw_boot_cnt = novella.lock_read(eeprom::select::HW_BOOT_CNT).await;
let tid = novella.lock_read(eeprom::select::TERMINAL_ID).await.normal;
let uptime_minutes = (novella.get_uptime().await.as_secs() / 60)
.min(u32::MAX as u64)
as u32;

plug.display_hw_info(
&mut tx_buf,
&const_str::VERSION_STR,
const_str::get_serial_number(),
&tid,
hw_boot_cnt,
uptime_minutes,
)
}
CardTerminalTxCmd::DisplayWarning(x) => {
plug.display_warning(&mut tx_buf, x)
Expand Down

0 comments on commit a57c8e7

Please sign in to comment.