ch912x

package module
v0.0.0-...-51176a3 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 13 Imported by: 0

README

CH912x

The program provides CH912x series chip configuration tools

Supported

Chip Name Status
CH9120 TESTED
CH9121 TESTED
CH9126 TESTED

Command line

References

LICENSE

MIT LICENSE, but not include docs folder

Documentation

Index

Constants

View Source
const (
	ProductCH9120         Product    = "CH9120"
	ProductCH9121         Product    = "CH9121"
	ProductCH9126         Product    = "CH9126"
	KindPushRequest       Kind       = 0x01
	KindPullRequest       Kind       = 0x02
	KindResetRequest      Kind       = 0x03
	KindDiscoveryRequest  Kind       = 0x04
	KindPushResponse      Kind       = 0x81
	KindPullResponse      Kind       = 0x82
	KindResetResponse     Kind       = 0x83
	KindDiscoveryResponse Kind       = 0x84
	TCPServer             UARTMode   = 0x00
	TCPClient             UARTMode   = 0x01
	UDPServer             UARTMode   = 0x02
	UDPClient             UARTMode   = 0x03
	ParityNone            UARTParity = 0x00
	ParityEven            UARTParity = 0x01
	ParityOdd             UARTParity = 0x02
	ParityMark            UARTParity = 0x03
	ParitySpace           UARTParity = 0x04
	NTPServer             NTPMode    = 0x00
	NTPClient             NTPMode    = 0x01
)

Variables

View Source
var (
	ErrInvalidNetworkInterface = errors.New("ch912x: invalid network interface")
	ErrCH9120InvalidJSON       = errors.New("ch912x: the JSON not is CH9120 configuration")
	ErrCH9121InvalidJSON       = errors.New("ch912x: the JSON not is CH9121 configuration")
	ErrCH9126InvalidJSON       = errors.New("ch912x: the JSON not is CH9126 configuration")
	ErrModuleKindWrong         = errors.New("ch912x: the module kind wrong")
	ErrModuleMustMAC           = errors.New("ch912x: the need to provide `ModuleMAC`")
	ErrTaskRunning             = errors.New("ch912x: the previous task was not completed")
	ErrUnknownModuleType       = errors.New("ch912x: unknown module type")
)

Functions

This section is empty.

Types

type CH9120

type CH9120 struct {
	Kind          Kind             `json:"-"`
	Version       string           `json:"version,omitempty"`
	ModuleName    string           `json:"module_name,omitempty"`
	ModuleMAC     net.HardwareAddr `json:"module_mac,omitempty"`
	ClientMAC     net.HardwareAddr `json:"client_mac,omitempty"`
	ModuleOptions *ModuleOptions   `json:"module_options,omitempty"`
	UART1         *UARTService     `json:"uart_1,omitempty"`
}

func (*CH9120) MarshalJSON

func (p *CH9120) MarshalJSON() ([]byte, error)

func (*CH9120) ReadFrom

func (p *CH9120) ReadFrom(r io.Reader) (n int64, err error)

func (*CH9120) UnmarshalJSON

func (p *CH9120) UnmarshalJSON(data []byte) (err error)

func (*CH9120) WriteTo

func (p *CH9120) WriteTo(w io.Writer) (n int64, err error)

type CH9121

type CH9121 struct {
	Kind          Kind             `json:"-"`
	Version       string           `json:"version,omitempty"`
	ModuleName    string           `json:"module_name,omitempty"`
	ModuleMAC     net.HardwareAddr `json:"module_mac,omitempty"`
	ClientMAC     net.HardwareAddr `json:"client_mac,omitempty"`
	ModuleOptions *ModuleOptions   `json:"module_options,omitempty"`
	UART1         *UARTService     `json:"uart_1,omitempty"`
	UART2         *UARTService     `json:"uart_2,omitempty"`
}

func (*CH9121) MarshalJSON

func (p *CH9121) MarshalJSON() ([]byte, error)

func (*CH9121) ReadFrom

func (p *CH9121) ReadFrom(r io.Reader) (n int64, err error)

func (*CH9121) UnmarshalJSON

func (p *CH9121) UnmarshalJSON(data []byte) (err error)

func (*CH9121) WriteTo

func (p *CH9121) WriteTo(w io.Writer) (n int64, err error)

type CH9126

type CH9126 struct {
	Kind          Kind             `json:"-"`
	Version       string           `json:"version,omitempty"`
	ModuleName    string           `json:"module_name,omitempty"`
	ModuleMAC     net.HardwareAddr `json:"module_mac,omitempty"`
	ClientMAC     net.HardwareAddr `json:"client_mac,omitempty"`
	ModuleOptions *ModuleOptions   `json:"module_options,omitempty"`
	UART1         *UARTService     `json:"uart_1,omitempty"`
	NTP           *NTPService      `json:"ntp,omitempty"`
}

func (*CH9126) MarshalJSON

func (p *CH9126) MarshalJSON() ([]byte, error)

func (*CH9126) ReadFrom

func (p *CH9126) ReadFrom(r io.Reader) (n int64, err error)

func (*CH9126) UnmarshalJSON

func (p *CH9126) UnmarshalJSON(data []byte) (err error)

func (*CH9126) WriteTo

func (p *CH9126) WriteTo(w io.Writer) (n int64, err error)

type ControlPlane

type ControlPlane struct {
	Timeout     time.Duration
	SendTimeout time.Duration
	// contains filtered or unexported fields
}

func ListenCH912X

func ListenCH912X(ifi *net.Interface) (plane *ControlPlane, err error)

func ListenCH912XByName

func ListenCH912XByName(name string) (*ControlPlane, error)

func (*ControlPlane) Close

func (p *ControlPlane) Close() (err error)

func (*ControlPlane) Discovery

func (p *ControlPlane) Discovery() <-chan Module

func (*ControlPlane) Pull

func (p *ControlPlane) Pull(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)

func (*ControlPlane) Push

func (p *ControlPlane) Push(ctx context.Context, module Module) (parsed Module, err error)

func (*ControlPlane) Reset

func (p *ControlPlane) Reset(ctx context.Context, product Product, address net.HardwareAddr) (module Module, err error)

func (*ControlPlane) SendDiscovery

func (p *ControlPlane) SendDiscovery(product Product) (err error)

type Kind

type Kind byte

type Module

type Module interface {
	io.ReaderFrom
	io.WriterTo
	// contains filtered or unexported methods
}

type ModuleOptions

type ModuleOptions struct {
	MAC              net.HardwareAddr `json:"mac,omitempty"`
	IP               net.IP           `json:"ip,omitempty"`
	Mask             net.IP           `json:"mask,omitempty"`
	Gateway          net.IP           `json:"gateway,omitempty"`
	UseDHCP          bool             `json:"use_dhcp,omitempty"`
	SerialNegotiate  bool             `json:"serial_negotiate,omitempty"`
	EnabledMinorUART bool             `json:"enabled_minor_uart,omitempty"`
}

type NTPMode

type NTPMode byte

type NTPService

type NTPService struct {
	Enabled     bool    `json:"enabled"`
	Mode        NTPMode `json:"mode"`
	ClientIP    net.IP  `json:"client_ip"`
	Polling     uint16  `json:"polling"`
	PulseOutput bool    `json:"pulse_output"`
	KeepAlive   bool    `json:"keep_alive"`
}

type Product

type Product string

type UARTMode

type UARTMode byte

type UARTParity

type UARTParity byte

type UARTService

type UARTService struct {
	Mode             UARTMode   `json:"mode"`
	ClientIP         net.IP     `json:"client_ip"`
	ClientPort       uint16     `json:"client_port"`
	ClientDomain     string     `json:"client_domain"`
	UseDomain        bool       `json:"use_domain"`
	LocalPort        uint16     `json:"local_port"`
	PacketSize       uint16     `json:"packet_size"`
	PacketTimeout    uint16     `json:"packet_timeout"`
	RandomClientPort bool       `json:"random_client_port,omitempty"`
	CloseOnLost      bool       `json:"close_on_lost"`
	ClearOnReconnect bool       `json:"clear_on_reconnect"`
	Baud             uint32     `json:"baud"`
	DataBits         uint8      `json:"data_bits"`
	StopBit          uint8      `json:"stop_bit"`
	Parity           UARTParity `json:"parity"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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