nekromant/pl2303gpio

语言: C

git: https://github.com/nekromant/pl2303gpio

PL2303HX用户空间GPIO控制工具
PL2303HX Userspace GPIO control tool
README.md (中文)

PL2303和CP2103用户空间GPIO控制工具

这是一组用于linux用户空间的小工具,允许您进行交互 在PL2303HX和CP2103器件上使用GPIO线。 PL2303:它仅在PL2303HXA上进行了测试,但可能适用于其他修订版。 CP2103:它仅在CP2103上进行了测试,但可能适用于其他版本/版本。

由于在写入时没有常见的GPIO驱动程序 Linux内核 - 这应该作为占位符直到上游人员 修复它。

编译和安装

你需要libusb-1.0-dev,gcc和pkg-config。赶紧跑

make 
sudo make install

安装udev规则(仅限Linux)

这个软件包附带了udev规则,这些规则将被删除 /etc/udev/rules.d/

自动安装和重新加载规则运行

sudo make install-rules

并重新插入你的pl2303 / cp2103加密狗。你不应该再需要root 访问gpio的权限。

我是否必须关闭minicom / rmmod pl2303才能使用此工具?

不。只要您需要,就可以在单独的终端中运行它

我可以选择插入的70个PL2303设备中的哪一个可以使用吗?

是的。您可以指定匹配的--product, - serial和--manuf字符串 你想要的设备。 这些必须先于任何其他选项。例:

./cp2303gpio --product=PowerUART --serial=fireblade --gpio 0 --out 1

用法

CP2103

PL2303HXA/CP2103 userspace GPIO control tool
(c) Andrew 'Necromant' Andrianov 2014, License: GPLv3
Usage: ./cp2103gpio [action1] [action2] ...
Options are: 
         --product=blah    - Use device with this 'product' string
         --serial=blah     - Use device with this 'serial' string
         --manuf=blah      - Use device with this 'manufacturer' string
         -g/--gpio  n      - select GPIO, n=0, 1
         -i/--in           - configure GPIO as input
         -o/--out v        - configure GPIO as output with value v
         -r/--read v       - Read current GPIO value

         -s/--sleep v      - Delay for v ms

Examples: 
        ./cp2103gpio --gpio=1 --out 1
        ./cp2103gpio --gpio=0 --out 0 --gpio=1 --in

All arguments are executed from left to right, you can add 
delays using --sleep v option. e.g. 
        ./cp2103gpio --gpio=0 --out 0 --sleep 1000 --gpio=0 --out 1

巴拉啊03

PL2303HXA/CP2103 userspace GPIO control tool
(c) Andrew 'Necromant' Andrianov 2014, License: GPLv3
Usage: ./pl2303gpio [action1] [action2] ...
Options are: 
         --product=blah    - Use device with this 'product' string
         --serial=blah     - Use device with this 'serial' string
         --manuf=blah      - Use device with this 'manufacturer' string
         -g/--gpio  n      - select GPIO, n=0, 1
         -i/--in           - configure GPIO as input
         -o/--out v        - configure GPIO as output with value v
         -r/--read v       - Read current GPIO value

         -s/--sleep v      - Delay for v ms

Examples: 
        ./pl2303gpio --gpio=1 --out 1
        ./pl2303gpio --gpio=0 --out 0 --gpio=1 --in

All arguments are executed from left to right, you can add 
delays using --sleep v option. e.g. 
        ./pl2303gpio --gpio=0 --out 0 --sleep 1000 --gpio=0 --out 1

限制

cp2303代码错过了GPIO线路“输入”模式所需的魔力。

技巧和窍门

参数从左到右执行。因此,您只能使用一个 调用pl2303gpio / cp2303gpio来执行一系列操作。如果是gpio线 保持不变,你可以省略后续的--gpio参数。 您可以使用--sleep来添加任意延迟(以毫秒为单位)

示例(将gpio3行设置为1,睡眠一秒,将gpio3设置为0:

./cp2303gpio --gpio=3 --out=1 --sleep=1000 --out=0

奖金脚本

'extra'目录包含我在OpenWRT框中使用的一些脚本来管理一些脚本 SBC服务器。它们通过安装脚本安装。

serverctl - 是一个bach脚本,只需提供主机名(也可以作为'序列号'连接到eprom上的cp2303),允许在任何一个盒子上快速打开/关闭/重启/访问minicom。 serverd - 是一个lua守护进程,它以循环方式ping服务器并在LED上显示其状态

Mac OS X提示

据报道,这些工具适用于Mac OS X.原因很明显 在mac上不需要udev规则。

执照

GPLv3的。我懒得复制这里的所有文字。谷歌吧。

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

PL2303 and CP2103 Userspace GPIO control tools

This is a set of small tools for linux userspace that allows you to interact
with GPIO lines on PL2303HX and CP2103 devices.
PL2303: It has only been tested on PL2303HXA, but may work for other revisions.
CP2103: It has only been tested on CP2103, but may work for other revisions/versions.

Since no common GPIO driver for those exists at the time of writing in
the linux kernel - this should serve as a placeholder till upstream guys
fix that.

Compiling & installing

You'll need libusb-1.0-dev, gcc and pkg-config. Just run

make 
sudo make install

Installing udev rules (Linux only)

This package comes with udev rules that will be dropped into your
/etc/udev/rules.d/

To automagically install and reload rules run

sudo make install-rules

and replug your pl2303/cp2103 dongles. You should no longer need root
permissions to access gpio in them.

Do I have to close minicom / rmmod pl2303 to use this tool ?

Nope. Just run it in a separate terminal whenever you need it

Can I chose which of 70 PL2303 devices plugged this will work with?

Yep. You can specify --product, --serial and --manuf strings to match
the device you want.
These must precede any other options. Example:

./cp2303gpio --product=PowerUART --serial=fireblade --gpio 0 --out 1

Usage

CP2103

PL2303HXA/CP2103 userspace GPIO control tool
(c) Andrew 'Necromant' Andrianov 2014, License: GPLv3
Usage: ./cp2103gpio [action1] [action2] ...
Options are: 
         --product=blah    - Use device with this 'product' string
         --serial=blah     - Use device with this 'serial' string
         --manuf=blah      - Use device with this 'manufacturer' string
         -g/--gpio  n      - select GPIO, n=0, 1
         -i/--in           - configure GPIO as input
         -o/--out v        - configure GPIO as output with value v
         -r/--read v       - Read current GPIO value

         -s/--sleep v      - Delay for v ms

Examples: 
        ./cp2103gpio --gpio=1 --out 1
        ./cp2103gpio --gpio=0 --out 0 --gpio=1 --in

All arguments are executed from left to right, you can add 
delays using --sleep v option. e.g. 
        ./cp2103gpio --gpio=0 --out 0 --sleep 1000 --gpio=0 --out 1

PL2303

PL2303HXA/CP2103 userspace GPIO control tool
(c) Andrew 'Necromant' Andrianov 2014, License: GPLv3
Usage: ./pl2303gpio [action1] [action2] ...
Options are: 
         --product=blah    - Use device with this 'product' string
         --serial=blah     - Use device with this 'serial' string
         --manuf=blah      - Use device with this 'manufacturer' string
         -g/--gpio  n      - select GPIO, n=0, 1
         -i/--in           - configure GPIO as input
         -o/--out v        - configure GPIO as output with value v
         -r/--read v       - Read current GPIO value

         -s/--sleep v      - Delay for v ms

Examples: 
        ./pl2303gpio --gpio=1 --out 1
        ./pl2303gpio --gpio=0 --out 0 --gpio=1 --in

All arguments are executed from left to right, you can add 
delays using --sleep v option. e.g. 
        ./pl2303gpio --gpio=0 --out 0 --sleep 1000 --gpio=0 --out 1

Limitations

cp2303 code misses magic required for 'input' mode of GPIO lines.

Tips and tricks

The arguments are executed from left to right. Therefore you can use only one
call to pl2303gpio/cp2303gpio to execute a sequence of actions. If the gpio line
stays the same, you can omit subsequent --gpio arguments.
You can use --sleep to add arbitary delays (in milliseconds)

Example (sets the gpio3 line to 1, sleeps for one second, sets the gpio3 to 0:

./cp2303gpio --gpio=3 --out=1 --sleep=1000 --out=0

Bonus scripts

The 'extra' directory contains a few scripts I use on my OpenWRT box to manage a few
SBC servers. They are installed via install-scripts.

serverctl - is a bach script that allows quickly to power on/power off/reboot/access minicom on any of the boxes by just supplying the hostname (which is also wired into cp2303 onboard eeprom as 'serial number').
serverd - is a lua daemon that pings servers in round-robin fasion and displays their state on LEDs

Mac OS X hint

These tools have been reported to work on Mac OS X. For obvious reasons you
don't need udev rules on a mac.

License

GPLv3. I'm too lazy to copy all the text here. Google for it.