serial

package module
v0.0.0-...-f72f88a Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: AGPL-3.0 Imports: 2 Imported by: 0

README

serial

Translation

目录

项目介绍

串口通讯

软件架构

软件架构说明

https://github.com/tarm/serial https://github.com/goburrow/serial https://github.com/jacobsa/go-serial

安装教程

  1. xxxx
  2. xxxx
  3. xxxx

使用说明

  1. xxxx
  2. xxxx
  3. xxxx

参与贡献

  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request

功能实现

开源协议

GNU © kokutas

Documentation

Index

Constants

View Source
const (
	DEFAULT_BAUD_RATE uint     = 9600        // 默认波特率
	DEFAULT_PARITY    Parity   = PARITY_NONE // 默认校验位
	DEFAULT_DATA_BITS uint8    = 8           // 默认数据位
	DEFAULT_STOP_BITS StopBits = STOP_ONE    // 默认停止位
)

默认值

Variables

View Source
var (
	// ErrBadSize is returned if Size is not supported.
	ErrBadSize error = errors.New("unsupported serial data size")
	// ErrBadStopBits is returned if the specified StopBits setting not supported.
	ErrBadStopBits error = errors.New("unsupported stop bit setting")
	// ErrBadParity is returned if the parity is not supported.
	ErrBadParity error = errors.New("unsupported parity setting")
)

Functions

func NewRS485

func NewRS485(enable bool, delayRtsBeforeSend time.Duration, delayRtsAfterSend time.Duration, rtsHighDuringSend bool, rtsHighAfterSend bool, rxDuringTx bool) *rs485

func NewSerial

func NewSerial(address string, baudRate uint, dataBits uint8, stopBits StopBits, parity Parity, timeout time.Duration, rs485 *rs485) *serial

Types

type Parity

type Parity byte

校验位类型

const (
	PARITY_NONE  Parity = 'N' // 无校验(NONE): 没有校验位
	PARITY_ODD   Parity = 'O' // 奇偶校验位-奇校验(ODD): 让传输的数据(包含校验位)中1的个数为奇数;如果传输字节中1的个数是偶数,则校验位为"1",奇数相反.
	PARITY_EVEN  Parity = 'E' // 奇偶校验位-偶校验(EVEN): 让传输的数据(包含校验位)中1的个数为偶数;如果传输字节中1的个数是偶数,则校验位为"0",奇数相反。
	PARITY_MARK  Parity = 'M' // 固定校验位(Stick)-1校验(MARK): 校验位总为1
	PARITY_SPACE Parity = 'S' // 固定校验位(Stick)-0校验(SPACE): 校验位总为0
)

校验位常量

type StopBits

type StopBits byte

停止位类型

const (
	STOP_ONE      StopBits = 1
	STOP_ONE_HALF StopBits = 15 // 1.5
	STOP_TWO      StopBits = 2
)

停止位常量

Jump to

Keyboard shortcuts

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