serial

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Overview

Package serial 实现 serial binder:串口连接、读写、重置。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LangProvider

type LangProvider interface {
	Lang() string
}

LangProvider 由 system binder 实现。

type Serial

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

Serial binder。

func New

func New(appCtx context.Context, lang LangProvider, mgr *serial_svc.Manager) *Serial

New 构造 serial binder。

func (*Serial) Cleanup

func (s *Serial) Cleanup()

Cleanup 关闭所有串口。

func (*Serial) ConnectSerialAsync

func (s *Serial) ConnectSerialAsync(req SerialConnectRequest) (string, error)

ConnectSerialAsync 异步打开串口连接,立即返回 connectionId

func (*Serial) DisconnectSerial

func (s *Serial) DisconnectSerial(sessionID string)

DisconnectSerial 断开串口连接

func (*Serial) ListSerialPorts

func (s *Serial) ListSerialPorts() ([]serial_svc.SerialPortInfo, error)

ListSerialPorts 列出系统可用串口

func (*Serial) ResizeSerialTerminal

func (s *Serial) ResizeSerialTerminal(sessionID string, cols int, rows int) error

ResizeSerialTerminal 调整串口终端尺寸(当前为 no-op,仅保持前后端接口一致)。

func (*Serial) Startup

func (s *Serial) Startup(ctx context.Context)

Startup 保存 Wails ctx。

func (*Serial) WriteSerial

func (s *Serial) WriteSerial(sessionID string, dataB64 string) error

WriteSerial 向串口终端写入数据(base64 编码)

type SerialConnectEvent

type SerialConnectEvent struct {
	Type      string `json:"type"`                // "progress" | "connected" | "error"
	Step      string `json:"step,omitempty"`      // "open"
	Message   string `json:"message,omitempty"`   // 进度消息
	SessionID string `json:"sessionId,omitempty"` // type=connected 时返回的会话ID
	Error     string `json:"error,omitempty"`     // type=error 时的错误信息
}

SerialConnectEvent 串口异步连接事件

type SerialConnectRequest

type SerialConnectRequest struct {
	AssetID int64 `json:"assetId"`
}

SerialConnectRequest 前端串口连接请求

Jump to

Keyboard shortcuts

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