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

Serial Interface Update Question #18

Open
schmidtw opened this issue Oct 2, 2022 · 4 comments
Open

Serial Interface Update Question #18

schmidtw opened this issue Oct 2, 2022 · 4 comments

Comments

@schmidtw
Copy link

schmidtw commented Oct 2, 2022

The serial port sub-system was mentioned as one that you're ok bringing in other implementations.

I'm presently using this one as the basis for a ds2480 1-wire chip: https://github.com/bugst/go-serial. Based on my searching this seems to be the best cross-platform, no cgo version around.

I'm curious how you envision supporting other impls. I think the conn.Conn interface works for most simple serial devices, but the Connect() function may not be enough to support devices like a ds2480, where uart focused changes need to happen on the fly.

If there is a set of interfaces that are the right ones for implementing as external serial port adapters, then it will be pretty easy to write a small adapter library. The adapter can be external to the host project (like periph/bugst-serial-adapter) that can adapt the two & allow for the drivers & that logic to live in periph/drivers.

I'm happy to do the coding for these two things (ds2480 and the bugst/go-serial bridge) as long as I know what you want it to look like & you're cool with the approach.

@maruel
Copy link
Member

maruel commented Oct 3, 2022

You mention Connect, you mean https://pkg.go.dev/periph.io/x/conn/v3/uart#Port ? I'm confused because you refer to 1-wire but the 1-wire API doesn't have a Connect() function; https://pkg.go.dev/periph.io/x/conn/v3/onewire

This is because UART is a Port, and 1-wire is a Bus.

@schmidtw
Copy link
Author

schmidtw commented Oct 3, 2022

Sorry for the confusion. I'll try to clarify.

I am interested in doing is bringing support in for the ds2480 chip (serial <-> 1-wire adapter chip). For our purposes, only the serial side of the chip is of concern.

I looked at the Port interface but it doesn't seem flexible enough to support the ds2480 chip for a few reasons:

  1. The baud rate needs to change after the connection is made.
  2. Input and output buffers need be able to be flushed.
  3. All the control pins aren't available.
  4. Hardware level timeouts aren't available.

This interface: https://pkg.go.dev/go.bug.st/serial#pkg-types does a pretty good job of showing the different features a serial interface needs. Specifically, the methods I am using from that interface that don't appear to have equivalents are:

  • SetMode() - unless the uart Port.Connect() will allow for changes without connection interruption.
  • ResetInputBuffer()
  • ResetOutputBuffer()
  • SetReadTimeout()

The ds2480 driver code needs to change the serial port to operate & needs an interface to be portable to all the supported serial implementations.

@maruel
Copy link
Member

maruel commented Oct 4, 2022

Oh ok so it would work over UART instead of I2C like https://pkg.go.dev/periph.io/x/devices/v3/ds248x does?

@schmidtw
Copy link
Author

Yes, that's right. Sorry for the delay - I missed the update email & just saw your post.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants