sio

package module
v0.0.0-...-4e608b7 Latest Latest
Warning

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

Go to latest
Published: May 11, 2025 License: MIT Imports: 5 Imported by: 0

README

Package sio lets you access old serial junk. It's a go-gettable fork and modification of dustin's rs232 package.

Install: $ go get github.com/schleibinger/sio

Online godocs are hosted at go.pkgdoc.org.

Documentation

Overview

Package sio supports communication using a serial port. Currently works only on Linux. Cgo is not used.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Addr

type Addr interface {
	Network() string // name of the network
	String() string  // string form of address
}

Addr represents a network end point address.

type FlowControlSettings

type FlowControlSettings struct {
	RS485Params RS485Params
	EnableRTS   bool
	EnableCTS   bool
	EnableDTR   bool
	EnableDSR   bool
}

type Port

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

func Open

func Open(dev string, rate uint32) (p *Port, err error)

Open returns a Port implementing net.Conn or an error if any. The Port behavior is like of the merged returns of net.DialTCP and net.ListenTCP.Accept, i.e. the net.Conn represents a bidirectional byte stream. The only supported mode ATM is 8N1. The serial line is put into raw mode (e.g. no HW nor XON/XOFF flow control).

Ex.: sio.Open("/dev/ttyS0", syscall.B115200)

func OpenWithTimeout

func OpenWithTimeout(dev string, rate uint32, readTimeout time.Duration, fcs FlowControlSettings) (p *Port, err error)

OpenWithTimeout works like Open but sets a timeout for Read() operations. Set the timeout to 0 for non-blocking operation.

func (*Port) Close

func (p *Port) Close() error

Implementation of net.Conn

func (*Port) Flush

func (p *Port) Flush() error

func (*Port) GetCTS

func (p *Port) GetCTS() (on bool, err error)

GetCTS return the state of p's CTS or an error if any. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) GetDSR

func (p *Port) GetDSR() (on bool, err error)

GetDSR return the state of p's DSR or an error if any. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) GetDTR

func (p *Port) GetDTR() (on bool, err error)

GetDTR return the state of p's DTR or an error if any. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) GetRTS

func (p *Port) GetRTS() (on bool, err error)

GetRTS return the state of p's RTS or an error if any. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) LocalAddr

func (p *Port) LocalAddr() Addr

Implementation of net.Conn

func (*Port) Read

func (p *Port) Read(b []byte) (n int, err error)

Implementation of net.Conn

func (*Port) RemoteAddr

func (p *Port) RemoteAddr() Addr

Implementation of net.Conn

func (*Port) SetCTS

func (p *Port) SetCTS(on bool) error

SetCTS sets the state of p's CTS to `on`. A non nil error is returned on failure. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) SetDSR

func (p *Port) SetDSR(on bool) error

SetDSR sets the state of p's DSR to `on`. A non nil error is returned on failure. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) SetDTR

func (p *Port) SetDTR(on bool) error

SetDTR sets the state of p's DTR to `on`. A non nil error is returned on failure. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) SetDeadline

func (p *Port) SetDeadline(t time.Time) error

Implementation of net.Conn

func (*Port) SetRTS

func (p *Port) SetRTS(on bool) error

SetRTS sets the state of p's RTS to `on`. A non nil error is returned on failure. Depending on the setup this signal may have the opposite direction than expected. In such case this function should not be used.

func (*Port) SetReadDeadline

func (p *Port) SetReadDeadline(t time.Time) error

Implementation of net.Conn

func (*Port) SetWriteDeadline

func (p *Port) SetWriteDeadline(t time.Time) error

Implementation of net.Conn

func (*Port) Sync

func (p *Port) Sync() error

func (*Port) Write

func (p *Port) Write(b []byte) (n int, err error)

Implementation of net.Conn

type RS485Params

type RS485Params struct {
	ENABLED               bool
	RTS_ON_SEND           bool
	RTS_AFTER_SEND        bool
	RX_DURING_TX          bool
	TERMINATE_BUS         bool
	ADDRB                 bool
	ADDR_RECV             bool
	ADDR_DEST             bool
	MODE_RS422            bool
	DELAY_RTS_BEFORE_SEND uint32
	DELAY_RTS_AFTER_SEND  uint32
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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