Escolar Documentos
Profissional Documentos
Cultura Documentos
PYTHON
EXTERNAL CONTROLLER
HARDWARE RESOURCES
HARDWARE RESOURCES
Python scripts are text files, it’s possible to run only one Python script in the
Telit PY modules
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.
Hardware Resources
antenna
IIC library
MOD library Python Engine
GPIO
with UPGRADABLE
software script GPIO library
Print command
SER2 library SER library
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.
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
a GPS device, control a device…. Serial port 1 (ASC1*) ex Serial port 0 (ASC0*) ex
TRACE PROG
*When Python is running and after SER2 library import TRACE serial port is free
to be used by Python.
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 .
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.
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
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.
Hardware Resources
IIC library
Python Engine
GPIO
MOD library with UPGRADABLE
software script GPIO library
GPS part
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…
To read this debug you need run a terminal program Serial port 0 (ASC0*) ex PROG
DOWNLOAD
WRITE the Python ENABLE
the Python Script into the the Python EXECUTE IT
script module NVM script
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
First
WRITE DOWNLOAD
all the functio all these Scripts
n Python Scri into the module
pts NVM
Second
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.
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)
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.
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 :