serial

package
v0.0.0-...-99c0e08 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Serial)

func WithBufferMaxSize

func WithBufferMaxSize(size int) Option

设置缓冲区大小

func WithConnect

func WithConnect(conn string) Option

设置连接字符串

func WithReadBufferSize

func WithReadBufferSize(size int) Option

设置读取缓冲区的大小

type Serial

type Serial struct {
	ReadBufSize int //读取数据的缓冲区

	HaveRecv bool //是否开启数据接收线程
	// contains filtered or unexported fields
}

Serial 串口

func NewSerial

func NewSerial(opts ...Option) *Serial

func (*Serial) Close

func (m *Serial) Close() (err error)

Close 关闭

func (*Serial) Closed

func (m *Serial) Closed() bool

Closed 串口是否已经关闭

func (*Serial) Len

func (m *Serial) Len() int

Len 获取buf 数据的长度

func (*Serial) Open

func (m *Serial) Open() (err error)

Open 打开

func (*Serial) OptionString

func (m *Serial) OptionString() string

func (*Serial) Read

func (m *Serial) Read(p []byte) (n int, err error)

Read 读数据

func (*Serial) ReadTimeout

func (m *Serial) ReadTimeout(data []byte, timeout int) (num int, err error)

ReadTimeout 读取数据直到超时

func (*Serial) Reset

func (m *Serial) Reset()

Reset 清空数据

func (*Serial) Write

func (m *Serial) Write(p []byte) (n int, err error)

Write 写数据

Directories

Path Synopsis
* @Author: fuzhuang * @Date: 2023-12-11 09:23:21 * @LastEditTime: 2024-11-20 09:12:19 * @LastEditors: wangjun haodreams@163.com * @Description: * @FilePath: \golib\serialer\test\test.go
* @Author: fuzhuang * @Date: 2023-12-11 09:23:21 * @LastEditTime: 2024-11-20 09:12:19 * @LastEditors: wangjun haodreams@163.com * @Description: * @FilePath: \golib\serialer\test\test.go

Jump to

Keyboard shortcuts

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