archsupport

package
v0.6.5 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

README

跨平台

这里放置一些对特定硬件的支持库,一般指的是定制化网关产品。如果有不同操作系统上的实现库,建议统一放置此处。可参考下面的hello文件里面的程序。

当前兼容

EEKIT 网关

EEKIT 是 RULEX 团队的默认硬件,操作系统为 64位OpenWrt、Armbian, CPU 架构为 64位全志H3。EEKIT 网关的lua标准库命名空间为 eekit

树莓派4B+

除此之外,还对 树莓派4B的 GPIO 做了支持。树莓派的lua标准库命名空间为 raspberry

环境变量

如果要启用硬件特性,需要在启动的时候加入 ARCHSUPPORT 环境变量来指定运行的版本, 例如要在 EEKIT-H3网关上运行:

ARCHSUPPORT=EEKITH3 rulex run

支持硬件列表

硬件名 环境参数 示例
EEKIT H3版本网关 EEKITH3 ARCHSUPPORT=EEKITH3 rulex run
EEKIT T507版本网关 EEKITT507 ARCHSUPPORT=EEKITT507 rulex run
EEKIT T113版本网关 EEKITT113 ARCHSUPPORT=EEKITT113 rulex run
树莓派4B、4B+ RPI4 ARCHSUPPORT=RPI4B rulex run
玩客云S805 WKYS805 ARCHSUPPORT=WKYS805 rulex run

警告: 这些属于板级高级功能,和硬件架构以及外设有关,默认关闭。 如果你自己需要定制,最好针对自己的硬件进行跨平台适配, 如果没有指定平台,可能会导致预料之外的结果。

常见函数

EEKIT H3版本网关
  1. GPIO 设置

    rhinopi:GPIOSet(Pin, Value)
    

    参数表

    参数名 类型 说明
    Pin int GPIO引脚
    Value int 高低电平, 0、1
  2. GPIO 获取

    rhinopi:GPIOGet(Pin)
    
    参数名 类型 说明
    Pin int GPIO引脚

示例脚本

  1. 玩客云WS1608
function Main(arg)
    while true do
        ws1608:GPIOSet("red", 1)
        time:Sleep(2000)
        ws1608:GPIOSet("red", 0)
        time:Sleep(2000)
    end
end

必须使用这个系统:Linux aml-s812 5.9.0-rc7-aml-s812 #20.12 SMP Sun Dec 13 22:50:05 CST 2020 armv7l GNU/Linux, Armbian 20.12 Buster \l

  1. EEKIT 网关
function Main(arg)
    while true do
        rhinopi:GPIOSet(6, 1)
        time:Sleep(2000)
        rhinopi:GPIOSet(7, 0)
        time:Sleep(2000)
    end
end

Documentation

Index

Constants

View Source
const (
	AmlogicWKYS805_R string = "red"
	AmlogicWKYS805_G string = "green"
	AmlogicWKYS805_B string = "blue"
)

玩客云WS1608有一个RGB LED,其系统内部已经直接支持进设备树:

R -> /sys/class/leds/onecloud\:red\:alive/brightness
G -> /sys/class/leds/onecloud\:green\:alive/brightness
B -> /sys/class/leds/onecloud\:blue\:alive/brightness

Variables

This section is empty.

Functions

func AmlogicWKYS805_RGBGet added in v0.5.2

func AmlogicWKYS805_RGBGet(pin string) (int, error)

func AmlogicWKYS805_RGBSet added in v0.5.2

func AmlogicWKYS805_RGBSet(pin string, value int) (bool, error)

func EEKIT_GPIOGet

func EEKIT_GPIOGet(pin int) (int, error)

explain:read gpio Pin: gpio pin return:1 is high 0 is low

func EEKIT_GPIOGetByFile added in v0.6.4

func EEKIT_GPIOGetByFile(pin byte) (int, error)

func EEKIT_GPIOGetDI1 added in v0.6.4

func EEKIT_GPIOGetDI1() (int, error)

func EEKIT_GPIOGetDI2 added in v0.6.4

func EEKIT_GPIOGetDI2() (int, error)

func EEKIT_GPIOGetDI3 added in v0.6.4

func EEKIT_GPIOGetDI3() (int, error)

func EEKIT_GPIOGetDO1 added in v0.6.4

func EEKIT_GPIOGetDO1() (int, error)

* * 新版本的文件读取形式获取GPIO状态 *

func EEKIT_GPIOGetDO2 added in v0.6.4

func EEKIT_GPIOGetDO2() (int, error)

func EEKIT_GPIOGetUserGpio added in v0.6.5

func EEKIT_GPIOGetUserGpio() (int, error)

func EEKIT_GPIOSet

func EEKIT_GPIOSet(pin, value int) (bool, error)

explain:set gpio Pin: gpio pin Value:gpio level 1 is high 0 is low

func EEKIT_GPIOSetByFile added in v0.6.4

func EEKIT_GPIOSetByFile(pin, value int) error

func EEKIT_GPIOSetDI1 added in v0.6.4

func EEKIT_GPIOSetDI1(value int) error

func EEKIT_GPIOSetDI2 added in v0.6.4

func EEKIT_GPIOSetDI2(value int) error

func EEKIT_GPIOSetDI3 added in v0.6.4

func EEKIT_GPIOSetDI3(value int) error

func EEKIT_GPIOSetDO1 added in v0.6.4

func EEKIT_GPIOSetDO1(value int) error

func EEKIT_GPIOSetDO2 added in v0.6.4

func EEKIT_GPIOSetDO2(value int) error

func EEKIT_GPIOSetUserGpio added in v0.6.5

func EEKIT_GPIOSetUserGpio(value int) error

func HelloWorld

func HelloWorld()

* * 这是Linux库函数调用,本案例没有意义,主要用来展示规范化 *

func RASPI4_GPIOGet

func RASPI4_GPIOGet(pin int) (int, error)

func RASPI4_GPIOSet

func RASPI4_GPIOSet(pin, value int) (bool, error)

func RhinoPiGet4GCSQ added in v0.6.4

func RhinoPiGet4GCSQ() int

*

  • 获取信号: +CSQ: 39,99
  • 0:没有信号。
  • 1-9:非常弱的信号,可能无法建立连接。
  • 10-14:较弱的信号,但可能可以建立连接。
  • 15-19:中等强度的信号。
  • 20-31:非常强的信号,信号质量非常好。 RhinoPiGet4GCSQ: 返回值代表信号格

func RhinoPiGetAPN added in v0.6.4

func RhinoPiGetAPN() (string, error)

* * APN 配置, 参考文档: Quectel_LTE_Standard(A)系列_TCP(IP)_应用指导_V1.4.pdf-2.3.2章节 --

AT+QICSGP=<contextID>[,<context_ type>,<APN>[,<username>,<passwo rd>)[,<authentication>[,<CDMA_pw d>]]]]

AT+QICSGP=1 //查询场景 1 配置。 +QICSGP: 1,"","","",0 OK AT+QICSGP=1,1,"UNINET","","",1 //配置场景 1,APN 配置为"UNINET"(中国联通)。 OK\ERROR

func RhinoPiGetCOPS added in v0.6.4

func RhinoPiGetCOPS() (string, error)

* * 获取运营商 +COPS: (2,"CHINA MOBILE","CMCC","46000",7), (1,"CHINA MOBILE","CMCC","46000",0), (3,"CHN-UNICOM","UNICOM","46001",7), (3,"CHN-CT","CT","46011",7), (1,"460 15","460 15","46015",7),,(0-4),(0-2)

func RhinoPiGetICCID added in v0.6.4

func RhinoPiGetICCID() (string, error)

* * 获取ICCID, 用户查询电话卡号 * +QCCID: 89860025128306012474

func RhinoPiRestart4G added in v0.6.4

func RhinoPiRestart4G() (string, error)

func RhinoPiSetAPN added in v0.6.4

func RhinoPiSetAPN(ptype int, apn, username, password string, auth, cdmaPwd int) (string, error)

场景恒等于1

Types

This section is empty.

Jump to

Keyboard shortcuts

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