com

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package com reads from COM port.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Baud is the configured baudrate of the serial port. It is set as command line parameter.
	Baud int

	// Verbose shows additional information if set true.
	Verbose bool
)

Functions

func GetSerialPorts

func GetSerialPorts() ([]string, error)

GetSerialPorts scans for serial ports.

Types

type COMport

type COMport interface {
	Open() bool
	Read(buf []byte) (int, error)
	Close() error
}

COMport is the comport interface type to use different COMports.

type PortGoBugSt

type PortGoBugSt struct {
	// contains filtered or unexported fields
}

PortGoBugSt is a serial device trice receiver

func NewCOMPortGoBugSt

func NewCOMPortGoBugSt(comPortName string) *PortGoBugSt

NewCOMPortGoBugSt creates an instance of a serial device type trice receiver

func (*PortGoBugSt) Close

func (p *PortGoBugSt) Close() error

Close releases port.

func (*PortGoBugSt) Open

func (p *PortGoBugSt) Open() bool

Open initializes the serial receiver.

It opens a serial port.

func (*PortGoBugSt) Read

func (p *PortGoBugSt) Read(buf []byte) (int, error)

Read blocks until (at least) one byte is received from the serial port or an error occurs. It stores data received from the serial port into the provided byte array buffer. The function returns the number of bytes read.

type PortTarm

type PortTarm struct {
	// contains filtered or unexported fields
}

PortTarm is a serial device trice receiver.

func NewCOMPortTarm

func NewCOMPortTarm(comPortName string) *PortTarm

NewCOMPortTarm creates an instance of a serial device type trice receiver.

func (*PortTarm) Close

func (p *PortTarm) Close() error

Close returns an error in case of failure.

func (*PortTarm) Open

func (p *PortTarm) Open() bool

Open returns true on successful operation.

func (*PortTarm) Read

func (p *PortTarm) Read(buf []byte) (int, error)

Read blocks until (at least) one byte is received from the serial port or an error occurs. It stores data received from the serial port into the provided byte array buffer. The function returns the number of bytes read.

Jump to

Keyboard shortcuts

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