Skip to content

tkey: gate CDC and FIDO handling on endpoint match, poll in readselect - #107

Open
jthornblad wants to merge 1 commit into
mainfrom
dont_block_in_main
Open

tkey: gate CDC and FIDO handling on endpoint match, poll in readselect#107
jthornblad wants to merge 1 commit into
mainfrom
dont_block_in_main

Conversation

@jthornblad

@jthornblad jthornblad commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Description

  • Change readselect() to non-blocking (true) instead of blocking (false) to be able to process data that have been put into the fifo from other places than main.
  • Guard the FIDO frame length check, read(), and fifo_hidmsg_add() behind (ep == IO_FIDO) && (available >= 1), since these previously ran unconditionally even when the received data came from IO_CDC
  • Use discard() instead of read() to drop incomplete HID frames
  • Replace the fifo_hidmsg_add() failure's return -1 with an assert, matching the other error-handling style in this loop

Type of change

Please tick any that are relevant to this PR and remove any that aren't.

  • Bugfix (non breaking change which resolve an issue)
  • Feature (non breaking change which adds functionality)
  • Breaking Change (a change which would cause existing functionality to not work as expected)
  • Documentation (a change to documentation)

Submission checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my changes
  • I have tested and verified my changes on target
  • My changes are well written and CI is passing
  • I have squashed my work to relevant commits and rebased on main for linear history
  • I have added a "Co-authored-by: x" if several people contributed, either pair programming or by squashing commits from different authors.
  • I have updated the documentation where relevant (readme, dev.tillitis.se etc.)
  • QEMU is updated to reflect changes

- Change readselect() to non-blocking (true) instead of blocking
  (false) to be able to process data that have been put into the
  fifo from other places than main.
- Guard the FIDO frame length check, read(), and fifo_hidmsg_add()
  behind `(ep == IO_FIDO) && (available >= 1)`, since these
  previously ran unconditionally even when the received data came
  from IO_CDC
- Use discard() instead of read() to drop incomplete HID frames
- Replace the fifo_hidmsg_add() failure's `return -1` with an assert,
  matching the other error-handling style in this loop
@jthornblad
jthornblad requested a review from dehanj July 10, 2026 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant