Metadata-Version: 2.4
Name: numato_usb_gpio
Version: 0.0.2
Summary: A small USB GPIO example package
Author-email: Numato systems Pvt Ltd <help@numato.com>
License-Expression: LGPL-3.0
Classifier: Programming Language :: Python :: 3.6
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# Python API for Numato USB GPIOs

This Python API can be used to control [Numato USB GPIO expanders](https://numato.com/product-category/automation/gpio-modules/usb-gpio/).

* Configure GPIOs as input or output port
* Write to output ports
* Read from input ports
* Read integer values from ADC input ports

numato-usb-gpio allows to control gpio modules (Set or Clear states). This module is compatible with all Numato USB GPIO series.

## Requirement

The module requires the minimum configuration :

- Windows-10(64 bits) and later
- Linux 64-bits
- Python3.6 and later


## License
This API is licensed under the GNU Lesser General Public License v3.0. See [LICENSE](https://www.gnu.org/licenses/lgpl-3.0.html) for full license text.


## Installation

Install the latest release:

```
pip install numato_usb_gpio
```


## Usage CLI

Linux :\
Test whether your devices can be found running the command-line interface like `python3 -m numato_usb_gpio.gpio`. Remember to have your user in the `dialout` group,
since the devices are registered as /dev/ttyACMx (i.e. modem devices). The default Baudrate is 921600.

Expected output:
```
❯ python3 -m numato_usb_gpio.gpio
Discovered devices:
dev: /dev/ttyACM0 | id: 00000000 | ver: 00000009 | ports: 32 | eol: '\r' | state: 0xFFFFFFFF
dev: /dev/ttyACM1 | id: 12345678 | ver: A0M10.01 | ports: 16 | eol: '\r' | state: 0xFFFF
```
\
Windows :
Test whether your devices can be found running the command-line interface like `python -m numato_usb_gpio.gpio`.The default Baudrate is 921600.
Expected output:
```
❯ python -m numato_usb_gpio.gpio
Discovered devices:
dev: COM27 | id: 00000000 | ver: 00000009 | ports: 32 | eol: '\r' | state: 0xFFFFFFFF
dev: COM5 | id: 12345678 | ver: A0M10.01 | ports: 16 | eol: '\r' | state: 0xFFFF

```

## How to use it

The command line example:

Windows :
```
python -m numato_usb_gpio.gpio --gpios=8 --port=<port> --baudrate=<baudrate> 
```

Linux :
```
python3 -m numato_usb_gpio.gpio --gpios=8 --port=<port> --baudrate=<baudrate> 
```
\
Parameters are :

`--gpios` : the number of gpios to drive (default is 8)

`--port` : the port (default is /dev/ttyUSB1 or "COM1")

`--baudrate` : the baudrate (default is 921600)

`--name` : the type of Numato Usb gpio module name (default is "USB", change the name as "USBG" for NL-USBG-C usb gpio modules).

`Note` : For all CLI commands use `python3` when using in Linux Systems and `python` in Windows Systems.


## List of Functions
1. ver()
2. id_get()
3. id_set("x")
4. info()
5. gpio_set("x")
6. gpio_clear("x")
7. gpio_read("x")
8. gpio_iomask("x")
9. gpio_iodir("x")
10. gpio_writeall("x")
11. gpio_readall()
12. adc_read("x")
13. notigy_get()
14. notify_set("x")
15. gpio_poweron("x","x")
16. gpio_setup("x","x")
<br/>

`Note`: "x" is the parameter to be passed in the functions, please refer the **"sending commands"** section in the user manual of each module for sending the right arguement and to understand the functioning of each command.


## Usage API

The API can be used like:

``` python
from numato_usb_gpio.gpio import Gpio 

# Please change the number of Gpios, COM Port and name accordingly.
Device = Gpio(numberGpios=32, port="COM27", name="USB") 

# To get the version of the module
version=Device.ver()
print(version)

# To get the Device Id 
Device.id_get()

# To Set all the gpios
Device.gpio_writeall("ffffffff")

# To get the Power-On Status of the module
Device.info()

# To set a single Gpio & read the status
Device.gpio_set(0)
print(Device.gpio_read(0))

# To change the direction of any port
Device.gpio_setup([0],"OUT")       // [ ports ] and direction : IN/OUT 
Device.gpio_setup([1,3,8],"OUT")

# Setting the Gpio Power-On Direction & Value
Device.gpio_poweron("00000000","0000ffff")

# Enable notify
Device.notify_set(1)  // 0 - Disable and 1 - Enable notify feature
```

## Release Revisions

- **0.0.2** — Updated LICENSE url.
