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

Recommended Answers

All 3 Replies

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.