FlySerials

package
v0.0.0-...-741ab34 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FlyBuffer

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

func (*FlyBuffer) Bytes

func (b *FlyBuffer) Bytes() []byte

func (*FlyBuffer) Cap

func (b *FlyBuffer) Cap() int

func (*FlyBuffer) Grow

func (b *FlyBuffer) Grow(n int)

func (*FlyBuffer) Len

func (b *FlyBuffer) Len() int

func (*FlyBuffer) Next

func (b *FlyBuffer) Next(n int) []byte

func (*FlyBuffer) Read

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

func (*FlyBuffer) ReadByte

func (b *FlyBuffer) ReadByte() (c byte, err error)

func (*FlyBuffer) ReadBytes

func (b *FlyBuffer) ReadBytes(delim byte) (line []byte, err error)

func (*FlyBuffer) ReadFrom

func (b *FlyBuffer) ReadFrom(r io.Reader) (n int64, err error)

func (*FlyBuffer) ReadRune

func (b *FlyBuffer) ReadRune() (r rune, size int, err error)

func (*FlyBuffer) ReadString

func (b *FlyBuffer) ReadString(delim byte) (line string, err error)

func (*FlyBuffer) Reset

func (b *FlyBuffer) Reset()

func (*FlyBuffer) String

func (b *FlyBuffer) String() string

func (*FlyBuffer) Truncate

func (b *FlyBuffer) Truncate(n int)

func (*FlyBuffer) UnreadByte

func (b *FlyBuffer) UnreadByte() error

func (*FlyBuffer) UnreadRune

func (b *FlyBuffer) UnreadRune() error

func (*FlyBuffer) Write

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

func (*FlyBuffer) WriteByte

func (b *FlyBuffer) WriteByte(c byte) error

func (*FlyBuffer) WriteRune

func (b *FlyBuffer) WriteRune(r rune) (n int, err error)

func (*FlyBuffer) WriteString

func (b *FlyBuffer) WriteString(s string) (n int, err error)

func (*FlyBuffer) WriteTo

func (b *FlyBuffer) WriteTo(w io.Writer) (n int64, err error)

type FlySerial

type FlySerial struct {
	Settings *FlySerialSettings

	Port io.ReadWriteCloser

	IsOpen bool
	Buffer FlyBuffer

	Ready bool
	// contains filtered or unexported fields
}

func NewFlySerial

func NewFlySerial() *FlySerial

func (*FlySerial) ClearBuffer

func (serial *FlySerial) ClearBuffer()

清空接收缓冲区

func (*FlySerial) Close

func (serial *FlySerial) Close() error

关闭

func (*FlySerial) GetName

func (serial *FlySerial) GetName() string

获取串口配置名称

func (*FlySerial) OnData

func (serial *FlySerial) OnData(cb func([]byte))

接收到数据回调

func (*FlySerial) OnErr

func (serial *FlySerial) OnErr(cb func(err interface{}))

错误回调

func (*FlySerial) Open

func (serial *FlySerial) Open(settings *FlySerialSettings) (io.ReadWriteCloser, error)

打开串口

func (*FlySerial) Print

func (serial *FlySerial) Print(data string) (int, error)

写数据

func (*FlySerial) Println

func (serial *FlySerial) Println(data string) (int, error)

写一行数据

func (*FlySerial) Read

func (serial *FlySerial) Read(p []byte) (int, error)

读数据

func (*FlySerial) ReadLine

func (serial *FlySerial) ReadLine(delim byte, delay_ms int64, timeout_ms int64) ([]byte, error)

读一行数据,遇到delim分隔符或者距离最后一次收到数据delay_ms毫秒后,返回读到的数据,或者等到超时,返回读到的数据

func (*FlySerial) ReadLineString

func (serial *FlySerial) ReadLineString(delim byte, delay_ms int64, timeout_ms int64) (string, error)

读一行数据,返回字符串

func (*FlySerial) Write

func (serial *FlySerial) Write(data []byte) (int, error)

写数据

type FlySerialSettings

type FlySerialSettings struct {
	Enable     bool
	ConfigType string
	ConfigKey  string
	Debug      bool

	Port                  string
	BaudRate              uint
	DataBits              uint
	ParityMode            string
	StopBits              uint
	MinimumReadSize       uint
	InterCharacterTimeout uint
	LoopDisable           bool

	Ready bool
}

func NewFlySerialSettings

func NewFlySerialSettings() *FlySerialSettings

func (*FlySerialSettings) LoadIni

func (s *FlySerialSettings) LoadIni(config *FlyConfigFile.FlyIni, key string) error

从ini加载配置信息

Jump to

Keyboard shortcuts

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