Telit Easy Script Python 2.7 r6
Telit Easy Script Python 2.7 r6
Telit Easy Script Python 2.7 r6
7
Application Note
80378ST10106A Rev. 6 – 2017-02-16
[01.2017]
The software described in this document is the property of Telit and its licensors. It is
furnished by express license agreement only and may be used only in accordance with
the terms of such an agreement.
II. Copyrighted Materials
Components, units, or third-party products used in the product described herein are NOT
fault-tolerant and are NOT designed, manufactured, or intended for use as on-line control
equipment in the following hazardous environments requiring fail-safe controls: the
operation of Nuclear Facilities, Aircraft Navigation or Aircraft Communication Systems, Air
Traffic Control, Life Support, or Weapons Systems (High Risk Activities"). Telit and its
supplier(s) specifically disclaim any expressed or implied warranty of fitness for such High
Risk Activities.
IV. Trademarks
TELIT and the Stylized T Logo are registered in Trademark Office. All other product or
service names are the property of their respective owners.
V. Third Party Rights
The software may include Third Party Right software. In this case you agree to comply
with all terms and conditions imposed on you in respect of such separate software. In
addition to Third Party Terms, the disclaimer of warranty and limitation of liability
provisions in this License shall apply to the Third Party Right software.
TELIT HEREBY DISCLAIMS ANY AND ALL WARRANTIES EXPRESS OR IMPLIED
FROM ANY THIRD PARTIES REGARDING ANY SEPARATE FILES, ANY THIRD
PARTY MATERIALS INCLUDED IN THE SOFTWARE, ANY THIRD PARTY MATERIALS
FROM WHICH THE SOFTWARE IS DERIVED (COLLECTIVELY “OTHER CODE”), AND
THE USE OF ANY OR ALL THE OTHER CODE IN CONNECTION WITH THE
SOFTWARE, INCLUDING (WITHOUT LIMITATION) ANY WARRANTIES OF
SATISFACTORY QUALITY OR FITNESS FOR A PARTICULAR PURPOSE.
NO THIRD PARTY LICENSORS OF OTHER CODE SHALL HAVE ANY LIABILITY FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS),
HOWEVER CAUSED AND WHETHER MADE UNDER CONTRACT, TORT OR OTHER
LEGAL THEORY, ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF
THE OTHER CODE OR THE EXERCISE OF ANY RIGHTS GRANTED UNDER EITHER
OR BOTH THIS LICENSE AND THE LEGAL TERMS APPLICABLE TO ANY SEPARATE
FILES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
SW Versions
HE910 Family
HE9101
HE910-D
HE910-GA 12.00.xx6
HE910-EUR / HE910-EUD
HE910-EUG / HE910-NAG
HE910-NAR / HE910-NAD
UE910 Family
UE910-EUR / UE910-EUD
12.00.xx6
UE910-NAR / UE910-NAD
UL865 Family
UL865-EUR / UL865-EUD
UL865-NAR / UL865-NAD 12.00.xx6
UL865-N3G
GE910 Family
GE910-QUAD
13.00.xx7
GE910-GNSS
CE910 Family
18.12.001
(Sprint)
CE910-DUAL 18.12.022
(Verizon)
18.12.012
(Aeris)
Note: the present document covers the SW versions shown in the Applicability Table and
may mention features which are not present or behave differently in previous SW versions
1 HE910 is the “type name” of the products marketed as HE910-G & HE910-DG
80378ST10106A Rev. 6 Page 4 of 93 2017-02-16
CONTENTS
NOTICE ..................................................................................................... 2
COPYRIGHTS ................................................................................................ 2
CONTENTS .................................................................................................... 5
1. INTRODUCTION ........................................................................ 11
1.2. Audience
This document is intended for Telit customers developing functionalities on their
applications.
TS-EMEA@telit.com
TS-AMERICAS@telit.com
TS-APAC@telit.com
Alternatively, use:
http://www.telit.com/support
For detailed information about where you can buy the Telit modules or for
recommendations on accessories and components visit:
http://www.telit.com
Our aim is to make this guide as helpful as possible. Keep us informed of your comments
and suggestions for improvements.
Telit appreciates feedback from the users of our information.
Caution or Warning – Alerts the user to important points about integrating the
module, if these points are not followed, the module and end user equipment
may fail or malfunction.
Tip or Information – Provides advice and suggestions that may be useful when
integrating the module.
Chapter 2: “Easy Script Extension – Python interpreter” gives a broad overview about the
extension.
Chapter 3: “Python script operations” deals with the execution of the scripts operatively.
Chapter 4: “Python built-in custom modules“ explains in detail the single custom built-in
modules.
Chapter 7: “Python notes” deals with some Python limits that should be considered while
developing scripts.
The Easy Script Extension functionality lets the developer to get rid of the external
controller and further simplify the programmed sequence of operations. The equipped
Python version features the following:
Python script interpreter engine version 2.7.2
2 MB of Non Volatile Memory space for user scripts and data files (12.xx.xxx,
13.xx.xxx and 18.11.004)
2 MB RAM available for the Python engine(12.xx.xxx, 13.xx.xxx and 18.11.004)
2.3 Python
Python is a dynamic object-oriented multipurpose high level programming language.
Python interpreter implemented version is 2.7.2.
Refer to
http://www.python.org/
and
http://www.python.org/download/releases/2.7.2/
for any information about Python and Python interpreter version 2.7.2.
NOTE:
Antenna GPS, GPS receiver and GPS Library are available exclusively for the
GPS modules.
import MDM
print 'Hello World!'
result = MDM.send('AT\r', 0)
print result
c = MDM.read()
print c
In order to download the, optionally compiled, Python script you have to choose a name
for your script on the module, taking care of the following:
the extension for scripts is .py;
the extension for compiled scripts is .pyc;
any or no extension is permitted for generic text or binary file;
the maximum file name length allowed is 16 characters;
file names are case sensitive.
Then you have to find out the exact size in bytes of the script or compiled script, or
generic text or binary file. For example, right clicking on the file and selecting “size” in
“properties” (attention: this is different from selecting “size on disk”).
It is important for large files, compared to module serial port buffer size of 4096 bytes, to
activate hardware flow control on your terminal emulator.
It is possible to overwrite an existing file, there is no need to delete old one first.
When using standard Windows terminal emulator Hyper Terminal refer to “Send Text file”
function.
In Hyper Terminal application select “Hardware” flow control in serial settings.
In ASCII Setup set “Send line ends with line feeds” and “Append line feeds to incoming
line ends”.
Type for example
AT#WSCRIPT=”a.py”,110
wait for the prompt
>>>
and use “Send Text file” selecting the proper file.
Wait for the result: OK or ERROR.
NOTE:
There is no error return value for non existing script name in the module
memory typed in command AT#ESCRIPT. For this reason it’s recommended
to double check the name of the script that you want to execute. On the other
hand this characteristic permits additional possibilities like enabling the Python
script before downloading it on the module or not having to enable the same
script name every time the script has been changed, deleted and replaced
with another script but with the same name.
It is important for large files, compared to PC serial port buffer size, to activate hardware
flow control on your terminal emulator.
Type for example
AT#RSCRIPT=”a.py
<<<
Receive file data and wait for the result: OK or ERROR.
For every product version (12.xx.xxx, 13.xx.xxx and 18.11.004) proceed in the following
way.Connect to the second module serial port USIF1 at 115200.
Collect Python standard output and standard error:
Python information messages (for example the version);
Python error information;
Results of all Python “print” statements.
interface between Python and the module serial port USIF0 direct
SER
handling
interface between Python and the module serial port USIF1 direct
SER2
handling
interface between Python and the module USB port USB0 direct
USB0
handling
Y Y Y
MDM
Y Y Y
MDM2
Y Y Y
SER
Y Y Y
SER2
Y Y Y
GPIO
Y Y Y
GPS
Y Y Y
IIC
Y Y Y
SPI
Y Y Y
MOD
Y Y Y
USB0
NOTE:
The buffer available for the MDM.send command is 32768 bytes for product
versiones 12.xx.xxx or 4096 bytes for product versiones 13.xx.xxx and
18.11.004.
4.1.2. MDM.read()
This command receives a string from the AT command interface.
It has no input parameter.
The return value is a Python string which contains the data received and stored in buffer
at the moment of command execution. The value might be empty if no data is received.
Example:
a = MDM.read()
Receives a string from AT command handling, assigning the return value to a.
NOTE:
it is up Python script to keep empty MDM.read buffer
4.1.4. MDM.readbyte()
This command receives a byte from the AT command interface.
It has no input parameter.
The return value is a Python integer which is the byte value received and stored in buffer
at the moment of command execution or is -1 if no data is received. The return value can
also be zero.
Example:
b = MDM.readbyte()
receives a byte from AT command handling, assigning the return value to b.
4.1.6. MDM.getDCD()
This command gets Carrier Detect (DCD) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is either 0 if DCD is OFF or 1 if DCD is ON.
Example:
cd = MDM.getDCD()
gets DCD from AT command handling, assigning the return value to cd.
4.1.7. MDM.getCTS()
This command gets Clear to Send (CTS) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is either 0 if CTS is set to OFF or 1 if CTS is
set to ON.
Example:
cts = MDM.getCTS()
gets CTS from AT command handling, assigning the return value to cts.
4.1.8. MDM.getDSR()
This command gets Data Set Ready (DSR) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is either 0 if DSR is OFF or 1 if DSR is ON.
Example:
dsr = MDM.getDSR()
gets DSR from AT command handling, assigning the return value to dsr.
4.1.10. MDM.setRTS(RTS_value)
This command sets Request to Send (RTS) in the AT command interface.
The input parameter RTS_value is a Python integer which is either 0 if setting RTS to OFF
or 1 if setting RTS to ON.
No return value.
Example:
MDM.setRTS(1)
sets RTS to ON in AT command handling.
4.1.11. MDM.setDTR(DTR_value)
This command sets Data Terminal Ready (DTR) in the AT command interface.
The input parameter DTR_value is a Python integer which is either 0 if setting DTR to
OFF or 1 if setting DTR to ON.
No return value.
Example:
MDM.setDTR(0)
sets DTR to OFF in AT command handling.
NOTE:
the buffer available for MDM2.send command is 32768 bytes for product
versions 12.xx.xxx or 4096 bytes for product versions 13.xx.xxx and
18.11.004.
4.2.2. MDM2.read()
This command receives a string from the AT command interface.
It has no input parameter.
The return value is a Python string which contains the data received and stored in buffer
at the moment of command execution. The value might be empty if no data is received.
Example:
a = MDM2.read()
receives a string from AT command handling, assigning the return value to a.
NOTE:
It is up to Python script to keep empty MDM2.read buffer.
4.2.4. MDM2.readbyte()
This command receives a byte from the AT command interface.
It has no input parameter.
The return value is a Python integer which is the byte value received and stored in buffer
at the moment of command execution or is -1 if no data is received. The return value can
also be zero.
Example:
b = MDM2.readbyte()
receives a byte from AT command handling, assigning the return value to b.
4.2.6. MDM2.getDCD()
This command gets Carrier Detect (DCD) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is 0 if DCD is set to OFF or 1 if DCD is set to
ON.
Example:
cd = MDM2.getDCD()
gets DCD from AT command handling, assigning the return value to cd.
4.2.7. MDM2.getCTS()
This command gets Clear to Send (CTS) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is either 0 if CTS is set to OFF or 1 if CTS is
set to ON.
Example:
cts = MDM2.getCTS()
gets CTS from AT command handling, assigning the return value to cts.
4.2.8. MDM2.getDSR()
This command gets Data Set Ready (DSR) from the AT command interface.
It has no input parameter.
The return value is a Python integer which is either 0 if DSR is set to OFF or 1 if DSR is
set to ON.
Example:
dsr = MDM2.getDSR()
gets DSR from AT command handling, assigning the return value to dsr.
4.2.10. MDM2.setRTS(RTS_value)
This command sets Request to Send (RTS) in the AT command interface.
The input parameter RTS_value is a Python integer which is 0 if setting RTS to set to OFF
or 1 if setting RTS to set to ON.
No return value.
Example:
MDM2.setRTS(1)
sets RTS to ON in AT command handling.
4.2.11. MDM2.setDTR(DTR_value)
This command sets Data Terminal Ready (DTR) in the AT command interface.
The input parameter DTR_value is a Python integer which is 0 if setting DTR to set to
OFF or 1 if setting DTR to set to ON.
No return value.
Example:
MDM2.setDTR(0)
sets DTR to OFF in AT command handling.
NOTE:
the buffer available for SER.send command is 4096 bytes.
4.3.2. SER.read()
This command receives a string from the serial port TXD/RXD.
It has no input parameter.
The return value is a Python string which contains the data received and stored in buffer
at the moment of command execution. The value might be empty if no data is received.
Example:
a = SER.read()
receives a string from the serial port USIF0 handling, assigning the return value to a.
NOTE:
It is up to Python script to keep empty SER.read buffer.
4.3.4. SER.readbyte()
This command receives a byte from the serial port TXD/RXD.
It has no input parameter.
The return value is a Python integer which is the byte value received and stored in buffer
at the moment of command execution or is -1 if no data is received. The return value can
also be zero.
Example:
b = SER.readbyte()
receives a byte from serial port USIF0 handling, assigning the return value to b.
NOTE:
Sending the +IPR command to the device does not affect the physical serial
port, you must use this function to set the speed of the port when using the
Python engine.
4.3.8. SER.setCTS(CTS_value)
This command sets Clear to Send (CTS) on the serial port USIF0.
From version 12.00.xx4, version 13.00.xx5 and version 18.11.004 this command has no
effect if flow control is enabled.
The input parameter CTS_value is a Python integer which is either 0 if CTS is set to OFF
or 1 if CTS is set to ON.
No return value.
Example:
SER.setCTS(1)
sets CTS to ON in USIF0.
4.3.9. SER.setDSR(DSR_value)
This command sets Data Set Ready (DSR) on the serial port USIF0.
From version 12.00.xx4, version 13.00.xx5 and version 18.11.004 this command has no
effect if flow control is enabled.
The input parameter DSR_value is a Python integer which is either 0 if DSR is set to OFF
or 1 if DSR is set to ON.
No return value.
Example:
SER.setDSR(1)
sets DSR to ON in USIF0.
4.3.11. SER.getRTS()
This command gets Request to Send (RTS) from the serial port USIF0.
It has no input parameter.
The return value is a Python integer which is either 0 if RTS is set to OFF or 1 if RTS is
set to ON.
Example:
rts = SER.getRTS()
gets RTS from USIF0, assigning the return value to rts.
4.3.12. SER.getDTR()
This command gets Data Terminal Ready (DTR) from the serial port USIF0.
It has no input parameter.
The return value is a Python integer which is either 0 if DTR is set to OFF or 1 if DTR is
set to ON.
Example:
dtr = SER.getDTR()
gets DTR from USIF0, assigning the return value to dtr.
4.4.1. SER2.send(string)
This command sends a string to the serial port USIF1.
The input parameter string is a Python string to send to the serial port USIF1.
The return value is a Python integer which is -1 if the timeout period has expired, 1
otherwise.
Example:
a = SER2.send('test')
sends the string 'test' to the serial port USIF1 handling, assigning the return value to a.
NOTE:
the buffer available for SER2.send command is 4096 bytes.
4.4.2. SER2.read()
This command receives a string from the serial port USIF1.
It has no input parameter.
The return value is a Python string which contains the data received and stored in buffer
at the moment of command execution. The value might be empty if no data is received.
Example:
a = SER2.read()
receives a string from the serial port USIF1 handling, assigning the return value to a.
NOTE:
It is up to Python to keep empty SER2.read buffer.
4.4.3. SER2.sendbyte(byte)
This command sends a byte to the serial port USIF1.
The input parameter byte can be zero or any Python byte to send to the serial port
USIF1.
The return value is a Python integer which is -1 if the timeout period has expired, 1
otherwise.
Example:
b = SER2.sendbyte(0x0d)
sends the byte 0x0d, that corresponds to <CR>, to the serial port USIF1 handling,
assigning the return value to b.
4.4.4. SER2.readbyte()
This command receives a byte from the serial port USIF1.
It has no input parameter.
The return value is a Python integer which is the byte value received and stored in buffer
at the moment of command execution or is -1 if no data is received. The return value can
also be zero.
Example:
b = SER2.readbyte()
receives a byte from serial port USIF1 handling, assigning the return value to b.
4.4.5. SER2.sendavail()
This command queries the number of bytes available to send to SER2 buffer.
It has no input parameter.
The return value is a Python integer which is the number of bytes available to send to
SER2 buffer.
Example:
NOTE:
The Python core does not verify if the pins are already used for other
purposes by other functions, it's the customer responsibility to ensure that no
conflict over pins occurs.
If you want to use the GPIO built-in module you need to import it:
import GPIO
then you can use its methods as in the following example:
a = GPIO.getIOvalue(5)
b = GPIO.setIOvalue(4, 1)
this reads the GPIO 5 value and sets GPIO 4 to the output with value 1.
More details about GPIO built-in module methods are in the following paragraphs.
NOTE:
For versions up to 12.00.xx5 this method returns -1 if the GPIOnumber is not
set to output.
4.5.2. GPIO.getIOvalue(GPIOnumber)
This method gets the input value of a GPIO.
The input parameter GPIOnumber is a Python integer which is the number of the GPIO.
The return value is a Python integer which is -1 if an error occurred otherwise it is the
input value. It can be either 0 or 1.
Example:
b = GPIO.getIOvalue(5)
gets the GPIO 5 input value, assigning the return value to b.
NOTE:
For versions up to 12.00.xx5 this method returns -1 if the GPIOnumber is not
set to output.
NOTE:
When the direction value is not 1, although the parameter value has no
meaning, it is necessary to assign it one of the two possible values: 0 or 1.
NOTE:
For version 18.11.004 the direction values for alternate functions are not
supported.
4.5.4. GPIO.getIOdir(GPIOnumber)
This method gets the direction of a GPIO.
The input parameter GPIOnumber is a Python integer which is the number of the GPIO.
The return value is a Python integer which is -1 if an error occurred otherwise is direction
value. It is 0 for input or 1 for output. Other values are available for alternate functions.
Refer to AT#GPIO command in product "AT Commands Reference Guide" for further
notes.
Example:
d = GPIO.getIOdir(7)
gets GPIO 7 direction, assigning the return value to d.
NOTE:
For version 18.11.004 the return values for alternate functions are not
supported.
4.5.5. GPIO.getADC(adcNumber)
This method gets ADC value. It is equivalent to the AT#ADC command.
The input parameter adcNumber is a Python integer which represents the ADC number
that will be read and converted in voltage.
NOTE:
For version 18.11.004 the only available value for adcNumber is 1.
4.5.8. GPIO.getAXE()
This method gets the hands free status value. It is equivalent to the AT#AXE command.
It has no input parameter.
The return value is a Python integer that is either 0 if a hand free is not connected or 1 if a
hand free is connected.
Example:
hf = GPIO.getAXE()
gets the AXE value, assigning the return value to hf.
NOTE:
For version 18.11.004 this method has no effect.
NOTE:
For version 18.11.004 the return values 1 and 2 for charger status are not
supported.
4.6.2. GPS.getPowerOnOff()
This method gets GPS controller current power ON/OFF status.
It has no input parameter.
The return value is a Python integer which is 0 if GPS controller is powered off or 1 if GPS
controller is powered on.
Example:
status = GPS.getPowerOnOff()
gets GPS controller current power ON/OFF status, assigning the return value to status.
4.6.3. GPS.resetMode(mode)
This method resets GPS controller. It is equivalent to the AT$GPSR command.
The input parameter mode is a Python integer and can have the following values:
0 - Hardware reset
1 - Coldstart (No Almanac, No Ephemeris);
2 - Warmstart (No Ephemeris);
3 - Hotstart (with stored Almanac and Ephemeris)
The return value is a Python integer which is -1 if an error occurred otherwise is 1.
This method is available only for product versions from 12.00.xx6 and from 13.00.xx7.
Example:
res = GPS.resetMode(1)
executes a cold restart of GPS controller, assigning the return value to res.
4.6.4. GPS.getActualPosition()
This method gets GPS last position information. It is equivalent to the AT$GPSACP
command.
It has no input parameter.
The return value is a Python string which is the last position information formatted in the
same way as for AT$GPSACP command response.
80378ST10106A Rev. 6 Page 48 of 93 2017-02-16
Example:
lastPosition = GPS.getActualPosition()
gets GPS last position information, assigning the return value to lastPosition.
4.6.6. GPS.powerSavingWakeUp()
This method wakes up GPS controller while in power saving mode. It is equivalent to the
AT$GPSWK command.
It has no input parameter.
The return value is a Python integer which is -1 if an error occurred otherwise is 1.
TeseoII-based GNSS receiver currently does not support power saving.
This method is available only for product versions from 12.00.xx6 and from 13.00.xx7.
Example:
res = GPS.powerSavingWakeUp()
wakes up GPS controller while in power saving, assigning the return value to res.
4.6.7. GPS.getLastGGA()
This method gets GPS last GGA NMEA sentence stored.
It has no input parameter.
The return value is a Python string which is the last GGA NMEA sentence formatted
according to NMEA specification.
4.6.8. GPS.getLastGLL()
This method gets GPS last GLL NMEA sentence stored.
It has no input parameter.
The return value is a Python string which is the last GLL NMEA sentence formatted
according to NMEA specification.
Example:
gll = GPS.getLastGLL()
gets last GLL NMEA sentence, assigning the return value to gll.
4.6.9. GPS.getLastGSA()
This method gets GPS last GSA NMEA sentence stored.
It has no input parameter.
The return value is a Python string which is the last GSA NMEA sentence formatted
according to NMEA specification.
Example:
gsa = GPS.getLastGSA()
gets last GSA NMEA sentence, assigning the return value to gsa.
4.6.10. GPS.getLastGSV()
This method gets GPS last GSV NMEA sentence stored.
It has no input parameter.
The return value is a Python string which is the concatenation of the last GSV NMEA
sentences formatted according to NMEA specification.
Example:
gsv = GPS.getLastGSV()
gets last GSV NMEA sentence, assigning the return value to gsv.
4.6.12. GPS.getLastVTG()
This method gets GPS last VTG NMEA sentence stored.
It has no input parameter.
The return value is a Python string which is the last VTG NMEA sentence formatted
according to NMEA specification.
Example:
vtg = GPS.getLastVTG()
gets last VTG NMEA sentence, assigning the return value to vtg.
4.6.13. GPS.getPosition()
This method gets GPS last position stored in numeric format.
It has no input parameter.
The return value is a Python tuple formatted in the following way:
(latitude, latNorS, longitude, lonEorW)
where:
the first element of tuple latitude is a Python integer which is latitude in
(degrees * 10000000), that is in degrees with 10000000 scale factor
the second element of tuple latNorS is a Python string which is ‘N’ for north or ‘S’
for south
the third element of tuple longitude is a Python integer which is longitude in
(degrees * 10000000), that is in degrees with 10000000 scale factor
fourth element of tuple lonEorW is a Python string which is ‘E’ for east or ‘W’ for
west.
If GPS controller has no position information the following tuple will be returned:
(0, '', 0, '').
This method is available only for product versions from 12.00.xx6 and from 13.00.xx7.
Example:
pos = GPS.getPosition()
gets last position stored, assigning the return value to pos.
NOTE:
An external pull-up must be provided on SDA line since the line is working as
open collector, on the hand SCLK is driven with a complete push pull.
NOTE:
All GPIO pins are available pins for the IIC bus.
It is Python script developer responsibility to avoid conflicts between GPIO
pins, no automatic check of GPIO pins already used for other purposes (GPIO
module, IIC module, SPI module) is available.
Example:
IICbus = IIC.new(3, 4, 0x50)
creates a new IIC bus object using GPIO 3 for SDA, GPIO 4 for SCL and with address
0x50.
4.7.2. init()
This IIC bus Python object method initializes the IIC bus.
No input value.
No return value.
Example:
IICbus.init()
initializes IIC bus object.
Examples:
IICbus = IIC.new(3, 4, 0x50)
IICbus.init()
rec = IICbus.readwrite('\x08'+'test', 10)
sends 08 hex byte followed by 'test' and then receives a string of 10 bytes assigning it to
rec.
rec = IICbus.readwrite('\x08'+'test', 0)
sends only 08 hex byte followed by 'test'.
rec = IICbus.readwrite('\x08', 10)
sends 08 hex byte and then receives a string of 10 bytes assigning it to rec.
rec = IICbus.readwrite('', 10)
receives only a string of 10 bytes assigning it to rec.
NOTE:
All GPIO pins are available pins for the SPI bus.
It is Python script developer responsibility to avoid conflicts between GPIO
pins, no automatic check of GPIO pins already used for other purposes (GPIO
module, IIC module, SPI module) is available.
Example:
SPIbus = SPI.new(3, 4, 5, 6, 7)
creates a new SPI bus object using GPIO 3 for SCLK, GPIO 4 for MOSI, GPIO 5 for
MISO, GPIO 6 for SS0, GPIO 7 for SS1.
4.9.1. MOD.watchdogEnable(timeout)
This method activates the software watchdog protection of the system against script
blocking by performing an automatic reboot of the module when the watchdog reaches a
determined value. To avoid system reboot MOD.watchdogReset() command must be
called periodically.
The input parameter timeout is an integer, which is measured in seconds and represents
the time to wait before executing the system reboot. The timeout range is (1 ÷ 36000 (10
hours)).
No return value.
Example:
MOD.watchdogEnable(60)
activates watchdog that after 60sec from execution of this command will reboot the
module unless MOD.watchdogReset() is called.
4.9.2. MOD.watchdogReset()
This method restarts the software watchdog counter that has been previously activated
with the command MOD.watchdogEnable(timeout) preventing in this way the reboot of the
module. It should be added in every part of the script that can cause a script blocking
(loops, etc.) and is used only when Python watchdog is enabled.
No input value.
No return value.
Example:
MOD.watchdogReset()
restarts watchdog counter.
4.9.4. MOD.powerSaving(timeout)
This method blocks script execution and sets the system in power saving mode for a
given time interval or until an external event occurs (e.g. incoming call RING). Blocking
script execution is necessary for power saving conditions to be achieved. Setting power
saving mode is equivalent to AT+CFUN=0 command (see Telit Modules Software User
Guide for further details).
The input parameter timeout is an integer, which is measured in seconds and represents
the maximum time the Python script remains blocked. The Python script will exit power
saving mode when the given value of timeout is reached or when an external event occurs
(e.g. incoming call RING). If the timeout value is -1 the Python script will exit from power
saving mode only when an external event occurs. The timeout value can be -1 or in the
range (0 ÷ 1800000 (500 hours)).
The return value is a Python integer which is 0 if the Python script has exited power
saving mode because an external event has occurred otherwise it is 1 if the Python script
has exited power saving mode because the timeout has expired.
Example:
cause = MOD.powerSaving(100)
blocks Python script and enters power saving mode for a maximum of 100 sec or until an
external event occurs.
NOTE:
The buffer available for the USB0.send command is 32767 bytes.
4.10.2. USB0.read()
This command receives a string from the first mini USB port USB0.
It has no input parameter.
The return value is a Python string which contains the data received and stored in buffer
at the moment of command execution. The value might be empty if no data is received.
Example:
a = USB0.read()
receives a string from the first mini USB port USB0 handling, assigning the return value to
a.
NOTE:
The buffer available for the USB0.read command is 32767 bytes. The
maximum number of bytes returned by each USB0.read is 8191.
4.10.4. USB0.readbyte()
This command receives a byte from the first mini USB port USB0.
It has no input parameter.
The return value is a Python integer which is the byte value received and stored in buffer
at the moment of command execution or is -1 if no data is received. The return value can
also be zero.
Example:
b = USB0.readbyte()
receives a byte from first mini USB port USB0 handling, assigning the return value to b.
4.10.5. USB0.sendavail()
This command queries the number of bytes available to send to USB0 buffer.
It has no input parameter.
The return value is a Python integer which is the number of bytes available to send to
USB0 buffer.
Example:
n = USB0.sendavail()
queries the number of bytes available to send, assigning the return value to n.
complex
unicode
docstring
packages
marshal
imp
_ast
__main__
__builtin__
sys
exceptions
gc
_warnings
_md5
binascii
_sre
_weakref
_symtable
_functools
_socket
time
posix
thread
signal
errno
cStringIO
math
abs
all
any
basestring
bin
bool
bytearray
callable
chr
classmethod
cmp
compile
complex (raises exception)
delattr
dict
dir
divmod
enumerate
eval
execfile
filter
float
format
frozenset
getattr
globals
hasattr
hash
help
hex
id
input
int
isinstance
issubclass
iter
len
list
locals
long
map
max
memoryview
min
next
object
oct
open
80378ST10106A Rev. 6 Page 63 of 93 2017-02-16
ord
pow
print
property
range
raw_input
reduce
reload
repr
reversed
round
set
setattr
slice
sorted
staticmethod
str
sum
super
tuple
type
vars
xrange
zip
__import__
apply
buffer
coerce
intern
False
True
None
NotImplemented
Ellipsis
__debug__
x or y
x and y
not x
5.2.6. Comparisons
The following comparisons are supported:
<
<=
>
>=
==
!=
is
is not
x+y
x-y
x*y
x/y
x // y
x%y
-x
+x
abs(x)
int(x)
long(x)
float(x)
divmod(x, y)
pow(x, y)
x ** y
round(x[, n])
x|y
x^y
x&y
x << y
x >> y
~x
bit_length()
as_integer_ratio()
is_integer()
hex()
fromhex(s)
__iter__()
next()
x in s
x not in s
s+t
s * n, n * s
s[i]
s[i:j]
s[i:j:k]
len(s)
min(s)
max(s)
s.index(i)
s.count(i)
capitalize
center
count
decode
encode
endswith
expandtabs
find
format
index
isalnum
isalpha
isdigit
islower
isspace
istitle
isupper
join
ljust
lower
lstrip
80378ST10106A Rev. 6 Page 67 of 93 2017-02-16
parition
replace
rfind
rindex
rjust
rpartition
rsplit
rstrip
split
splitlines
startswith
strip
swapcase
title
translate
upper
zfill
s[i] = x
s[i:j] = t
del s[i:j]
s[i:j:k] = t
del s[i:j:k]
s.append(x)
s.extend(x)
s.count(x)
s.index(x[, i[, j]])
s.insert(i, x)
s.pop([i])
s.remove(x)
s.reverse()
s.sort([cmp[, key[, reverse]]])
len(s)
x in s
x not in s
isdisjoint()
issubset()
set <= other()
set < other()
issuperset
set >= other()
set > other()
union
set | other | …()
intersection
set & other & …()
difference
set - other - …()
symmetric_difference
set ^ other()
copy()
update
set |= other | …()
intersection_update
set &= other & …()
difference_update
set -= other | …()
len(d)
d[key]
d[key] = value
del d[key]
key in d
key not in d
iter(d)
clear()
copy()
fromkeys(seq,[value])
80378ST10106A Rev. 6 Page 69 of 93 2017-02-16
get(key,[default])
has_key(key)
items()
iteritems()
iterkeys()
itervalues()
keys()
pop(key,[default])
popitem()
setdefault(key,[default])
update([other])
values()
viewitems()
viewkeys()
viewvalues()
close()
flush()
fileno()
isatty()
next()
read([size])
readline([size])
readlines([sizehint])
xreadlines()
seek(offset[, whence])
tell()
write(str)
writelines(seq)
closed
encoding
errors
mode
name
newlines
softspace
NOTE:
For product versions 13.xx.xxx.
Root directory for Python scripts and in general for text and binary files is
empty and cannot be changed.
Files path name in Python scripts will refer to the empty root directory.
Example:
f = open(‘example.txt’, ‘rb’)
tobytes()
tolist()
format
itemsize
shape
ndim
strides
readonly
__dict__
name
BaseException
Exception
StandardError
ArithmeticError
BufferError
LookupError
EnviromentError
AssertionError
AttributeError
EOFError
FloatingPointError
GeneratorExit
IOError
ImportError
IndexError
KeyError
KeyboardInterrupt
MemoryError
NameError
NotImplementedError
OSError
OverflowError
ReferenceError
RuntimeError
StopIteration
SyntaxError
IndentationError
TabError
SystemError
SystemExit
TypeError
UnboundLocalError
UnicodeError
ValueError
ZeroDivisionError
dump
load
dumps
loads
version
find_module
get_magic
get_suffixes
load_module
new_module
lock_held
acquire_lock
release_lock
PY_SOURCE
PY_COMPILED
C_BUILTIN
PY_FROZEN
_clear_type_cache
_current_frames
displayhook
exc_info
exc_clear
exepthook
exit
getrefcount
getrecusionlimit
getsizeof
_getframe
setcheckinterval
getcheckinterval
setprofile
getprofile
setrecusionlimit
settrace
gettrace
call_tracing
stdin
stdout
stderr
__stdin__
__stdout__
__stderr__
__diplayhook__
__excepthook__
version
hexversion
subversion
_mercurial
76on’t_write_bytecode
api_version
copyright
platform
executable
prefix
exec_prefix
maxsize
80378ST10106A Rev. 6 Page 76 of 93 2017-02-16
maxint
py3kwarning
float_info
long_onfo
builtin_module_names
byteorder
warnoptions
version_info
flags
float_repr_style
argv
exitfunc
last_type
last_value
last_traceback
modules
meta_path
path
path_hooks
path_importer_cache
tracebacklimit
enable
disable
isenabled
collect
set_debug
get_debug
get_objects
set_threshold
get_count
get_threshold
get_referrers
get_referents
is_tracked
garbage
DEBUG_STATS
DEBUG_COLLECTABLE
DEBUG_UNCOLLECTABLE
DEBUG_INSTANCES
DEBUG_OBJECTS
DEBUG_SAVEALL
DEBUG_LEAK
a2b_uu
b2a_uu
a2b_base64
b2a_base64
a2b_qp
b2a_qp
a2b_hqx
rledecode_hqx
rlecode_hqx
b2a_hqx
crc_hqx
crc32
b2a_hex
hexlify
a2b_hex
unexlify
Error
Incomplete
socket
gethostbyname
gethostbyname_ex
gethostbyaddr
ntohs
ntohl
htons
htonl
inet_aton
inet_ntoa
getaddrinfo
getnameinfo
getdefualttimeout
setdefualttimeout
error
herror
gaierror
timeout
has_ipv6
AF_INET
AF_UNSPEC
INADDR_ANY
INADDR_BROADCAST
IPPROTO_IP
IPPROTO_TCP
IPPROTO_UDP
IP_HDRINCL
IP_TOS
IP_TTL
MSG_DONTWAIT
SHUT_RD
SHUT_RDWR
SHUT_WR
SOCK_STREAM
SOCK_DGRAM
SOCK_RAW
SOL_SOCKET
SO_ACCEPTCONN
SO_BROADCAST
SO_ERR
SO_KEEPALIVE
SO_LINGER
SO_RCVBUF
SO_RCVTIMEO
SO_REUSEADDR
SO_SNDBUF
SO_TYPE
TCP_MAXSEG
TCP_NODELAY
AI_ADDRCONFIG
AI_ALL
AI_CANONNAME
AI_DEFAULT
AI_MASK
AI_NUMERICHOST
AI_PASSIVE
AI_V4MAPPED
AI_V4MAPPED_CFG
EAI_ADDRFAMILY
80378ST10106A Rev. 6 Page 80 of 93 2017-02-16
EAI_AGAIN
EAI_BADFLAGS
EAI_BADHINTS
EAI_FAIL
EAI_FAMILY
EAI_MEMORY
EAI_NODATA
EAI_NONAME
EAI_PROTOCOL
EAI_SERVICE
EAI_SOCKTYPE
EAI_SYSTEM
NI_DGRAM
NI_MAXHOST
NI_MAXSERV
NI_NAMEREQD
NI_NOFQDN
NI_NUMERICHOST
NI_NUMERICSERV
The following non standard constant is supported in product versions 12.xx.xxx and from
13.00.xx5 but it is not supported in version 18.11.004:
SO_CONTEXTID
accept
bind
close
connect
connect_ex
fileno
getpeername
getsockname
getsockopt
listen
recv
recv_into
recvfrom
recvfrom_into
send
sendall
sendto
setblocking
settimeout
gettimeout
setsockopt
shutdown
80378ST10106A Rev. 6 Page 81 of 93 2017-02-16
Socket objects support the following attributes:
family
type
proto
timeout
time
clock
sleep
stat
unlink
remove
rename
open
close
closerange
lseek
read
write
fstat
isatty
strerror
error
F_OK
R_OK
W_OK
X_OK
start_new_thread
exit
allocate_lock
get_ident
stack_size
(raises exception)
acquire
release
locked
error
NOTE:
It is strongly recommended to terminate main thread only after all secondary
threads are terminated.
signal
getsignal
SIG_DFL
SIG_IGN
SIGMDM
SIGMDM2
errocode
StringIO
InputType
OutputType
Acos
acosh
asin
asinh
atan
atan2
atanh
ceil
copysign
cos
cosh
Degrees
erf
erfc
exp
expm1
fabs
factorial
floor
fmod
frexp
fsum
gamma
hypot
isinf
isnan
ldexp
lgamma
log
log1p
log10
modf
pow
radians
sin
sinh
sqrt
tan
tanh
trunc
e
pi
SO_CONTEXTID
It is the socket option flag used to link a socket object to a context identifier after PDP
Context Activation procedure.
NOTE:
PDP Context Activation procedure can be obtained using AT+CGDCONT and
AT#SGACT commands on MDM or MDM2 interface.
NOTE:
There is a firewall always active on module.
Without firewall proper configuration socket methods might not work as
expected.
Firewall can be configured using AT#FRWL command on MDM or MDM2
interface.
Sockets used by standard functions (e.g. gethostbyname) are silently linked to context
identifier number one.
SIGMDM
It is the signal number linked to the event of presence of data in MDM.read buffer.
Example:
signal.signal(signal.SIGMDM, MDMReadHandler)
SIGMDM
It is the signal number linked to the event of presence of data in MDM2.read buffer.
Example:
signal.signal(signal.SIGMDM2, MDM2ReadHandler)
In order to prevent memory error, in phase of execution of the script, we advise you to
consider the following limits:
allocated memory for each variable;
number of the variables.
The memory available on modules includes:
2 MB of Non Volatile Memory for the user scripts and data files (12.xx.xxx,
13.xx.xxx and 18.11.004);
2 MB RAM available for Python engine usage (12.xx.xxx, 13.xx.xxx and
18.11.004).
Some limits of the available NVM that affect file saving procedures and need to be
considered are listed below:
It is highly recommended not to use the module as a data logger since all flash memories
have limited number of writing and deleting cycles.