serialutils

package
v0.35.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 19, 2024 License: GPL-3.0 Imports: 7 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Reset

func Reset(portToTouch string, wait bool, cb *ResetProgressCallbacks, dryRun bool) (string, error)

Reset a board using the 1200 bps port-touch and wait for new ports. Both reset and wait are optional: - if port is "" touch will be skipped - if wait is false waiting will be skipped If wait is true, this function will wait for a new port to appear and returns that one, otherwise the empty string is returned if the new port can not be detected or if the wait parameter is false. If dryRun is set to true this function will only emulate the port reset without actually performing it, this is useful to mockup for unit-testing and CI. In dryRun mode if the `portToTouch` ends with `"999"` and wait is true, Reset will return a new "bootloader" port as `portToTouch+"0"`. The error is set if the port listing fails.

func TouchSerialPortAt1200bps

func TouchSerialPortAt1200bps(port string) error

TouchSerialPortAt1200bps open and close the serial port at 1200 bps. This is used on many Arduino boards as a signal to put the board in "bootloader" mode.

Types

type ResetProgressCallbacks

type ResetProgressCallbacks struct {
	// TouchingPort is called to signal the 1200-bps touch of the reported port
	TouchingPort func(port string)
	// WaitingForNewSerial is called to signal that we are waiting for a new port
	WaitingForNewSerial func()
	// BootloaderPortFound is called to signal that the wait is completed and to
	// report the port found, or the empty string if no ports have been found and
	// the wait has timed-out.
	BootloaderPortFound func(port string)
	// Debug reports messages useful for debugging purposes. In normal conditions
	// these messages should not be displayed to the user.
	Debug func(msg string)
}

ResetProgressCallbacks is a struct that defines a bunch of function callback to observe the Reset function progress.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL