Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

USBTMC: EP not busy should not bail from tud_usbtmc_transmit_notification_data #2735

Open
1 task done
hinxx opened this issue Jul 23, 2024 · 0 comments
Open
1 task done
Labels

Comments

@hinxx
Copy link

hinxx commented Jul 23, 2024

Operating System

Linux

Board

RPI Pico

Firmware

tinyusb/src/class/usbtmc/usbtmc_device.c
tinyusb/examples/device/usbtmc/src/usbtmc_app.c

What happened ?

PR #2494 introduced tud_usbtmc_transmit_notification_data() function. The check if EP is not busy bails out of the function if the EP is NOT busy:

TU_VERIFY(usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in));

I believe it should be the opposite; bail if the EP IS busy and continue if not busy like so:

TU_VERIFY(usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in) == false);

How to reproduce ?

Original code:

  1. Add the following to usbtmc_app.c:
bool tud_usbtmc_notification_complete_cb(void) {
  usbtmc_srq_interrupt_488_t intMsg =
  {
    .bNotify1 = USB488_bNOTIFY1_SRQ,
    .StatusByte = 0xa5
  };
  bool ret = tud_usbtmc_transmit_notification_data((void*)&intMsg, sizeof(intMsg));
  (void)ret;

  return true;
}
  1. Use the following python script to poll for interrupt condition: poll-interrupt-in.txt

  2. Observe No data available (timeout) being printed out by python script.

  3. Change the

    TU_VERIFY(usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in));

    to

TU_VERIFY(usbd_edpt_busy(usbtmc_state.rhport, usbtmc_state.ep_int_in) == false);
  1. Using the same script will now continuously print :
Data received: array('B', [129, 165])

Debug Log as txt file (LOG/CFG_TUSB_DEBUG=2)

I could not see any useful in the debug logs, I had to use the pico probe debugger to see that the interrupt EP is in fact not busy and the the code is wrong.

Screenshots

No response

I have checked existing issues, dicussion and documentation

  • I confirm I have checked existing issues, dicussion and documentation.
@hinxx hinxx added the Bug 🐞 label Jul 23, 2024
@hinxx hinxx changed the title USBTMC check for EP not busy should return true in tud_usbtmc_transmit_notification_data USBTMC: EP not busy should not bail true in tud_usbtmc_transmit_notification_data Jul 23, 2024
@hinxx hinxx changed the title USBTMC: EP not busy should not bail true in tud_usbtmc_transmit_notification_data USBTMC: EP not busy should not bail from tud_usbtmc_transmit_notification_data Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant