Rainbow Electronics GM862-GPS User Manual

Page 66

Advertising
background image





Easy Script

in Python

80000ST10020a Rev.8 - 01/10/08

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

page 66 of 100

In order to gain again the AT command interface on the modem physical port (for example to update
locally a new script) the module shall be powered on with the DTR line HIGH (0V at the module DTR
pin) so that the script is not executed and the Python engine is stopped. The real execution of the
Python script is delayed from the power on due to the time needed by Python to parse the script. The
longer is the script, the longer is this delay.

NOTE: that only the running script is compiled at run time, all the others that this script may include
are compiled once and the compiled result is saved in the NVM as a file with extension .pyo. This
delay can be greatly reduced with a simple stratagem:

• type your script normally, and include the main loop in a function, for example "main()", save it

to the NVM of the module with a known name, for example appl.py

• write a new script that includes the previous file object, for example "import appl", and this file

should call only the main function of the appl.py script, for example main().


In this way the first time the script is executed the imported files will be compiled and the result saved
as compiled .pyo files (don't delete them during normal operations, but remember to delete them if you
change the corresponding .py script otherwise your changes will not take effect). From the next start-
up and in every future start-up the imported files will not be anymore compiled and script execution
delay is greatly reduced.

This trick is useful also for long complex scripts, which may run out of memory during compilation;
splitting the script into several smaller scripts containing part of the functions/objects definitions will
separate the compilation and allow for much bigger script usage.

Advertising