Easy Script in Python 80000ST10020a Rev.
Easy Script in Python 80000ST10020a Rev.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Contents 1 Easy Script Extension - Python interpreter ..................................................................................... 8 1.1 Overview..................................................................................................................................................8 1.2 Python 1.5.2+ Copyright Notice ..........................................................................................................10 1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.4 SER built-in module .............................................................................................................................30 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.4.10 2.4.11 2.4.12 2.4.13 2.5 SER2 built-in module ...........................................................................................................................35 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6 SER2.send(string) ..
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.8.9 2.9 IIC object method: dev_gen_write(addr, start, string) .......................................................................................50 SPI built-in module...............................................................................................................................51 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 2.10 SPI.new(SCLK_pin, MOSI_pin, MISO_pin, , ,…)............................................
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.2.10 4.2.11 4.2.12 4.2.13 4.2.14 4.2.15 4.2.16 4.2.17 4.2.18 4.2.19 4.2.20 4.2.21 4.2.22 4.2.23 4.2.24 4.2.25 4.2.26 4.2.27 4.2.28 4.2.29 4.2.30 4.2.31 4.2.32 4.2.33 4.2.34 4.2.35 5 Operators, statements, functions ........................................................................................................................80 Truth Value Testing ..........................................
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.
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.
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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 1.2 Python 1.5.2+ Copyright Notice The Python code implemented into the module is copyrighted by Stichting Mathematisch Centrum, this is the license: Copyright © 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, The Netherlands. All Rights Reserved Copyright © 1995-2001 Corporation for National Research Initiatives; All Rights Reserved. Copyright (c) 2001-2007 Python Software Foundation; All Rights Reserved.
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.
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.
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.
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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 1.5.2 Operators Python has the following operators: • Arithmetic and bitwise operators + - * / % ** ~ << >> & ^ | • Relational and logical operators is in < <= > >= == != not and or • Assignments = += -= *= /= %= **= <<= >>= &= ^= |= • Other operators () [ ] { } [:] `` . lambda 1.5.
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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 1.5.6 Resources Some useful manuals for Python can be found on the following links: 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.
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 float long docstring Available modules (all others are not supported) marshal imp _main_ _builtin_ sys md5 Reproduction forbidden without Telit Communications S.p.A.
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.
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).
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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 sends byte 0x0d, that stands for , 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.
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.
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.
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.
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.
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 , 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.
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.
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.
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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.4.2 SER.receive(timeout) This command receives a string from serial port TXD/RXD waiting for it until timeout is expired. Return value will be the first string received no matter of how long the timeout is. Input parameter timeout is a Python integer, which is measured in 1/10s, and represents the maximum time of waiting for the string from the serial port ASC0.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.4.5 SER.receivebyte(timeout) This command receives a byte from serial port TXD/RXD waiting for it until timeout is expired. Return value will be the first byte received no matter of how long the timeout is. Input parameter timeout is a Python integer, which is measured in 1/10s, and represents the maximum time of waiting for the string from serial port ASC0.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 sets serial port ASC0 speed to 115200, assigning return value to b. NOTE: in the PythonWin version pervious to TelitPy1.5.2+_V2.1.exe and Python on module version previous to Ver6.03.000 a different syntax is implemented depending of the development environment. For PythonWin application: SER.SetSpeed(speed) without char format parameter. For Python installed on module: SER.set_speed(speed, char format) with char format not an optional parameter. 2.4.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.4.11 SER.setRI(RI_value) This command sets Ring Indicator (RI) in serial port ASC0. Input parameter RI_value is a Python integer which is 0 if RI is set to OFF or 1 if RI is set to ON. It has no return value. Example: SER.setRI(1) sets RI to ON in ASC0. 2.4.12 SER.getRTS() This command gets Request to Send (RTS) from serial port ASC0. It has no input parameter.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.5 SER2 built-in module7 SER2 built-in module is the interface between Python and mobile internal serial port ASC1 direct handling. It is used when you want to send data from Python script to serial port ASC1 and receive data from serial port ASC1 to Python script. SER2 built-in module is available only for non-GPS products.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.5.2 SER2.receive(timeout) This command receives a string from serial port ASC1 waiting for it until timeout is expired. Return value will be the first string received no matter of how long the timeout is. Input parameter timeout is a Python integer, which is measured in 1/10s, and represents the maximum time of waiting for the string from the serial port ASC1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.5.5 SER2.receivebyte(timeout) This command receives a byte from serial port ASC1 waiting for it until timeout is expired. Return value will be the first byte received no matter of how long the timeout is. Input parameter timeout is a Python integer which is measured in 1/10s, and represents the maximum time of waiting for the string from serial port ASC1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.6 GPIO built-in module GPIO built-in module8 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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Return value is a Python integer which is -1 if an error occurred otherwise is input or output value. It is 0 or 1. Example: a = GPIO.getIOvalue(5) gets GPIO 5 input or output value, assigning return value to b. 2.6.3 GPIO.setIOdir(GPIOnumber, value, direction) Sets direction of a GPIO. First input parameter GPIOnumber is a Python integer which is the number of the GPIO. Second input parameter value is a Python integer which is the output value.
Easy Script in Python 2.6.5 GPIO.getADC(adcNumber)9 80000ST10020a Rev.8 - 01/10/08 Gets ADC value in the same way as AT#ADC command. Input parameter adcNumber is a Python integer which represents the ADC number that will be read and converted in voltage. Return value is a Python integer which is -1 if an error occurred otherwise the converted voltage is returned in mV. Example: mV = GPIO.getADC(2) gets ADC number 2 input voltage, assigning return value in mV. 2.6.6 GPIO.
Easy Script in Python 2.6.8 GPIO.getAXE()9 80000ST10020a Rev.8 - 01/10/08 Gets hands free status value in the same way as AT#AXE command. There is no input parameter. Return value is a Python integer that is 0 if a hand free is not connected or 1 if a hand free is connected. Example: hf = GPIO.getAXE() gets AXE value, assigning return value to hf. 2.6.9 GPIO.setSLED(status, onDuration, offDuration) 10 Sets status led configuration values in the same way as AT#SLED does.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 0 - charger not connected 1 - charger connected and charging 2 - charger connected and charging process completed Second element of tuple is a Python integer which is battery voltage in mV. Example: cbc = GPIO.getCBC() gets charger status and battery voltage values, assigning return value to cbc tuple. Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.7 MOD built-in module 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. If you want to use MOD built-in module you need to import it first: import MOD then you can use MOD built-in module methods like in the following example: MOD.sleep(15) this blocks Python script execution for 1.5s.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 blocks Python script for 1.5 s. NOTE: the parameter sleeptime can assume integer values is in the following range [0,32767] 2.7.3 MOD.watchdogEnable(timeout) 11 Protects system against script blocking by performing automatic reboot of the module when the watchdog reaches determined value. Input parameter timeout is an integer, which is measured in seconds and represents time to waiting before executing software restart. No return value. Example: MOD.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Disables Python watchdog. 2.7.6 MOD.powerSaving(timeout) 11 This new feature allows Python to put the system in power saving mode12 for a certain period or until an external event13 occurs in the same way as AT command AT+CFUN=0 does. Input parameter timeout is an integer, which is measured in seconds and represents time for which the Python script remains blocked.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.8 IIC built-in module IIC built-in module14 is an implementation on the Python core of the IIC bus15 Master (No Multi-Master) using the "bit-banging" technique. 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 on two GPIO pins that will become the Serial Data and Serial Clock pins of the bus.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 This creates one IIC bus over the lines SDA=GPIO3 and SCL=GPIO4 with default address 0x50. If no address defined, the address anyway can be feed with the readwrite() function as first part of the string. NOTE: available pins for the IIC bus are GPIO1 - GPIO13. The only exception is the module family GM862 where available pins are GPIO2 - GPIO13 where GPIO2 must be used only for output. 2.8.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 ret = myIIC1.readwrite('\x08', 14) # Random read print ' RANDOM READ FROM ADDR = 0x08, 14 bytes: %s' % ret #MOD.sleep(5) print ' Writing DATA= "hello!" from ADDR = 0x00' myIIC1.readwrite('\x00'+ 'hello!', 0) #MOD.sleep(5) print ' SETTING CURRENT ADDRESS = 0x00' if myIIC1.readwrite('\x00',0) == -1: print 'Error acknowledged' #MOD.sleep(5) ret = myIIC1.readwrite('', 22) # Current address read print ' CURRENT ADDR READ = 0x00, 22 bytes: %s' % ret MOD.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Return value is a Python integer which is -1 if an error occurred otherwise is 1 if all bytes of the string have been acknowledged by the slave. Example: a = bus1.send('test') sends string 'test' to the IIC bus , assigning return result value to a. 2.8.6 IIC object method: dev_read(addr, len) Receives a string of len bytes from IIC bus device at address addr. Return value is a Python string which is containing data received. Example: a = bus1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.8.9 IIC object method: dev_gen_write(addr, start, string) Sends a string to the IIC bus device whose address is addr, starting from address start. Return value is a Python string which is 1 if data is acknowledged correctly, -1 otherwise. Example: a = bus1.dev_gen_write(114, 112, '123456789') sends the string '123456789' to the IIC bus device at address 114, starting from address 112, assigning the result to a.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.9 SPI built-in module SPI built-in module17 is an implementation on the Python core of the SPI bus Master using the "bitbanging" technique. 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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 The SS_pin is optional because not all SPI devices have a Slave Select line, otherwise named Chip Select (CS) line. Return value is the Python custom SPI object pointer that will be used further to interface with this specific SPI object created. Example: mySPIobject = SPI.new(6, 7, 8, 9, 10) Creates an SPI object “mySPIobject” where SCLK=GPIO6, MOSI=GPIO7, MISO=GPIO8 and SS0=GPIO9, SS1=GPIO10 NOTE: available pins for the SPI bus are GPIO1 - GPIO13.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Example: status = mySPIobject.init(0, 0, 0) In this initialization no SS line is defined as default, and no SS line will be moved if not set in readwrite function. status = mySPIobject.init(0, 0, 0, 1) In this initialization the SS=1 refers to the use of SS1, already defined in SPI.new(6, 7, 8, 9, 10) as GPIO10. status = mySPIobject.init(0, 0, 0, 0) In this initialization the SS=0 refers to the use of SS0, already defined in SPI.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 CMD_RESET = '\xC0' REG_ADDR_X = '\x0E' #this value is not the value for any SPI device, but for tested one only! REG_ADDR_Y = '\x0F' #this value is not the value for any SPI device, but for tested one only! TWO_READ_ACCESS = '\x00\x00' # string of the length equal to the number of bytes to receive MySPI1 = SPI.new (3,10,8,6) # (SCLK, MOSI, MISO, SS0) MySPI1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 b=bus4.sendbyte(111,1) sends byte 111 to the SPI bus activating the Slave Select line of the SS1 device (in our example GPIO10) 2.9.5 SPI object method: readbyte() NOTE: We advice to use the new readwrite (2.9.3) method to send bytes or strings. Receives a byte from the SPI bus device at Slave Select number SS_number.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Receives a string of len bytes from SPI bus device at Slave Select number SS_number. Input optional parameter SS_number is a Python byte representing the Slave number to be activated; if not present no slave line is activated. Return value is a Python string that contains received data. Example: a = bus4.read(10,0) receives a string of 10 bytes from SPI bus device on SS0 line, assigning it to a. Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.10 GPS19 built-in module GPS built-in module is the 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. If you want to use GPS built-in module you need to import it first: import GPS After this you can start using GPS built-in module methods like in the following example: position = GPS.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.10.3 GPS.resetMode(mode) This module resets GPS controller in the same way as AT command: AT$GPSR. Input parameter mode is a Python integer and can have the following values: • 0 for Hardware reset • 1 for Coldstart (No Almanac, No Ephemeris); • 2 for Warmstart (No Ephemeris); • 3 for Hotstart (with stored Almanac and Ephemeris). Return value is a Python integer which is -1 if an error occurred otherwise is 1. Example: res = GPS.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Return value is a Python string which is the last position information formatted in the same way as for AT$GPSACP command response. Example: lastPosition = GPS.getActualPosition() gets GPS last position information, assigning return value to lastPosition. 2.10.7 GPS.powerSavingMode(mode, pushToFixPeriod) This module sets GPS controller power saving mode in the same way as AT command AT$GPSPS.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Return value is a Python string which is the last GGA NMEA sentence formatted according to NMEA specification. Example: gga = GPS.getLastGGA() gets last GGA NMEA sentence, assigning return value to gga. 2.10.10 GPS.getLastGLL() This command gets GPS last GLL NMEA sentence stored. It has no input parameter. Return value is a Python string which is the last GLL NMEA sentence formatted according to NMEA specification. Example: gll = GPS.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 2.10.13 GPS.getLastRMC() This command gets GPS last RMC NMEA sentence stored. It has no input parameter. Return value is a Python string which is the last RMC NMEA sentence formatted according to NMEA specification. Example: rms = GPS.getLastRMC() gets last RMC NMEA sentence, assigning return value to rmc. 2.10.14 GPS.getLastVTG() This command gets GPS last VTG NMEA sentence stored. It has no input parameter.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3 Python Script Operations 3.1 Executing a Python script The steps required to have a script running by the python engine of the module are: • • • • write the python script; download the python script into the module NVM; enable the python script; execute the python script. 3.1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 The script can be downloaded on the module using the #WSCRIPT command. In order to guarantee your company know-how, you have the option to hide the script text so that the #RSCRIPT command does not return the text of the script and keeps it "confidential", you can see only the name of the script with the #LSCRIPT command.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 For example: AT#WSCRIPT=”a.py”,110 wait for the prompt >>> and use “Send Text file” with ASCII Setup: “Send line ends with line feeds” and “Append line feeds to incoming line ends” in HyperTerminal “Properties” enabled. Wait for download result: OK or ERROR. TIP: If download result gives ERROR check if the script name (remember that it is case sensitive) or the file size are correct.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 If instead of Hyper Terminal you use Procomm Plus application the script text should be sent using “Send File”, selecting “Raw ASCII” or “ASCII” as Transfer Protocol. If you use “ASCII” transfer protocol, be sure the options “Expand tabs” and “Expand black lines” are not selected. 3.1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 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.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3.1.5 Reading Python script Command: AT#RSCRIPT=“< script_name >“ • < script_name >: file name With the following command AT#RSCRIPT you can read a saved script text. The script text read can be saved using “Capture Text” in HyperTerminal or “Capture File” in Procomm Plus application. Port settings should be baud rate 115200bps and hardware flow control.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 NOTE: Commands used to write, read and delete script like AT#WSCRIPT, AT#LSCRIPT, AT#RSCRIPT and AT#DSCRIPT can be applied on any type of file, not necessary an executable Python script. (example: received data files) 3.1.8 Restart Python script Command: AT#REBOOT This is an execution command that causes the restart of the module and execution of the active script on the start-up. Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3.2 Run AT Interface and Python at the same time With new start mode for Python it is possible to use standard AT command interface on ASC0 and run a Python script at the same time.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3.3 Debug Python script The debug of the active Python script can be done both on the emulated environment of the Telit Python Package (refer to its documentation) or directly on the target with the second serial port pin EMMI TX (actually a not translated RS232 serial port as the RXD pin). Connect to the module serial port EMMI TX at 115200 8-N-1 with hardware flow control active.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 • close any application controlling the serial ports and install the Python Debug application (please contact our technical support to get Python Debug application) NOTE: if an error messages appears during the installation, it will be necessary to close any application controlling the serial ports • the following box should appear when you run the Pythondebug.exe for the first time: • Select the Setup option.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 • Then select a Virtual COM, different from the other COM ports preferably (“COM8” in the figure), and associate to it the first SSC device that appearing in the list (“Data Module EVK2A” in the figure), • the following figure should appear: NOTE: If the PC uses the EVK2 RS232 upper port (ASC0) to send AT commands, remember to put all jumpers to set RS232 mode.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3.3.1.2 Debugging process After the successful installation of the drivers process of direct debugging of the Telit GPS modules can start. The steps are the following: • • • • • • Switch on the module and activate the SSC output with the following AT command: AT#SSCTRACE=1 Download and enable your Python script, then power OFF the module. to be sure that DTR input to the module is HIGH disconnect the RS232 cable from the module side (i.e.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 3.3.2 Debug Python script on GPS modules using CMUX CMUX (Converter-Multiplexer) is a multiplexing protocol implemented in the Telit module that can be used to send data, SMS, fax, TCP data. The Multiplexer mode enables one serial interface to transmit data to four different customer applications form which one is dedicated to Python debug. This is achieved by providing four virtual channels using a Multiplexer (Mux).
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 • Switch ON the module and with a terminal emulator (e.g. Hyper Terminal) and send the following commands to the module: AT#SSCTRACE=0 disabled SSC output AT#CMUXSCR=1, bit rate (e.g.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 Control if the Setup options are the following: Set the Module Main Port as the real COM port you have available (e.g. COM1 in the figure), check the Python box and then select the Apply button. • After this step, you will have 4 new Telit Serial Port Mux ports (see Control Panel – System – Hardware – Device Manager) as in the figure below: Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 • Run a terminal emulator application (e.g.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 After 10 seconds you should see the script starting and the debug info appearing on the terminal emulator window. • • If an ERROR messages appears in the Virtual Port #1,2,3,4 boxes, close any application controlling the serial ports and then restart the Telit CMUX application. If this procedure is not sufficient to avoid ERROR message, reset the PC, run again Telit Serial Port Mux with the same settings and repeat the procedure as described above.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4 Python standard functions In this paragraph you can find detailed description of Python language supported features in Data Terminal Modules. Note that all the functions listed below are available in the Python version is 1.5.2+. 4.1 Technical characteristics 4.1.1 General All Python statements and almost all Python built-in types and functions are supported.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2 Python supported features Refer to the documents available online such as: Python 1.5.2 Tutorial, Python 1.5.2 Reference Manual or Python 1.5.2 Library Reference for further details for all the features listed in the paragraphs below. 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 • exec statement 4.2.2 Truth Value Testing Truth value testing is supported. 4.2.3 Boolean Operations The following Boolean operations are supported: x or y x and y not x 4.2.4 Comparisons The following comparisons are supported: < <= > >= == <> != is is not 4.2.5 Numeric Types: Integers The following operations are supported with the integer type: x+y x-y x*y x/y Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 x%y -x +x abs(x) int(x) long(x) divmod(x, y) pow(x, y) x ** y x|y x^y x&y x << n x >> n ~x 4.2.6 Numeric Types: Long Integers The following operations are supported with long integers: x+y x-y x*y x/y x%y -x +x abs(x) int(x) long(x) divmod(x, y) pow(x, y) x ** y x|y x^y x&y x << n x >> n ~x Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.7 Numeric Types: Float Floating point numbers are not supported. 4.2.8 Numeric Types: Complex Complex numbers are not supported. 4.2.9 Sequence Types: Strings The following operations are supported with the string type: x in s x not in s s+t s * n, n * s s[i] s[i:j] len(s) min(s) max(s) The only difference between Python version 1.5.2+ and 1.5.2 is that strings are objects that support the following methods: s.capitalize() s.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 s.strip() s.swapcase() s.translate(table[, deletechars]) s.upper() The following attribute is supported: __methods__ For string methods refer to Python 2.0.1 Library Reference for further details. 4.2.10 Sequence Types: Tuples The following operations are supported with the tuples: x in s x not in s s+t s * n, n * s s[i] s[i:j] len(s) min(s) max(s) 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 max(s) s[i] = x s[i:j] = t del s[i:j] s.append(x) s.extend(x) s.count(x) s.index(x) s.insert(i, x) s.pop([i]) s.remove(x) s.reverse() s.sort([cmpfunc]) The following attribute is supported: __methods__ 4.2.12 Mapping Types: Dictionaries The following operations are supported with the dictionaries: len(a) a[k] a[k] = x del a[k] a.clear() a.copy() a.has_key(k) a.items() a.keys() a.update(b) a.values() a.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.13 Other Built-in Types: File Objects The following methods are supported with the file objects: f.close() f.flush() f.isatty() f.fileno() f.read([size]) f.readline([size]) f.readlines([sizehint]) f.seek(offset[, whence]) f.tell() f.write(str) f.writelines(list) The following method is not supported: f.truncate([size]) The following attributes are supported: __methods__ softspace mode name closed 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.15 Other Built-in Types: Classes Classes objects, class attribute access and class instances are supported. The following attributes are supported: __dict__ __name__ __bases__ __module__ The following attributes are supported by class methods: im_func im_self im_class The following special methods are supported: __init__(self [, args...
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.17 Other Built-in Types: Methods Methods objects are supported with the following attributes: __name__ __self__ 4.2.18 Other Built-in Types: Type Objects Type objects are supported. 4.2.19 Other Built-in Types: Null Object Null object is supported. 4.2.20 Other Built-in Types: Ellipsis Object Ellipsis object is supported. 4.2.21 Other Built-in Types: Buffer Objects Buffer objects are supported. 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.23 Other Built-in Internal Types: Code Objects Code objects and code object execution is supported with the following attributes: co_argcount co_nlocals co_stacksize co_flags co_code co_consts co_names co_varnames co_filename co_name co_firstlineno co_lnotab 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 tb_next tb_frame tb_lasti tb_lineno 4.2.26 Other Built-in Internal Types: Slice Objects Slice objects are supported with the following attributes: start stop step 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 SyntaxError SystemError SystemExit UnboundLocalError TypeError ValueError ZeroDivisionError RemovedFeatureError is an exception added in Python version 1.5.2+. RemovedFeatureError is raised when trying to use floats or complex that are not supported. Exceptions are strings objects. If file exceptions.py is downloaded to Data Terminal Module Python than module exceptions is automatically imported at the scripts start and exceptions are class objects. 4.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 apply(function, args[, keywords]) buffer(object[, offset[, size]]) chr(i) dir([object]) getattr(object, name[, default]) hasattr(object, name) hash(object) hex(x) id(object) isinstance(object, class) len(s) list(sequence) map(function, list, ...) max(s[, args...]) min(s[, args...
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 4.2.30 Built-in Modules: imp Built-in imp module is supported with the following methods: find_module(name[, path]) get_magic() get_suffixes() load_module(name, file, filename, description) new_module(name) The following constants are supported: PY_SOURCE PY_COMPILED C_BUILTIN PY_FROZEN 4.2.31 Built-in Modules: __main__ Built-in __main__ module is supported. 4.2.32 Built-in Modules: __builtin__ Built-in __builtin__ module is supported. 4.2.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 The following variables are supported: stdin stdout stderr __stdin__ __stdout__ __stderr__ version hexversion copyright platform executable prefix exec_prefix maxint builtin_module_names removed_features argv exc_type exc_value exc_traceback exitfunc last_type last_value last_traceback modules path tracebacklimit The variables hexversion and removed_features are variables added in Python version 1.5.2+.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 The following methods are supported: update(arg) digest() copy() 4.2.35 Library Modules Most of Python Library Modules are not supported because they depend on Operative System. Basically if a library module imports OS that module is not supported. Some library modules do not depend on Operative System and are supported. An example is string.py. Reproduction forbidden without Telit Communications S.p.A.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 5 Python notes 5.1 Memory Limits In order to prevent memory error, in phase of compilation or execution of the script, we advise you to consider the following limits: • allocated memory for each variable • number of the variables that can cause RAM overflow. The memory available on Telit Python modules includes: • around 2MB of Non Volatile Memory for the user scripts and data • 1.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 All these names are included in the main script and in all the files .py called directly or indirectly by the main. The number of names that can be loaded at each startup from the Python task is around 500. We advise you to use the same variable names in different .py files of the same project, in case this is possible. The recommended dimension of the compiled file .
Easy Script in Python 80000ST10020a Rev.
Easy Script in Python 80000ST10020a Rev.
Easy Script in Python 80000ST10020a Rev.8 - 01/10/08 7 Document Change Log Revision ISSUE#0 ISSUE#1 Date 21/03/06 13/09/06 ISSUE#2 16/03/07 ISSUE#3 24/05/07 ISSUE#4 ISSUE#5 ISSUE#6 07/09/07 25/10/07 07/12/07 ISSUE#7 19/12/07 ISSUE#8 01/10/08 Changes Release First ISSUE#1 1.4 Python Implementation Description: added SPI and IIC libraries that were missing on the graphic 2.4 MOD built-in module: added Python watchdog and power saving mode 2.