tinygo-org / tinygo

Go compiler for small places. Microcontrollers, WebAssembly (WASM/WASI), and command-line tools. Based on LLVM.
https://tinygo.org
Other
15.23k stars 898 forks source link

UART for nrf targets does not implement `machine.Serialer` #3990

Open bgould opened 10 months ago

bgould commented 10 months ago

This function procedure is incompatible with the machine.Serialer interface:

https://github.com/tinygo-org/tinygo/blob/2b215955cac75b1308d02269b8ea5b73448708a9/src/machine/machine_nrf.go#L174

When compiling with -serial=uart, compilation fails when attempting to use machine.Serial as a machine.Serialer like:

cannot use machine.Serial (variable of type *machine.UART) as machine.Serialer value in struct literal: *machine.UART does not implement machine.Serialer (wrong type for method Configure)
                have Configure(machine.UARTConfig)
                want Configure(machine.UARTConfig) error
bgould commented 10 months ago

Upon further investigation ... it appears machine.Serialer is protected by build tags in src/machine/usb.go ... so maybe isn't intended for UART to implement it? Unless there is some detail I'm missing, I think that UART should implement machine.Serialer.

sago35 commented 10 months ago

The machine.Serialer interface, if I recall correctly, was introduced for the purpose of tidying up implementations such as -serial=uart. Therefore, it probably does not take into account environments without USB support.

As you are writing, I believe UART should implement machine.Serialer.