gao_serial

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

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

Go to latest
Published: May 15, 2019 License: MIT Imports: 15 Imported by: 0

README

gao_serial

just A messy operation of serial

Documentation

Index

Constants

View Source
const InvalidString = "<invalid convert>"

Variables

View Source
var (
	//AT check a equipment whether has at response
	AT = "AT\r"
	//ATZ init equipment configure
	ATZ       = "ATZ\r"
	ECHOCLOSE = "ATE0\r"
	ECHOOPEN  = "ATE1\r"
	//IME is international mobile equipment identity
	IME = "AT+CGSN\r"
	//CSQ is signal intensity of equipment
	CSQ = "AT+CSQ\r"
	//NETWORK is mobile equipment network situation
	NETWORK = "AT+CREG?\r"
)

Functions

func BytesString

func BytesString(b []byte) string

func CheckAT

func CheckAT(gs *GaoSerial) error

func CheckATZ

func CheckATZ(gs *GaoSerial) error

func ConvInt64

func ConvInt64(jsonItf interface{}) int64

func ConvString

func ConvString(jsonItf interface{}) string

func DeepCopy

func DeepCopy(dst, src interface{}) error

DeepCopy 深度拷贝对象

func DoFlateCompress

func DoFlateCompress(src []byte) ([]byte, error)

func DoFlateUnCompress

func DoFlateUnCompress(compressSrc []byte) ([]byte, error)

func GetCSQ

func GetCSQ(gs *GaoSerial) (string, error)

GetCSQ get csq from equipment

func GetCurrentDir

func GetCurrentDir() string

func GetIMEI

func GetIMEI(gs *GaoSerial) (string, error)

GetIMEI get IME from equipment

func GetNetWork

func GetNetWork(gs *GaoSerial) (string, error)

GetNetWork return equipment network register situation

func PathExists

func PathExists(path string) (bool, error)

func SetEchoClose

func SetEchoClose(gs *GaoSerial) error

SetEchoClose close equipment echo

func StrToMap

func StrToMap(s string) (map[string]string, error)

func StringBytes

func StringBytes(s string) (b []byte)

Types

type ErrPortBlock

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

func (ErrPortBlock) Error

func (e ErrPortBlock) Error() string

type GaoSerial

type GaoSerial struct {
	Com      string
	Bandrate int
	// contains filtered or unexported fields
}

func NewGaoSerial

func NewGaoSerial(blockTimeout time.Duration) *GaoSerial

func (*GaoSerial) Close

func (gs *GaoSerial) Close() error

func (*GaoSerial) Open

func (gs *GaoSerial) Open(com string, bandrate int) error

func (*GaoSerial) Read

func (gs *GaoSerial) Read(timeout time.Duration) ([]byte, error)

Read read data from port, use timeout, or encounter error return

func (*GaoSerial) SetReadTimeout

func (gs *GaoSerial) SetReadTimeout(timeout time.Duration) error

func (*GaoSerial) Write

func (gs *GaoSerial) Write(b []byte) (int, error)

Write write data to port

func (*GaoSerial) WriteAndRead

func (gs *GaoSerial) WriteAndRead(b []byte, wrInterval, readTimeout time.Duration) ([]byte, error)

WriteAndRead write data and receive response wrInterval is time interval between write and read readTimeout is time read data

func (*GaoSerial) WriteAndReadLines

func (gs *GaoSerial) WriteAndReadLines(b []byte, wrInterval, readTimeout time.Duration) ([][]byte, error)

WriteAndReadLines return receive response split by lines and filter empty lines

Jump to

Keyboard shortcuts

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