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

(Question) SerialConnection mutex locks read and write methods #195

Open
antonio-sc66 opened this issue Oct 18, 2023 · 1 comment
Open

Comments

@antonio-sc66
Copy link
Contributor

antonio-sc66 commented Oct 18, 2023

Hi,

To my understanding, the SerialConnection has a single mutex to lock the port attribute, this means that if a SerialConnection is shared between threads using Arc (like in the mavlink-dump binary) it won't be posible to perform a recv call in one thread and a send call in another thread at the same time. If no messages are received it will never be able to send (mutex will be locked until recv ends).

SerialPorts can send and receive at the same time, but the crate used doesn't split the tx and rx channels, I guess this is why a single Port and mutex is being used.

How can a workaround be implemented?

Would it be posible to have an auxiliary mutex to split reading and writing locks? Methods performing read operations would lock an specific mutex and methods performing write operations would lock the other mutex. It's not elegant but the port is hidden inside the structure. Would this make any sense?

@patrickelectric
Copy link
Member

That was in theory fixed by this PR
#102

But, I have not rebased it or tested in embedded devices to be sure that works.

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

No branches or pull requests

2 participants