serial

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

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

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

README

serial

README-zh

Table of Contents

Description

Serial Communication

Architecture

Software architecture description

Installation

  1. xxxx
  2. xxxx
  3. xxxx

Instructions

  1. xxxx
  2. xxxx
  3. xxxx

Contribution

  1. Fork the repository
  2. Create Feat_xxx branch
  3. Commit your code
  4. Create Pull Request

Feature

License

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 (
	// ErrBadDataBits is returned if DataBits is not supported.
	ErrBadDataBits error = errors.New("unsupported serial data bits")
	// 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 New

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

func Validate

func Validate(object interface{}, language string, translation bool) error

func ValidateNil

func ValidateNil(object interface{}) bool

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