Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 3 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.4 SER built-in module .............................................................................................................................30
3.3.1Debug Python script on GPS modules using SSC bus.......................................................................................70
3.3.1.1Installation of the drivers ..........................................................................................................................70
3.3.1.2Debugging process ....................................................................................................................................73
3.3.2Debug Python script on GPS modules using CMUX ........................................................................................74
3.3.2.2Debugging process ....................................................................................................................................74
4Python standard functions ............................................................................................................. 79
4.2.2Truth Value Testing...........................................................................................................................................81
4.2.6Numeric Types: Long Integers ..........................................................................................................................82
5.2 Other Limits..........................................................................................................................................97
6 List of acronyms.............................................................................................................................. 98
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 6 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
DISCLAIMER
The information contained in this document is the proprietary information of Telit Communications
S.p.A. and its affiliates (“TELIT”). The contents are confidential and any disclosure to persons other
than the officers, employees, agents or subcontractors of the owner or licensee of this document,
without the prior written consent of Telit, is strictly prohibited.
Telit makes every effort to ensure the quality of the information it makes available. Notwithstanding the
foregoing, Telit does not make any warranty as to the information contained herein, and does not
accept any liability for any injury, loss or damage of any kind incurred by use of or reliance upon the
information.
Telit disclaims any and all responsibility for the application of the devices characterized in this
document, and notes that the application of the device must comply with the safety standards of the
applicable country, and where applicable, with the relevant wiring rules.
Telit reserves the right to make modifications, additions and deletions to this document due to
typographical errors, inaccurate information, or improvements to programs and/or equipment at any
time and without notice. Such changes will, nevertheless be incorporated into new editions of this
application note.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 7 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1 Easy Script Extension - Python
interpreter
1.1 Overview
The Easy Script Extension is a feature that allows driving the modem "internally", writing the
controlling application directly in a nice high level language: Python.
The Easy Script Extension is aimed for the application usually done by a small microcontroller that
managed some I/O pins and the module through the AT command interface.
A schematic of such a configuration can be:
FFLLAASSHH RROOMM
GGSSMM--GGPPRRSS
PPrroottooccooll SSttaacckk
FFLLAASSHH
RROOMM
mmeemmoorryy
HHAARRDDWWAARREE RREESSOOUURRCCEESS
EEXXTTEERRNNAALL
CCOONNTTRROOLLLLEERR
PPHHYYSSIICCAALL AATT SSEERRIIAALL
PPOORRTT
AATT ccoommmmaannddss
GGPPRRSS MMOODDEEMM
EENNGGIINNE
RRAAMM
E
RRAAMM ffoorr
GGSSMM--GGPPRRSS
mmooddeemm
PPrroottooccooll SSttaacck
k
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 8 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
In order to eliminate this external controller, and further simplify the programming of the sequence of
operations, inside the Python version it is included:
• Python script interpreter engine v. 1.5.2+
• around 2MB of Non Volatile Memory space for the user scripts and data
• 1.2 MB RAM reserved for Python engine usage
A schematic of this approach is:
FFLLAASSHH RROOMM
AAvvaaiillaabbllee UUsseerr
NNVVMM FFLLAASSHH
MMeemmoorryy
((22MMbbyyttee)
GGSSMM--GGPPRRSS
PPrroottooccooll SSttaacckk
FFLLAASSHH
RROOMM
mmeemmoorryy
E
AAvvaaiillaabbllee RRAAMM
ffoorr PPyytthhoonn
IInntteerrpprreetteerr
((11..22MMbbyyttee)
RRAAMM ffoorr
GGSSMM--GGPPRRSS
mmooddeemm
PPrroottooccooll SSttaacck
PPYYTTHHOONN
IINNTTEERRPPRREETTEERR EENNGGIINNEE
MMDDMM mmoodduullee
)
VVIIRRTTUUAALL IINNTTEERRNNAALL AATT
SSEERRIIAALL PPOORRTT
AATT ccoommmmaannddss
GGPPRRSS MMOODDEEMM
EENNGGIINNE
RRAAMM
)
k
HHAARRDDWWAARREE RREESSOOUURRCCEESS
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 9 of 100
Permission to use, copy, modify, and distribute this software and its documentation for any purpose
and without fee is hereby granted, provided that the above copyright notice appear in all copies and
that both that copyright notice and this permission notice appear in supporting documentation, and
that the names of Stichting Mathematisch Centrum or CWI or Corporation for National Research
Initiatives or CNRI not be used in advertising or publicity pertaining to distribution of the software
without specific, written prior permission.
While CWI is the initial source for this software, a modified version is made available by the
Corporation for National Research Initiatives (CNRI) at the Internet address ftp://ftp.python.org
STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM OR CNRI BE
LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 10 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1.3 Python installation
In order to have software that functions correctly the system requirement is PC running Windows 2000
or XP.
To get PythonWin package 1.5.2+ with the latest version please contacts Technical Support at the email:
ts-emea@telit.com;
ts-apac@telit.com;
ts-americas@telit.com.
Or by means the form in telit’s website Æ technical support Æcontact
Getting user name and password it is possible to download it from Telit’s websiteÆdownload zone:
http://www.telit.com/en/products/download-zone,
At the moment, the latest version available is TelitPy1.5.2+_V4.1.exe.
To install Telit Python package you need to execute the exe file TelitPy1.5.2+_V4.1.exe and let the
installer use the default settings. The installation contains the Python compiler package. The Telit
Python package is placed in the folder C:\Program Files\Python\ .The correct path in the Windows
Environmental variables will be set up automatically.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 11 of 100
r
V
r
r
rry
y
A
A
r
r
r
rry
y
r
r
rry
y
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1.4 Python implementation description
Python scripts are text files stored in NVM inside the Telit module. There's a file system inside the
module that allows to write and read files with different names on one single level (no subdirectories
are supported).
Attention: it is possible to run only one Python script at the time.
The Python script is executed in a task inside the Telit module at the lowest priority, making sure this
does not interfere with GSM/GPRS normal operations. This allows serial ports, protocol stack etc. to
run independently from the Python script.
The Python script interacts with the Telit module functionality through four build-in interfaces.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 12 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
NOTE: Antenna GPS, GPS receiver and GPS Library are available exclusively for GPS modules
GM862-GPS and GE863-GPS. Moreover SER2 Library cannot be used by the GPS modules since
their TRACE port is not available.
•The MDM interface is the most important one. It allows Python script to send AT commands,
receive responses and unsolicited indications, send data to the network and receive data from
the network during connections. It is quite the same as the usual serial port interface in the
Telit module. The difference is that this interface is not a real serial port but just an internal
software bridge between Python and mobile internal AT command handling engine. All AT
commands working in the Telit module are working in this software interface as well. Some of
them have no meaning on this interface, such as those regarding serial port settings. The usual
concept of hardware flow control keeps its meaning over this interface, but it's managed
internally.
•The MDM2 interface is the second interface between Python and mobile internal AT
command handling. It is used to send AT commands from Python script to mobile and receive
AT responses from mobile to Python script when the classic MDM built-in module already in
use.
•The SER interface allows Python script to read from and write to the real physical serial port
ASC0, that is usually used to send the AT commands to the module, for example to read
information from external device. When Python is running this serial port is free to be used by
Python script because it is not used as AT command interface since the AT parser is mapped
into the internal virtual serial port. No flow control is available from Python on this port.
•The SER2 interface allows Python script to read from and write to the real physical serial port
ASC1, that is usually available for trace and debug.
•The GPIO interface allows Python script to handle general purpose input output faster than
through AT commands, skipping the command parser and going directly to control the pins.
• The MOD interface is a collection of useful functions.
• The IIC interface is an implementation on the Python core of the IIC bus Master. It allows
Python to create one or more IIC bus on the available GPIO pins.
• The SPI interface isan implementation on the Python core of the SPI bus Master. It allows
Python to create one or more SPI bus on the available GPIO pins.
•The GPS interface isthe interface between Python and mobile internal GPS controller. It is
used in order to handle GPS controller without dedicated AT commands through MDM built-in
module.
For the debug, the print command is directly forwarded on the EMMI TX pin (second serial port) at
baud rate115200bps 8N1.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 13 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1.5 Introduction to Python
Python is a dynamic object oriented programming language that can be used for many kinds of
software development. It offers strong support for integration with different tools, comes with extensive
standard libraries, and can be learned in a few days time.
1.5.1 Data types
There are three groups of data types in Python:
• Scalars have the subtypes integer, long integer (with an arbitrary number of digits), and strings.
For example:
i = 1; li = 9999999999L; s = 'Hello'
• Sequences contain any number of arbitrary objects in a defined order.
L = [1, 5, 3, 9, 14];
• Associative lists (more commonly known as dictionaries) allow the access to values based on
keys. These keys can be arbitrary but immutable objects. For example:
D = {'b': 'Python', 'a': 5}; print D['a']
prints 5.
• Unlike Pascal, C, C++ or Java, Python is a dynamically typed language. Thus, the following
code is perfectly valid Python:
a = 7 # 7 (integer)
a = str(2*a) + ' bytes' # '7 bytes' (string)
In Python variables are not defined in the script, they appear only when used.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 14 of 100
1.5.2 Operators
Python has the following operators:
• Arithmetic and bitwise operators
+ - * / % ** ~ << >> & ^ |
• Relational and logical operators
is in < <= > >= == != not and or
• Assignments
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
= += -= *= /= %= **= <<= >>= &= ^= |=
• Other operators
() [ ] { } [:] `` . lambda
1.5.3 Compound statements
• Statements that belong to the same logical group are indented by the same amount of white
space:
if a > 0:
b = 1
c = 2
Usually, each statement starts on a new line.
• A statement is continued by putting a backslash \ at the end of a line. This isn't necessary if
there are still parentheses (or brackets or braces) open:
my_list = [1, # open bracket, statement continues
['abc', 2], # nested list
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 15 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1.5.4 Conditional execution
• Python uses if, elif (not elsif or elseif), and else to denote conditional execution of statements.
For example:
if a > b:
print 'a is greater than b.'
elif a < b:
print 'a is lower than b.'
else:
print 'a equals b.'
• You can use "abbreviated" interval tests:
if 2 <= a <= 7:
print 'a is in the interval [2, 7].'
1.5.5 Loops
• Loops in Python are defined by the keywords for and while.
• The following example uses a while loop to collect all numbers from 0 to 99 in a list.
numbers = [ ]
i = 0
while i < 100:
numbers.append(i)
i = i + 1 # or i += 1 since Python 2.0
• A similar for loop looks like:
numbers = [ ]
for i in range(100):
numbers.append(i)
• Instead of the explicit loops above also an implicit loop is possible:
numbers = range(100)
range(100) generates a list of all integers from 0 to 99 (not 100).
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 16 of 100
1.5.6 Resources
Some useful manuals for Python can be found on the following links:
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
http://www.python.org/doc/current/tut/tut.html
http://www.hetland.org/python/instant-python.php
http://rgruet.free.fr/PQR2.2.html
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 17 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
1.6 Python core supported features
The Python core version is 1.5.2+ (string methods added to 1.5.2). You can use all Python statements
and almost all Python built-in types and functions.
Built-in types and functions not
supported
complex marshal
float imp
long _main_
docstring _builtin_
sys
md5
Available modules
(all others are not supported)
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 18 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2 Python Build-in Custom Modules
Several build in custom modules have been included in the python core, specifically aimed at the
hardware environment of the module.
The build in modules included are:
MDM
MDM2
SER
SER2
GPIO
MOD
IIC
SPI
GPS
interface between Python and mobile internal AT command handling
second interface between Python and mobile internal AT command handling
interface between Python and mobile internal serial port ASC0 direct handling
interface between Python and mobile internal serial port ASC1 direct handling
interface between Python and mobile internal general purpose input output direct
handling
interface between Python and mobile miscellaneous functions
custom software Inter IC bus that can be mapped on creation over almost any
GPIO pin available
custom software Serial Protocol Interface bus that can be mapped on creation
over almost any GPIO pin available
interface between Python and mobile internal GPS controller
2.1 CMUX and Python1
To make the use of Python easier CMUX (Converter-Multiplexer) feature has been implemented in the
Telit modules. The Multiplexer mode creates four virtual channels on one serial interface and permits
to transmit data to four different applications. This makes it possible to run a Python script and at the
same time use CMUX on ASC0 with the following division of channels:
• first CMUX port is reserved for SER module;
• second CMUX port is available for AT command handling in case when MDM2 built-in module
is not been imported;
• third CMUX port is available for AT command handling;
• fourth CMUX port is in use for debug (print statements);
ASC1 is available for non-GPS products with import of the SER2 built-in module.
1
feature available for the modules with the following Order-Num. :, GM862GPS***-***, GM862PYT***-***,
GE863PYT***-***, GE863GPS***-***, GE864PYT***-***, GC864PYT***-***, GE864PYH***-***,and old
3990250657, 3990250660,
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 19 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.2 MDM built-in module
MDM built-in module is the interface between Python and the module AT command parser engine.
You need to use MDM built-in module if you want to send AT commands and data from Python script
to the network and receive responses and data from the network during connections.
For the default start configuration echo (ATE0) is disabled and long form (verbose) is return codes
(ATV1).
If you want to use MDM built-in module you need to import it first:
import MDM
then you can use MDM built-in module methods like in the following example:
a = MDM.send('AT', 0)
b = MDM.sendbyte(0x0d, 0)
c = MDM.receive(10)
which sends 'AT' and receives 'OK'.
More details about MDM built-in module methods can be found in the following paragraphs.
2.2.1 MDM.send(string, timeout)
This command sends a string to AT command interface. First input parameter string is a Python string
which is the string to send to AT command interface. Second input parameter timeout is a Python
integer, which is measured in 1/10s, and represents the time of waiting for the string to be sent to AT
command interface, with maximum value of timeout. Waiting time is caused by hardware flow control.
Return value is a Python integer which is -1 if timeout expired otherwise is 1.
Example:
a = MDM.send('AT', 5)
sends string 'AT' to AT command handling, possibly waiting for 0.5 s, assigning return value to a.
NOTE: The buffer available for MDM.send command is 4096 bytes
2
2.2.2 MDM.receive(timeout)
This command receives a string from AT command interface waiting for it until timeout is expired.
Return value will be the first string received no matter of how long the timeout is. Request to Send
2
For the products with the following old Order-Num. 3390250656, 3390250654 and 3990150466 the available
buffer is 2048 bytes
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 20 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
(RTS) is set to ON. Input parameter timeout is a Python integer, which is measured in 1/10s, and
represents the maximum time of waiting for the string from AT command interface.
Return value is a Python string which is an empty string if timeout has expired without any data
received otherwise the string contains data received.
Example:
a = MDM.receive(15)
receives a string from AT command handling, possibly waiting for it for 1.5 s, assigning return value to
a.
NOTE: The buffer available for MDM.receive command is 4096 bytes
3
2.2.3 MDM.read()
This command receives a string from AT command interface without waiting for it. Request to Send
(RTS) is set to ON. It has no input parameter.
Return value is a Python string which is an empty string if no data received otherwise is the string
containing data received in the moment when command is activated.
Example:
a = MDM.read()
receives a string from AT command handling, assigning return value to a.
NOTE: The buffer available for MDM.read command is 4096 bytes
4
2.2.4 MDM.sendbyte(byte, timeout)
This command sends a byte to AT command interface. First input parameter byte is any Python byte
that will be to send to AT command interface. It can also be zero. Second input parameter timeout is a
Python integer, which is measured in 1/10s, and represents the maximum time of waiting for the string
from AT command interface. Waiting time is caused by hardware flow control.
Return value is a Python integer which is -1 if timeout expired otherwise is 1.
Example:
b = MDM.sendbyte(0x0d, 0)
3
For the products with the following old Order-Num. 3390250656, 3390250654 and 3990150466 the available
buffer is 2048 bytes
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 21 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
sends byte 0x0d, that stands for <CR>, to AT command handling, without waiting, assigning return
value to b.
2.2.5 MDM.receivebyte(timeout)
This command receives a byte from AT command interface waiting for it until timeout is expired.
Request to Send (RTS) is set to ON. Input parameter timeout is a Python integer which is measured in
1/10s, and represents the maximum time of waiting for the string from AT command interface.
Return value is a Python integer which is -1 if timeout expired without any data received otherwise is
the byte value received. It can also be zero.
Example:
b = MDM2.receivebyte(20)
receives a byte from AT command handling, possibly waiting for it for 2.0 s, assigning return value to
b.
2.2.6 MDM.readbyte()
This command receives a byte from AT command interface without waiting for it. Request to Send
(RTS) is set to ON. It has no input parameter.
Return value is a Python integer which is -1 if no data received otherwise is the byte value received. It
can also be zero.
Example:
b = MDM.readbyte()
receives a byte from AT command handling, assigning return value to b.
2.2.7 MDM.getDCD()
This command gets Carrier Detect (DCD) from AT command interface. It has no input parameter.
Return value is a Python integer which is 0 if DCD is OFF or 1 if DCD is ON.
Example:
cd = MDM.getDCD()
gets DCD from AT command handling, assigning return value to cd.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 22 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.2.8 MDM.getCTS()
This command gets Clear to Send (CTS) from AT command interface. it has no input parameter.
Return value is a Python integer which is 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 return value to cts.
2.2.9 MDM.getDSR()
This command gets Data Set Ready (DSR) from AT command interface. It has no input parameter.
Return value is a Python integer which is 0 if DSR is OFF or 1 if DSR is ON.
Example:
dsr = MDM.getDSR()
gets DSR from AT command handling, assigning return value to dsr.
2.2.10 MDM.getRI()
This command gets Ring Indicator (RI) from AT command interface. It has no input parameter.
Return value is a Python integer which is 0 if RI is set to OFF or 1 if RI is set to ON.
Example:
ri = MDM.getRI()
gets RI from AT command handling, assigning return value to ri.
2.2.11 MDM.setRTS(RTS_value)
This command sets Request to Send (RTS) in AT command interface. Input parameter RTS_value is
a Python integer which is 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.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 23 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.2.12 MDM.setDTR(DTR_value)
This command sets Data Terminal Ready (DTR) in AT command interface. Input parameter
DTR_value is a Python integer which is 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.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 24 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.3 MDM2 built-in module4
MDM2 built-in module is the second interface between Python and mobile internal AT command
handling. It is used to send AT commands from Python script to mobile and receive AT responses
from mobile to Python script when the classic MDM built-in module already in use.
MDM2 built-in module is independent from activation of CMUX on ASC0. In case you have enabled
CMUX on ASC0 (AT#CMUXSCR=1) then the second CMUX port will be dedicated to MDM2 and no
AT command handling will be possible on that port. Remember that first CMUX port is reserved for
SER module and fourth CMUX port is in use for debug (print statements).
For the default start configuration echo (ATE0) is disabled and long form (verbose) is return codes
(ATV1).
If you want to use MDM2 built-in module you need to import it first:
import MDM2
than you can use MDM2 built-in module methods like in the following example:
a = MDM2.send('AT', 0)
b = MDM2.sendbyte(0x0d, 0)
c = MDM2.receive(10)
which sends 'AT' and receives 'OK'.
More details about MDM2 built-in module methods can be found in the following paragraphs.
2.3.1 MDM2.send(string, timeout)
This command sends a string to AT command interface. First input parameter string is a Python string
that will be send to AT command interface. Second input parameter timeout is a Python integer which
is measured in 1/10s, and represents the time of waiting for the string to be sent to AT command
interface, with maximum value of timeout. Waiting time is caused by hardware flow control.
Return value is a Python integer which is -1 if timeout expired otherwise is 1.
Example:
a = MDM2.send('AT', 5)
sends string 'AT' to AT command handling, possibly waiting for 0.5 s, assigning return value to a.
NOTE: The buffer available for MDM2.send command is 4096 bytes
4
feature available for the modules with the following Order-Num.: , GM862PYT***-***, GE863PYT***-***,
GE864PYT***-***, GC864PYT***-***, GE864PYH***-***, GM862GPS***-***, G3863GPS***-***, and the old
3990250660 and 3990250657
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 25 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.3.2 MDM2.receive(timeout)
This command receives a string from AT command interface waiting for it until timeout is expired.
Return value will be the first string received no matter of how long the timeout is. Request to Send
(RTS) is set to ON. Input parameter timeout is a Python integer, which is measured in 1/10s, and
represents the maximum time of waiting for the string from AT command interface.
Return value is a Python string which is an empty string if timeout has expired without any data
received otherwise the string contains data received.
Example:
a = MDM2.receive(15)
receives a string from AT command handling, possibly waiting for it for 1.5 s, assigning return value to
a.
NOTE: The buffer available for MDM2.receive command is 4096 bytes.
2.3.3 MDM2.read()
This command receives a string from AT command interface without waiting for it. Request to Send
(RTS) is set to ON. No input parameter.
Return value is a Python string which is an empty string if no data received otherwise the string
contains data received in the moment when command is activated.
Example:
a = MDM2.read()
receives a string from AT command handling, assigning return value to a.
NOTE: The buffer available for MDM2.read command is 4096 bytes
2.3.4 MDM2.sendbyte(byte, timeout)
This command sends a byte to AT command interface. First input parameter byte is any Python byte
that will be to send to AT command interface. It can also be zero.
Second input parameter timeout is a Python integer which is the value in 1/10 s to wait for the byte to
be sent to AT command interface before timeout expires. Waiting time is caused by hardware flow
control.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 26 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
Return value is a Python integer which is -1 if timeout expired otherwise is 1.
Example:
b = MDM2.sendbyte(0x0d, 0)
sends byte 0x0d, that is <CR>, to AT command handling, without waiting, assigning return value to b.
2.3.5 MDM2.receivebyte(timeout)
This command receives a byte from AT command interface waiting for it until timeout is expired.
Request to Send (RTS) is set to ON. Input parameter timeout is a Python integer which is measured in
1/10s, and represents the maximum time of waiting for the string from AT command interface.
Return value is a Python integer which is -1 if timeout expired without any data received otherwise is
the byte value received. It can also be zero.
Example:
b = MDM2.receivebyte(20)
receives a byte from AT command handling, possibly waiting for it for 2.0 s, assigning return value to
b.
2.3.6 MDM2.readbyte()
This command receives a byte from AT command interface without waiting for it. Request to Send
(RTS) is set to ON. It has no input parameter.
Return value is a Python integer which is -1 if no data received otherwise is the byte value received. It
can also be zero.
Example:
b = MDM2.readbyte()
receives a byte from AT command handling, assigning return value to b.
2.3.7 MDM2.getDCD()
This command gets Carrier Detect (DCD) from AT command interface. It has no input parameter.
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()
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 27 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
gets DCD from AT command handling, assigning return value to cd.
2.3.8 MDM2.getCTS()
This command gets Clear to Send (CTS) from AT command interface. It has no input parameter.
Return value is a Python integer which is 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 return value to cts.
2.3.9 MDM2.getDSR()
This command gets Data Set Ready (DSR) from AT command interface. It has no input parameter.
Return value is a Python integer which is 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 return value to dsr.
2.3.10 MDM2.getRI()
This command gets Ring Indicator (RI) from AT command interface. It has no input parameter.
Return value is a Python integer which is 0 if RI is set to OFF or 1 if RI is set to ON.
Example:
ri = MDM2.getRI()
gets RI from AT command handling, assigning return value to ri.
2.3.11 MDM2.setRTS(RTS_value)
This command sets Request to Send (RTS) in AT command interface. 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.
It has no return value.
Example:
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 28 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
MDM2.setRTS(1)
sets RTS to ON in AT command handling.
2.3.12 MDM2.setDTR(DTR_value)
This command sets Data Terminal Ready (DTR) in AT command interface. 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.
It has no return value.
Example:
MDM2.setDTR(0)
sets DTR to OFF in AT command handling.
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 29 of 100
Easy Script in Python
80000ST10020a Rev.8 - 01/10/08
2.4 SER built-in module
SER built-in module is the interface between Python core and the device serial port over the RXD/TXD
pins direct handling. You need to use SER built-in module if you want to send data from Python script
to serial port and to receive data from serial port ASC0 to Python script. This serial port handling
module can be used for example to interface the module with an external device such as a GPS and
read/send its data (NMEA for example). SER built-in module has also been improved lately with the
possibility to control physical lines.
If you want to use SER built-in module you need to import it first:
import SER
then you can use SER built-in module methods like in the following example:
a = SER.set_speed('9600')
b = SER.send('test')
c = SER.sendbyte(0x0d)
d = SER.receive(10)
which sends 'test' followed by <CR> and receives data waiting for one second.
More details about SER built-in module methods can be found in the following paragraphs.
2.4.1 SER.send(string)
This command sends a string to the serial port TXD/RXD. Input parameter string is a Python string
that will be send to serial port ASC0.
Return value is a Python integer which is -1 if an error occurred otherwise is 1.
Example:
a = SER.send('test')
sends string 'test' to serial port ASC0 handling, assigning return value to a.
NOTE: the buffer available for SER.send(string) command is 4096 bytes
5
For the products with the following old Order-Num. 3390250656, 3390250654 and 3990150466 the available
buffer is 2048 bytes
5
Reproduction forbidden without Telit Communications S.p.A. written authorization - All Rights Reserved page 30 of 100
Loading...
+ 70 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.