-
Notifications
You must be signed in to change notification settings - Fork 320
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
Serial backend fixes #1092
Serial backend fixes #1092
Conversation
pcercuei
commented
Dec 1, 2023
- Make sure the serial backend will properly exit and not lock up when iio_context_destroy is called;
- Handle clients sending the BINARY command in ASCII when IIOD is already in binary mode (which happens when a new client connects)
- Fix iio_context_clone() in the compat layer, which should return -ENOSYS with the serial backend, as only one context can be created at the same time. This fixes iio-osc running on top of the compat layer when using the serial backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
c8a007e
to
2da3ddc
Compare
Instead of doing blocking reads, which are not cancellable and therefore cause deadlocks when the .shutdown callback is called, use a fast polling loop with non-blocking reads. This fixes the read thread not closing on shutdown. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
It was using the return value as a specifier for the string length, which is fine as long as the return value is positive, but is most certainly not fine if it is a negative error code. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
This allows Libiio >= v1.0 to talk with IIOD <= v0.25. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Unlike with the network and USB backends, IIOD is unable to detect when a client disconnected. A new client would then send the BINARY command, which would not be understood by IIOD if it already was in binary mode. Use the convenient fact that the BINARY string is exactly the same size as our command opcodes, and compare each opcode read with the "BINARY\r\n" string. In case of a match, simply send a code 0 to tell the client that we are in binary mode, and continue as usual. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
The .clone callback was only implemented by the local and network backends in Libiio <= v0.25. Emulate this behaviour by returning -ENOSYS if using a different backend. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
2da3ddc
to
4292df5
Compare
nanosleep(&ts, NULL); | ||
#endif | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be in utils.c rather than here? (I guess it's a single use case?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utils.c is for the high-level API, we'd have to export it as a public symbol (as the serial backend can be a module) and I prefer to avoid that as much as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense.
It is possible that iio_task_stop() will be called even before the iio_task_run() thread enters the while() loop, where it waits for tasks; in that case, both threads would be waiting on the condition variable without anyone signaling it. Address that issue by signaling the condition variable at the beginning of the for() loop, and not at the end. Signed-off-by: Paul Cercueil <paul@crapouillou.net>
Added a fix for a lockup that only @buha could trigger. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool, the last commit does fix the issue of iio_info hanging after printing all the info