beautypg.com

6 gpio built-in module, 1 gpio.setiovalue(gpionumber, value), 2 gpio.getiovalue(gpionumber) – Rainbow Electronics GM862-GPS User Manual

Page 38

background image





Easy Script

in Python

80000ST10020a Rev.8 - 01/10/08

Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved

page 38 of 100

2.6 GPIO built-in module


GPIO built-in module

8

is the interface between Python core and module internal general purpose input

output direct handling. You need to use GPIO built-in module if you want to set GPIO values from
Python script and to read GPIO values from Python script.
You can control GPIO pins also by sending internal 'AT#GPIO' commands using the MDM module, but
using the GPIO module is faster because no command parsing is involved, therefore its use is
recommended.

NOTE:
Python core does not verify if the pins are already used for other purposes (IIC module or SPI
module) by other functions, it's the customer responsibility to ensure that no conflict over pins occurs.

If you want to use GPIO built-in module you need to import it first:

import GPIO
then you can use GPIO built-in module methods like in the following example:
a = GPIO.getIOvalue(5)
b = GPIO.setIOvalue(4, 1)
this reads GPIO 5 value and sets GPIO 4 to output with value 1.

More details about GPIO built-in module methods are in the following paragraphs.

2.6.1 GPIO.setIOvalue(GPIOnumber, value)

Sets output value of a GPIO pin. First input parameter GPIOnumber is a Python integer which is the
number of the GPIO. Second input parameter value is a Python integer which is the output value. It
can be 0 or 1.
Return value is a Python integer which is -1 if an error occurred otherwise is 1.

Example:

b = GPIO.setIOvalue(4, 1)

sets GPIO 4 to output with value 1, assigning return value to b.

2.6.2 GPIO.getIOvalue(GPIOnumber)

Gets input or output value of a GPIO. Input parameter GPIOnumber is a Python integer which is the
number of the GPIO.

8

Note: In case of data call, simulation in PythonWin of GPIO module will not be complete. (a dummy command

replaces GPIO module commands)