blclient

package
v0.0.0-...-2fa4403 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidResponse      = errors.New("invalid response")
	ErrInvalidBootHeader    = errors.New("invalid boot header")
	ErrInvalidSegmentHeader = errors.New("invalid segment header")
)

Functions

func ParseError

func ParseError(data []byte) error

Types

type BLClient

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

func Dial

func Dial(portName string, opts ...BLClientOption) (*BLClient, error)

func (*BLClient) CheckImage

func (blc *BLClient) CheckImage() error

func (*BLClient) Close

func (blc *BLClient) Close() error

func (*BLClient) Command

func (blc *BLClient) Command(data []byte, length int) ([]byte, error)

func (*BLClient) GetBootInfo

func (blc *BLClient) GetBootInfo() ([]byte, error)

func (*BLClient) Handshake

func (blc *BLClient) Handshake() error

func (*BLClient) LoadBootHeader

func (blc *BLClient) LoadBootHeader(r io.Reader) (n int, err error)

func (*BLClient) LoadSegmentData

func (blc *BLClient) LoadSegmentData(r io.Reader) (n int, err error)

func (*BLClient) LoadSegmentHeader

func (blc *BLClient) LoadSegmentHeader(r io.Reader) (n int, err error)

func (*BLClient) Read

func (blc *BLClient) Read(length int) ([]byte, error)

func (*BLClient) ReadJedecId

func (blc *BLClient) ReadJedecId() ([]byte, error)

func (*BLClient) ResetDevice

func (blc *BLClient) ResetDevice() error

func (*BLClient) RunImage

func (blc *BLClient) RunImage() error

func (*BLClient) TryCommand

func (blc *BLClient) TryCommand(data []byte, length int) (b []byte, err error)

func (*BLClient) Write

func (blc *BLClient) Write(data []byte) (err error)

type BLClientOption

type BLClientOption interface {
	Apply(blc *BLClient)
}

func WithBaudRate

func WithBaudRate(baudrate int) BLClientOption

func WithLogger

func WithLogger(l *zap.SugaredLogger) BLClientOption

func WithReadBufferSize

func WithReadBufferSize(n int) BLClientOption

func WithReadTimeout

func WithReadTimeout(n int) BLClientOption

func WithWriteTimeout

func WithWriteTimeout(n int) BLClientOption

type BLClientOptionFunc

type BLClientOptionFunc func(blc *BLClient)

func (BLClientOptionFunc) Apply

func (fn BLClientOptionFunc) Apply(blc *BLClient)

type BlfbResponseError

type BlfbResponseError[T ~uint8] interface {
	error
	fmt.Stringer
	Code() T
}

type ErrCodeCmd

type ErrCodeCmd uint8
const (
	ERR_CMD_ID_ERROR ErrCodeCmd = iota + 1
	ERR_CMD_LEN_ERROR
	ERR_CMD_CRC_ERROR
	ERR_CMD_SEQ_ERROR
)

cmd

type ErrCodeFlash

type ErrCodeFlash uint8
const (
	ERR_FLASH_INIT_ERROR ErrCodeFlash = iota + 1
	ERR_FLASH_ERASE_PARA_ERROR
	ERR_FLASH_ERASE_ERROR
	ERR_FLASH_WRITE_PARA_ERROR
	ERR_FLASH_WRITE_ADDR_ERROR
	ERR_FLASH_WRITE_ERROR
	ERR_FLASH_BOOT_PARA_ERROR
	ERR_FLASH_SET_PARA_ERROR
	ERR_FLASH_READ_STATUS_REG_ERROR
	ERR_FLASH_WRITE_STATUS_REG_ERROR
)

flash

type ErrCodeIF

type ErrCodeIF uint8
const (
	ERR_IF_RATE_LEN_ERROR ErrCodeIF = iota + 1
	ERR_IF_RATE_PARA_ERROR
	ERR_IF_PASSWORDERROR
	ERR_IF_PASSWORDCLOSE
)

IF

type ErrCodeImage

type ErrCodeImage uint8
const (
	ERR_IMG_BOOTHEADER_LEN_ERROR ErrCodeImage = iota + 1
	ERR_IMG_BOOTHEADER_NOT_LOAD_ERROR
	ERR_IMG_BOOTHEADER_MAGIC_ERROR
	ERR_IMG_BOOTHEADER_CRC_ERROR
	ERR_IMG_BOOTHEADER_ENCRYPT_NOTFIT
	ERR_IMG_BOOTHEADER_SIGN_NOTFIT
	ERR_IMG_SEGMENT_CNT_ERROR
	ERR_IMG_AES_IV_LEN_ERROR
	ERR_IMG_AES_IV_CRC_ERROR
	ERR_IMG_PK_LEN_ERROR
	ERR_IMG_PK_CRC_ERROR
	ERR_IMG_PK_HASH_ERROR
	ERR_IMG_SIGNATURE_LEN_ERROR
	ERR_IMG_SIGNATURE_CRC_ERROR
	ERR_IMG_SECTIONHEADER_LEN_ERROR
	ERR_IMG_SECTIONHEADER_CRC_ERROR
	ERR_IMG_SECTIONHEADER_DST_ERROR
	ERR_IMG_SECTIONDATA_LEN_ERROR
	ERR_IMG_SECTIONDATA_DEC_ERROR
	ERR_IMG_SECTIONDATA_TLEN_ERROR
	ERR_IMG_SECTIONDATA_CRC_ERROR
	ERR_IMG_HALFBAKED_ERROR
	ERR_IMG_HASH_ERROR
	ERR_IMG_SIGN_PARSE_ERROR
	ERR_IMG_SIGN_ERROR
	ERR_IMG_DEC_ERROR
	ERR_IMG_ALL_INVALID_ERROR
)

image

type ErrCodeMisc

type ErrCodeMisc uint8
const (
	ERR_PLL_ERROR ErrCodeMisc = iota + 252
	ERR_INVASION_ERROR
	ERR_POLLING
	ERR_FAIL
)

MISC

type ErrType

type ErrType uint8
const (
	ERR_FLASH ErrType = 0x00
	ERR_CMD   ErrType = 0x01
	ERR_IMAGE ErrType = 0x02
	ERR_IF    ErrType = 0x03
	ERR_MISC  ErrType = 0xFF
)

Jump to

Keyboard shortcuts

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