| | |
python program with italian explanation ,
Thread Solved |
if somebody can explain it in english
Thanks
Il sorgente che segue va copiato e salvato in un file con estensione .py ad esempio IO_SMS.py
#Importo i moduli
import MDM
import GPIO
import MOD
#VARIABILI
GSMNUMBER="xxxxxxxxxx" #Numero del destinatario dell'SMS
SMSMESSAGE="Il modem Telit con python ti scrive
" #Messaggio dell'SMS inviato
#SETTO LA DIREZIONE DEI PORT
r=GPIO.setIOdir(5,0,1) #Setto GPIO5 come output e come valore di default 0
r=GPIO.setIOdir(6,0,1) #Setto GPIO6 come output e come valore di default 0
r=GPIO.setIOdir(7,0,1) #Setto GPIO7 come output e come valore di default 0
r=GPIO.setIOdir(4,0,0) #Setto GPIO4 come input
#lampeggio d'avvio
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
#Abilito la modalità testo del modem
res = MDM.send('AT+CMGF=1\r', 0) #Invio comando AT
res = MDM.receive(3) #Attendo 3 sec
if(res.find('OK') != -1): #Ricevuto "OK"
while (1): #Ciclo infinito
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6
if(GPIO.getIOvalue(4)==0): #Verifico lo stato del port GPIO4
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5
TXbuff="AT+CMGS=\"%s\"\r" % (GSMNUMBER)
res = MDM.send(TXbuff, 0)
res = MDM.receive(2) #Attendo 2 sec
if(res.find('>') != -1): # se ricevo il prompt
TXbuff = SMSMESSAGE + chr(26) + "\r" #appendo CTRL + Z
res = MDM.send(TXbuff, 0) #invio la stringa al modem
res = MDM.receive(3) #Attendo 3 sec
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6
MOD.sleep(10) #Pausa per un secondo
else: #Non ho ricevuto "OK"
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
Thanks
Il sorgente che segue va copiato e salvato in un file con estensione .py ad esempio IO_SMS.py
#Importo i moduli
import MDM
import GPIO
import MOD
#VARIABILI
GSMNUMBER="xxxxxxxxxx" #Numero del destinatario dell'SMS
SMSMESSAGE="Il modem Telit con python ti scrive
" #Messaggio dell'SMS inviato#SETTO LA DIREZIONE DEI PORT
r=GPIO.setIOdir(5,0,1) #Setto GPIO5 come output e come valore di default 0
r=GPIO.setIOdir(6,0,1) #Setto GPIO6 come output e come valore di default 0
r=GPIO.setIOdir(7,0,1) #Setto GPIO7 come output e come valore di default 0
r=GPIO.setIOdir(4,0,0) #Setto GPIO4 come input
#lampeggio d'avvio
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
#Abilito la modalità testo del modem
res = MDM.send('AT+CMGF=1\r', 0) #Invio comando AT
res = MDM.receive(3) #Attendo 3 sec
if(res.find('OK') != -1): #Ricevuto "OK"
while (1): #Ciclo infinito
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6
if(GPIO.getIOvalue(4)==0): #Verifico lo stato del port GPIO4
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5
TXbuff="AT+CMGS=\"%s\"\r" % (GSMNUMBER)
res = MDM.send(TXbuff, 0)
res = MDM.receive(2) #Attendo 2 sec
if(res.find('>') != -1): # se ricevo il prompt
TXbuff = SMSMESSAGE + chr(26) + "\r" #appendo CTRL + Z
res = MDM.send(TXbuff, 0) #invio la stringa al modem
res = MDM.receive(3) #Attendo 3 sec
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6
MOD.sleep(10) #Pausa per un secondo
else: #Non ho ricevuto "OK"
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7
MOD.sleep(10) #Pausa per un secondo
•
•
Join Date: Jun 2007
Posts: 4
Reputation:
Solved Threads: 1
Dunno what this is about. Just translating verbatim. Hope it helps!
Il sorgente che segue va copiato e salvato in un file con estensione .py ad esempio IO_SMS.py
En - The following source has to be copied and saved in a .py extension file, for example IO_SMS.py
#Importo i moduli En- It imports the modules
import MDM
import GPIO
import MOD
#VARIABILI En- variables
GSMNUMBER="xxxxxxxxxx" #Numero del destinatario dell'SMS En- Number of the SMS receiver
SMSMESSAGE="Il modem Telit con python ti scrive " #Messaggio dell'SMS inviato En- Text of the sent SMS ("The modem Telit with python is writing to you")
#SETTO LA DIREZIONE DEI PORT En- Ports (Data flow) Direction Settings
r=GPIO.setIOdir(5,0,1) #Setto GPIO5 come output e come valore di default 0 En- It sets GPIO5 as output with default value 0
r=GPIO.setIOdir(6,0,1) #Setto GPIO6 come output e come valore di default 0 En- It sets GPIO6 as output with default value 0
r=GPIO.setIOdir(7,0,1) #Setto GPIO7 come output e come valore di default 0 En- It sets GPIO7 as output with default value 0
r=GPIO.setIOdir(4,0,0) #Setto GPIO4 come input En- It sets GPIO4 as input
#lampeggio d'avvio En- start phase blinking
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5 En- It turns on the LED on GPIO5
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6 En- It turns on the LED on GPIO6
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5 En- It turns off the LED on GPIO5
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6 En- It turns off the LED on GPIO6
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
#Abilito la modalità testo del modem En- It enables the modem's text mode
res = MDM.send('AT+CMGF=1\r', 0) #Invio comando AT En- It sends the AT command
res = MDM.receive(3) #Attendo 3 sec En- It waits 3 seconds
if(res.find('OK') != -1): #Ricevuto "OK" En- "OK" Received
while (1): #Ciclo infinito En- Neverending loop
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6 En- It turns on the LED on GPIO6
if(GPIO.getIOvalue(4)==0): #Verifico lo stato del port GPIO4 En- It checks the status of the GPIO4 port
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5 En- It turns on the LED on GPIO5
TXbuff="AT+CMGS=\"%s\"\r" % (GSMNUMBER)
res = MDM.send(TXbuff, 0)
res = MDM.receive(2) #Attendo 2 sec En- It waits 2 seconds
if(res.find('>') != -1): # se ricevo il prompt En- If prompted
TXbuff = SMSMESSAGE + chr(26) + "\r" #appendo CTRL + Z En- It appends Ctrl + Z
res = MDM.send(TXbuff, 0) #invio la stringa al modem En- It sends the string to the modem
res = MDM.receive(3) #Attendo 3 sec En- It waits 3 seconds
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5 En- It turns off the LED on GPIO5
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6 En- It turns off the LED on GPIO6
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
else: #Non ho ricevuto "OK" En- It has not received "OK"
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
Il sorgente che segue va copiato e salvato in un file con estensione .py ad esempio IO_SMS.py
En - The following source has to be copied and saved in a .py extension file, for example IO_SMS.py
#Importo i moduli En- It imports the modules
import MDM
import GPIO
import MOD
#VARIABILI En- variables
GSMNUMBER="xxxxxxxxxx" #Numero del destinatario dell'SMS En- Number of the SMS receiver
SMSMESSAGE="Il modem Telit con python ti scrive " #Messaggio dell'SMS inviato En- Text of the sent SMS ("The modem Telit with python is writing to you")
#SETTO LA DIREZIONE DEI PORT En- Ports (Data flow) Direction Settings
r=GPIO.setIOdir(5,0,1) #Setto GPIO5 come output e come valore di default 0 En- It sets GPIO5 as output with default value 0
r=GPIO.setIOdir(6,0,1) #Setto GPIO6 come output e come valore di default 0 En- It sets GPIO6 as output with default value 0
r=GPIO.setIOdir(7,0,1) #Setto GPIO7 come output e come valore di default 0 En- It sets GPIO7 as output with default value 0
r=GPIO.setIOdir(4,0,0) #Setto GPIO4 come input En- It sets GPIO4 as input
#lampeggio d'avvio En- start phase blinking
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5 En- It turns on the LED on GPIO5
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6 En- It turns on the LED on GPIO6
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5 En- It turns off the LED on GPIO5
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6 En- It turns off the LED on GPIO6
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
#Abilito la modalità testo del modem En- It enables the modem's text mode
res = MDM.send('AT+CMGF=1\r', 0) #Invio comando AT En- It sends the AT command
res = MDM.receive(3) #Attendo 3 sec En- It waits 3 seconds
if(res.find('OK') != -1): #Ricevuto "OK" En- "OK" Received
while (1): #Ciclo infinito En- Neverending loop
s=GPIO.setIOvalue(6,1) #Accendo il led su GPIO6 En- It turns on the LED on GPIO6
if(GPIO.getIOvalue(4)==0): #Verifico lo stato del port GPIO4 En- It checks the status of the GPIO4 port
s=GPIO.setIOvalue(5,1) #Accendo il led su GPIO5 En- It turns on the LED on GPIO5
TXbuff="AT+CMGS=\"%s\"\r" % (GSMNUMBER)
res = MDM.send(TXbuff, 0)
res = MDM.receive(2) #Attendo 2 sec En- It waits 2 seconds
if(res.find('>') != -1): # se ricevo il prompt En- If prompted
TXbuff = SMSMESSAGE + chr(26) + "\r" #appendo CTRL + Z En- It appends Ctrl + Z
res = MDM.send(TXbuff, 0) #invio la stringa al modem En- It sends the string to the modem
res = MDM.receive(3) #Attendo 3 sec En- It waits 3 seconds
s=GPIO.setIOvalue(5,0) #Spengo il led su GPIO5 En- It turns off the LED on GPIO5
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(6,0) #Spengo il led su GPIO6 En- It turns off the LED on GPIO6
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
else: #Non ho ricevuto "OK" En- It has not received "OK"
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,0) #Spengo il led su GPIO7 En- It turns off the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
s=GPIO.setIOvalue(7,1) #Accendo il led su GPIO7 En- It turns on the LED on GPIO7
MOD.sleep(10) #Pausa per un secondo En- Pause for a second
![]() |
Similar Threads
- Starting Python (Python)
- I Need Help Writing A Word Count Program In My Python (Python)
- running a process from a python program (Python)
- Need help with a simple python program (Python)
Other Threads in the Python Forum
- Previous Thread: PyQt and Qt Designer: KActionSelector
- Next Thread: Reverse Data File
| Thread Tools | Search this Thread |
abrupt accessdenied anti apache application approximation argv array beginner book builtin calculator change converter countpasswordentry curved dan08 dictionaries dictionary dynamic edit enter examples file float format function gui homework import inches input java keyboard lapse launcher library line lines linux list lists loop microphone mouse movingimageswithpygame mysqlquery newb number numbers numeric output parameters parsing path phonebook plugin port prime programming projects py2exe pygame pyopengl pysimplewizard python random recursion redirect remote reverse scrolledtext session simple software sprite statictext string strings syntax table terminal text textarea thread threading time tlapse trick tuple tutorial twoup ubuntu unicode unit urllib urllib2 variable wordgame wxpython






