Você está na página 1de 27

EASY SCRIPT ® FUNCTION

Telit @ M2M Platforms Seminar


www.m2m-platforms.com
e-mail: sales@m2m-platforms.com
Easy Script Extension

The Easy Script Extension is a feature that allows


to drive the modem "internally" writing the
software application directly in a high level language:

PYTHON

The Easy Script Extension is aimed at low complexity


applications where the application was usually done
by a small microcontroller that manage some I/O pins
and the module through the AT command and
interface.

Author: Daniele Scalembra 2007/1


2
Standard Module configuration

EXTERNAL CONTROLLER

FLASH ROM RAM

PHYSICAL AT SERIAL PORT

GSM-GPRS RAM for


AT commands
Protocol Stack GSM-GPRS
FLASH modem
ROM GPRS MODEM Protocol Stack
memory ENGINE

HARDWARE RESOURCES

Author: Daniele Scalembra 2007/1


3
To eliminate the external controller, and further
simplify the programming of the sequence of
operations, the PYTHON powered module includes:

9Python script interpreter engine v. 1.5.2+

9around 3MB of Non Volatile Memory for the user


scripts and data

91.5 MB RAM reserved for Python engine usage

Author: Daniele Scalembra 2007/1


4
Python Powered Module

FLASH ROM RAM


PYTHON INTERPRETER
ENGINE

Available User NVM MDM module Available RAM for


FLASH Memory Python Interpreter
(3Mbyte) (1.5Mbyte)
VIRTUAL INTERNAL
AT SERIAL PORT

GSM-GPRS AT commands RAM for


Protocol Stack GSM-GPRS
FLASH GPRS MODEM modem
ROM ENGINE Protocol Stack
memory

HARDWARE RESOURCES

Author: Daniele Scalembra 2007/1


5
Python implementation description

Python scripts are text files, it’s possible to run only one Python script in the
Telit PY modules

The Python script is stored in NVM inside the 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).

The Python script is executed in a task inside the module at the lowest priority,
making sure this does not interfere with GPRS/GSM normal operations.
This allows serial ports, protocol stack etc. to run independently from the Python
script.

The Python script interacts with the module functionality through build-in
interfaces.

Author: Daniele Scalembra 2007/1


6
Python interfaces

Hardware Resources
antenna

GPRS Modem Engine

Virtual internal AT serial port

MDM2 library MDM library SPI library

IIC library
MOD library Python Engine
GPIO
with UPGRADABLE
software script GPIO library

Print command
SER2 library SER library

Serial port 1 (ASC1*) ex Serial port 0 (ASC0*) ex


TRACE PROG

Author: Daniele Scalembra 2007/1


7
Python interfaces MDM/ new MDM2

MDM and MDM2 interfaces are the most important.


Virtual internal AT serial port
Allows Python script to send AT commands,
MDM2 library MDM library
receive responses and unsolicited indications,
send data to the network and receive data
Python Engine
from the network during connections with UPGRADABLE
software script

Are quite the same as the usual serial port interface


in the Telit modules. Are working in parallel as serial cmux in the Telit modules.

The difference is that this interfaces are not real serial ports but just internal
software bridge between Python and mobile internal AT command handling engine.

All AT commands working in the Telit modules are working in this software
interfaces as well and follow the same rules as per cmux.
Some of them have no meaning on this interface, such as those regarding serial port settings.
The usual concept of flow control keeps its meaning over this interface, but it's managed internally.

Author: Daniele Scalembra 2007/1


8
Python interfaces SER/ new SER2

The SER and SER2* interfaces allows Python script Python Engine
with UPGRADABLE
to read from and write to the REAL physical serial ports, software script

ASC0/ASC1usually AT command and TRACE ports.


For example to read NMEA information from SER2 library SER library

a GPS device, control a device…. Serial port 1 (ASC1*) ex Serial port 0 (ASC0*) ex
TRACE PROG

When Python is running When the AT command 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.

*When Python is running and after SER2 library import TRACE serial port is free
to be used by Python.

No flow control is available from Python on this ports.

*SER2 not available on GPS products


Author: Daniele Scalembra 2007/1
9
Python interface MOD

The MOD interface is a collection of useful functions.


MOD library Python Engine
with UPGRADABLE
software script
MOD built-in module is the interface between Python and
module miscellaneous functions.

You need to use MOD built-in module if you want to generate timers in Python script,
stop Python execution, mange a Python watchdog, manage the power saving mode
from your Python script, etc.
MOD.watchdogxxx(xxx)
MOD.sleep(sleeptime) A set of function to manage a
Blocks Python script execution for Python watchdog .
MOD.secCounter() a given time returning the
This method is useful for timers resources to the system.
generation in Python script. Input parameter timesleep is a
Return value is a Python integer which Python integer which is the time in MOD.powerSavingxxx(xxx)
is the value of seconds elapsed since 1 A set of function to manage in Python
1/10 s to block script execution.
January 1970. the power saving mode .

Author: Daniele Scalembra 2007/1


10
Python interface GPIO

The GPIO interface allows Python script Python Engine


with UPGRADABLE GPIO
to handle general purpose input output software script
GPIO library
Faster than through AT commands, skipping
the command parser and going directly to control the pins.

GPIO built-in module 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 suggested.

Author: Daniele Scalembra 2007/1


11
IIC and SPI built-in module

IIC built-in module is an implementation Python Engine


IIC library
GPIO
On the Python core of the IIC bus with UPGRADABLE
software script
Master (No Multi-Master).
You need to use IIC built-in module if you want to create one or more IIC bus on the
available GPIO pins.

This IIC bus handling module is mapped on creation two GPIO pins that will becom
e the Serial Data and Serial Clock pins of the bus.

It can be multi-instantiated (you can create more than one IIC bus over different pins)
and the pins used must not be used for other purposes.

Note that Python core does not verify if the pins are already used for other purposes
(SPI module or GPIO module) by other functions, it's the applicator responsibility to e
nsure that no conflict over pins occurs.
Author: Daniele Scalembra 2007/1
12
IIC and SPI built-in module

SPI library

SPI built-in module is an implementation on


Python Engine
GPIO
The Python core of the SPI bus Master with UPGRADABLE
software script

You need to use SPI built-in module if you want to create one or more SPI bus on the
available GPIO pins.

This SPI bus handling module is mapped on creation on three or more GPIO pins that
will become the Serial Data In/Out and Serial Clock pins of the bus, plus a number of
optional chip select pins up to 8.

It can be multi-instantiated (you can create more than one SPI bus over different pins)
and the pins used must not be used for other purposes.

Author: Daniele Scalembra 2007/1


13
Python interfaces in GPS modules

Hardware Resources

GPS part GPRS Modem Engine

Virtual internal AT serial port


GPS library
MDM2 library MDM library SPI library

IIC library
Python Engine
GPIO
MOD library with UPGRADABLE
software script GPIO library

Print command SER library

Serial port 0 (ASC0*) ex


PROG

Author: Daniele Scalembra 2007/1


14
Python interfaces GPS

GPS part

GPS built-in module is the interface between


GPS library
Python and mobile internal GPS controller.
Python Engine
with UPGRADABLE
It is used in order to handle GPS controller without dedicated software script
AT commands trough MDM built-in module.

This interface is intended to be able to control GPS part when the MDM module is
busy with other activity (like when GPRS connection is up) and is not possible
use AT Commands.

Using this module you can read position while you are using GPRS capability and
then send this data trough GPRS, typical tracking solution…

Author: Daniele Scalembra 2007/1


15
Debug Python script

When a script is running on a module, debug messages,


and print command (added in the script ) are available on :
Python Engine
with UPGRADABLE
- Serial port ASC1 (no for GPS modules) software script

In GPS modules ASC1 is used internaly to be connected


Print command
and control GPS part.
No after import of SER2, since this moment ASC1 is
avaiable to be managed with SER2 function. Serial port 1 (ASC1*) ex
TRACE

- On highest one of the port of multiplexed Python Engine with


UPGRADABLE software script
Serial port ASC0.
In this case you must run Pcmux application on your pc

Print command SER library

To read this debug you need run a terminal program Serial port 0 (ASC0*) ex PROG

connected to the properly serial port.

Author: Daniele Scalembra 2007/1


16
Executing a single Python script

The steps required to have a script running by the python engine


of the module are:

DOWNLOAD
WRITE the Python ENABLE
the Python Script into the the Python EXECUTE IT
script module NVM script

Author: Daniele Scalembra 2007/1


17
Executing a Python “project”

We call Python “project” a Python program made by a main Python script that calls
functions defined in other Python scripts (typical solution).

For example:
Script main.py calls functions imported from different script like :
-SMSfunction.py
-GPRSfuncion.py
main.py
-GPSfunction.py
- ……
-………
SMSfunction.py GPRSfunction.py GPSfunction.py

Author: Daniele Scalembra 2007/1


18
Executing a Python “project”

In this case to run the “project” we need two steps :

First

WRITE DOWNLOAD
all the functio all these Scripts
n Python Scri into the module
pts NVM

Second

WRITE DOWNLOAD ENABLE


the main this script into the the main EXECUTE IT
Python script module NVM script

Author: Daniele Scalembra 2007/1


19
Executing a Python “project”

ƒ At the first switch on, all the scripts are compiled.


This operation could take time (compiling operation is the longest one) depending
on the scripts complexity.

ƒ Other times only the main is compiled ------- > quicker!

After the complete “compiling operation”, the compiled scripts will have the
extension .pyo

The “functions” source files (.py) could be deleted from NVM if compiled scripts
(.pyo) are present.

Author: Daniele Scalembra 2007/1


20
Updating Your Python script
(YOUR APPLICATION)

The steps required to update a python script (your application) are :

DOWNLOAD ENABLE
DELETE the new Script int the Python scri
the old Script from o the module NV pt
(only if is the main a EXECUTE IT
the module NVM M nd if the name is chang
(py / pyo) (py) ed)

How to do this operation ?


Trough serial port (RS232) using a serial terminal interface.
This could be a problem !!!

Author: Daniele Scalembra 2007/1


21
Updating Your Python script
(YOUR APPLICATION)

APPLICATION ON THE FIELD !

Author: Daniele Scalembra 2007/1


22
Updating Your Python script
(YOUR APPLICATION)

TO UPDATE THE FIRMWARE YOU SHOULD CALL BACK ALL


THE APPLICATIONS !

Author: Daniele Scalembra 2007/1


23
Updating Your Python script
(YOUR APPLICATION)

THE BEST WAY?


UPDATE THE APPLICATION
OVER THE AIR.

Author: Daniele Scalembra 2007/1


24
Updating Your Python script
(YOUR APPLICATION)

Advantages:
ƒ Is not necessary to call back all the applications.
ƒ No physical handling of the applications are required.
ƒ Possible to update all the applications at same time.

How to do the OVER THE AIR update of a Python script ?

In your Python application code you should foresee a step that, if the application
receive an specific update indication (i.e. SMS with specific string ,call from specif
ic number…), an “update function” is executed.
What this “update function” does :

1. Receive the new (updated) script trough :


- CSD connection.
- FTP connection on a server where the new script is stored.

Author: Daniele Scalembra 2007/1


25
Updating Your Python script
(YOUR APPLICATION)

What this “update function” does :

2. Verify the integrity of the new script:


- Extracting the check sum (put at the end of the new script file and calculated
with the md5 function at the moment of the new script creation, do this using
Telit MD5 Digest checksum add to script tool, in Telit Pythonwin).
- Re calculating the check sum locally (using md5 function) .
- Verifying the match of the two results.

3. If the integrity of the script is OK then the new script


is saved in the NVM with a new name.

4. Enable the new Script

5. Reboot the system.

Author: Daniele Scalembra 2007/1


26
Join Telit wireless solutions!

Save money enjoying


TELIT PYTHON MODULES !!!

Author: Daniele Scalembra 2007/1


27

Você também pode gostar