(device: &HidDevice, row_no: u16, row: &[u8])
| 448 | } |
| 449 | |
| 450 | fn write_row(device: &HidDevice, row_no: u16, row: &[u8]) -> Result<usize, HidError> { |
| 451 | let row_no_bytes = row_no.to_le_bytes(); |
| 452 | trace!("Writing row {:04X}. Data: {:X?}", row_no, row); |
| 453 | |
| 454 | // First image start 0x1800 (row 0x30) |
| 455 | // row from 0x0030 to 0x01fb |
| 456 | // 0x30*128 (row size) = 0x1800, which is Image 1 start = 00001800 |
| 457 | // 0x01fb-0x30+1 = 460 |
| 458 | // OH! This must be the metadata |
| 459 | // And another one at 03ff, which adds up to 461 rows |
| 460 | // |
| 461 | // Second Image start 0x10000 (row 0x200) |
| 462 | // Last one if 0x03cb |
| 463 | // And another one at 03fe |
| 464 | |
| 465 | // I think 0x46 might be CY_PD_FLASH_READ_WRITE_CMD_SIG |
| 466 | let mut buffer = [0; 132]; |
| 467 | buffer[0] = ReportIdCmd::E2WriteRow as u8; |
| 468 | buffer[1] = CmdParam::FlashWrite as u8; |
| 469 | buffer[2] = row_no_bytes[0]; |
| 470 | buffer[3] = row_no_bytes[1]; |
| 471 | buffer[4..].copy_from_slice(row); |
| 472 | device.write(&buffer) |
| 473 | } |
| 474 | |
| 475 | /// Wait for the specific card to reappear |
| 476 | /// Waiting a maximum timeout, if it hasn't appeared by then, return None |
no test coverage detected