Documentation
¶
Overview ¶
Package serial 实现 serial binder:串口连接、读写、重置。
Index ¶
- type LangProvider
- type Serial
- func (s *Serial) Cleanup()
- func (s *Serial) ConnectSerialAsync(req SerialConnectRequest) (string, error)
- func (s *Serial) DisconnectSerial(sessionID string)
- func (s *Serial) ListSerialPorts() ([]serial_svc.SerialPortInfo, error)
- func (s *Serial) ResizeSerialTerminal(sessionID string, cols int, rows int) error
- func (s *Serial) Startup(ctx context.Context)
- func (s *Serial) WriteSerial(sessionID string, dataB64 string) error
- type SerialConnectEvent
- type SerialConnectRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
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) ConnectSerialAsync ¶
func (s *Serial) ConnectSerialAsync(req SerialConnectRequest) (string, error)
ConnectSerialAsync 异步打开串口连接,立即返回 connectionId
func (*Serial) DisconnectSerial ¶
DisconnectSerial 断开串口连接
func (*Serial) ListSerialPorts ¶
func (s *Serial) ListSerialPorts() ([]serial_svc.SerialPortInfo, error)
ListSerialPorts 列出系统可用串口
func (*Serial) ResizeSerialTerminal ¶
ResizeSerialTerminal 调整串口终端尺寸(当前为 no-op,仅保持前后端接口一致)。
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 前端串口连接请求
Click to show internal directories.
Click to hide internal directories.