ADC-24 USB hang when pressing ctrl-c

Discussion forum for the Picoscope 6 Linux software
Post Reply
ehliar
Newbie
Posts: 0
Joined: Tue Mar 26, 2019 8:44 am

ADC-24 USB hang when pressing ctrl-c

Post by ehliar »

Another problem I have is that the device is highly likely to end up
in a bad state in case I press ctrl-c while picohrdlCon is collecting
data. In this case I get messages like the following in dmesg:

Code: Select all

[3617769.153920] usb 1-9: device descriptor read/64, error -110
This was relatively easy to work around for ctrl-c by installing a
signal-handler and ensuring that I close the device using
HRDLCloseUnit().

Example code if someone else has the same problem:

Code: Select all

// Only modify ctrl_c volatile variable here to avoid accidentally calling
// functions that are not async-signal-safe.
volatile ctrl_c = 0;
void sigint_handler(sig_t s)
{
  ctrl_c = 1;
}


void main (void)
{
  // ... lots of code snipped
  signal (SIGINT, sigint_handler);
  // Main loop
  while(!ctrl_c) {
    CollectSingleBlocked();
  }
  printf("Exiting due to ctrl-c\n");
  HRDLCloseUnit(g_device);
  printf("Device closed\n");
}
}

Do you have a better work-around for this? This workaround seems good
enough for the ctrl-c case but will probably not work if I for example
need to force-quit my application from within a debugger.


I'm running this on x86_64 Ubuntu 18.04.2 LTS with libpicohrdl 1.6.0-1r08.
The picosdk-c-examples was cloned from commit 2342bef920ebd233ff98d16fb457047323093221

Hitesh

Re: ADC-24 USB hang when pressing ctrl-c

Post by Hitesh »

Hi ehliar,

This is a known issue if data collection is stopped without calling HRDLCloseUnit(). An issue has already been logged, and should be investigated in the future.

For the time being, please use the workaround that you have.

Regards,

Post Reply