periph / host

Go·Hardware·Lean - Host drivers
https://periph.io
Apache License 2.0
53 stars 27 forks source link

serial: Fix serial so it can be used #16

Closed adev73 closed 1 year ago

adev73 commented 1 year ago

This PR fixes a problem with the Serial port implementation, whereby:

  1. It was not possible to correctly instantiate a serial port object
  2. Read/Write methods were unreachable as implemented on private "conn" property of Port, and not exposed via conn.Conn interface

Please note: This is a "bare minimum" set of changes, to allow me to use periph.io's serial capabilities. It currently ONLY works on Linux machines, and it only works if you have ttySerialX type ports symlinked in your /dev folder.

Yet TODO: Implement it for Windows. Improve to address Manuel's TODOs. Allow other /dev/ttyX types to be treated as serial ports. Better error handling. Loads...

adev73 commented 1 year ago

Oops, this went into the wrong repo!

maruel commented 1 year ago

I'm currently travelling, will be able to provide more timely comments later next week. If you want to test a local fork you can use the replace go.mod directive. https://go.dev/ref/mod#go-mod-file-replace No need to rename all imports.

adev73 commented 1 year ago

Hi Maurel - no rush... I'm using a bodged version in another project right now; I'd probably want to discuss with you how Serial should behave before I did a "proper" fork/code/test/pr cycle - this is the first time I've used a github PR for a forked repo & didn't spot (in time) that it PR'd back to the original repo & not my fork!

I've renamed the imports in my version just so I can mess about with it more easily; when we do this for real I will definitely use the replace directive.

Cheers, Ade.