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

Is it possible to create an UART adapter? #162

Open
MGlolenstine opened this issue Jun 30, 2023 · 3 comments
Open

Is it possible to create an UART adapter? #162

MGlolenstine opened this issue Jun 30, 2023 · 3 comments

Comments

@MGlolenstine
Copy link

MGlolenstine commented Jun 30, 2023

I've tried looking into making a custom adapter, but the ConnectionInfo requires SocketAddr which only supports IPv4 and IPv6, which UART doesn't have.

Would it be possible to implement connect_with without having to specify an IP address?

I've looked around for a bit and I think that one of the actions I could take, is to fork it and add COM/TTY support to ConnectionInfo and RemoteAddr.

EDIT: I know that the point of this library is networking, but I like the design and I thought it would make my interfacing with UART easier.

@lemunozm
Copy link
Owner

lemunozm commented Jul 3, 2023

Hi @MGlolenstine, glad to hear you're creating a UART adapter. I like the idea 🙌🏻.

Sure it would need some kind of refactoring/redesign. I think the first question is, how to identify UARTs connections?

The SocketAddr returned by connect_with ends up in the Endpoint type used everywhere. I think the first change will be to allow the Endpoint type to hold several kinds of connections:

pub enum Addr {
    Network(SocketAddr),
    Device(/* UART addr here*/ )
}

pub struct Endpoint {
    resource_id: ResourceId,
    addr: Addr,
}

Then, you can now return an Addr::Device() from the connect_with() function. WDYT?

@MGlolenstine
Copy link
Author

I have to admit that I've only barely scratched the surface of the library, and the above ideas I've gotten from the documentation (which is excellent, by the way).
Your idea will probably be much better than what I had, and I'll take a look later today and see if I can create a nice abstraction :)

Thank you!

@lemunozm
Copy link
Owner

lemunozm commented Jul 3, 2023

Great! and any suggestion or other idea you feel fits better is welcome!

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