Blevene / LabsConBadge_2023

LabsConBadge 2023
4 stars 2 forks source link

fine tune trade process #22

Closed securelyfitz closed 12 months ago

securelyfitz commented 1 year ago

right now it mostly works but has a few software delays hard coded for ease of debugging.

probably makes sense to break out 'transmit' and 'receive' into class member functions to make the trade logic a bit cleaner

also - once a trade happens, the card needs to be validated and both the card and handle need to be stored properly

securelyfitz commented 1 year ago

seems like tx/rx is reliable enough it's best to just do it once, plus then you don't get misaligned byte pairs also, seems like uart timeout is good enough if set low. still need to clean up code and remove print statements

also - clue validation happens in the game data structure

securelyfitz commented 1 year ago

fixed an annoying issue where if i sent too much data (~20 bytes) the rp2040 would hard crash a few seconds later. no errors. added a flush() after each byte write, while excessive , gets it one.

still need to clean up overlay geometry

securelyfitz commented 12 months ago

overlay and text cleaned up. annoying hard crash issue disappeared for small transactions, but is now blocking TX/RX. some details:

theory:

securelyfitz commented 12 months ago

More notes:

securelyfitz commented 12 months ago

workaround is to use busio to create the UART interface with a large buffer. Have not isolated the missing bounds checking.

Solved two issues with TX/RX sync with a lead-in of carriage returns:

  1. the first few bytes sent after power is enabled to the IRDA phy seem to be error prone. A lead-in of CR's gets some run time before transmitting the data. Received CR's are then trimmed as whitespace.
  2. sometimes, the 2-byte symbols are misaligned. To fix, the fake_ira.readbyte member checks every byte coming in - if twice in a row, it receives a misaligned CR's, it reads and drops one more byte so that it's back in sync

With this, the majority of transmissions are flawless. There are still occasional bitflips, but crc/encryption should easily catch those.

Closing this for the badge - but will pursue the memory corruption issue elsewhere.