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
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