hwportmanager

package
v0.6.7 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: AGPL-3.0 Imports: 7 Imported by: 0

README

硬件接口管理器

类似windows下的“设备管理器”,统一管理硬件接口。

警告:此处会随着硬件不同而不兼容,要移植的时候记得统一一下目标硬件的端口

Documentation

Overview

* * RhinoPi 硬件接口相关管理 * 警告:此处会随着硬件不同而不兼容,要移植的时候记得统一一下目标硬件的端口 *

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckSerialBusy added in v0.6.7

func CheckSerialBusy(serialDevice string) error

检查串口设备是否被系统进程占用

func FreeInterfaceBusy

func FreeInterfaceBusy(name string)

* * 释放 *

func RefreshPort

func RefreshPort(Port RhinoH3HwPort)

func SetHwPort

func SetHwPort(Port RhinoH3HwPort)

* * 加载配置到运行时, 需要刷新与配置相关的所有设备 *

func SetInterfaceBusy

func SetInterfaceBusy(name string, OccupyBy HwPortOccupy)

* * 忙碌 *

Types

type HardwarePort added in v0.6.7

type HardwarePort struct {
	UUID        int64  `json:"uuid"`        // ID
	Name        string `json:"name"`        // 名称
	Alias       string `json:"alias"`       // 别名
	Type        string `json:"type"`        // 类型,主要有 USER、SYSTEM两种
	Path        string `json:"path"`        // 路径
	Description string `json:"description"` // 额外信息
}

* * 硬件设备上的端口 *

type HardwarePortClass added in v0.6.7

type HardwarePortClass struct {
	Audio HardwarePort `json:"audio"`
	Can   HardwarePort `json:"can"`
	Di    HardwarePort `json:"di"`
	Do    HardwarePort `json:"do"`
	Hdmi  HardwarePort `json:"hdmi"`
	Ir    HardwarePort `json:"ir"`
	Relay HardwarePort `json:"relay"`
	Rs232 HardwarePort `json:"rs232"`
	Rs485 HardwarePort `json:"rs485"`
	Uart  HardwarePort `json:"uart"`
	Video HardwarePort `json:"video"`
}

* * 统一管理不同型号设备的硬件端口 *

type HwPortOccupy

type HwPortOccupy struct {
	UUID string `json:"uuid"` // UUID
	Type string `json:"type"` // DEVICE, OS,... Other......
	Name string `json:"name"` // 占用的设备名称
}

type HwPortsManager

type HwPortsManager struct {
	Interfaces sync.Map
	// contains filtered or unexported fields
}

func InitHwPortsManager

func InitHwPortsManager(rulex typex.RuleX) *HwPortsManager

type RhinoH3HwPort

type RhinoH3HwPort struct {
	UUID        string       `json:"uuid"`        // 接口名称
	Name        string       `json:"name"`        // 接口名称
	Alias       string       `json:"alias"`       // 别名
	Busy        bool         `json:"busy"`        // 运行时数据,是否被占
	OccupyBy    HwPortOccupy `json:"occupyBy"`    // 运行时数据,被谁占用了 UUID
	Type        string       `json:"type"`        // 接口类型, UART(串口),USB(USB),FD(通用文件句柄)
	Description string       `json:"description"` // 额外备注
	Config      interface{}  `json:"config"`      // 配置, 串口配置、或者网卡、USB等
}

func AllHwPort

func AllHwPort() []RhinoH3HwPort

* * 所有的接口 *

func GetHwPort

func GetHwPort(name string) (RhinoH3HwPort, error)

* * 获取一个运行时状态 *

func (RhinoH3HwPort) String

func (v RhinoH3HwPort) String() string

type UartConfig

type UartConfig struct {
	Timeout  int    `json:"timeout"`
	Uart     string `json:"uart"`
	BaudRate int    `json:"baudRate"`
	DataBits int    `json:"dataBits"`
	Parity   string `json:"parity"`
	StopBits int    `json:"stopBits"`
}

* * 这里记录一些H3网关的硬件接口信息,同时记录串口是否被占用等 *

Jump to

Keyboard shortcuts

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