944,116 Members | Top Members by Rank

Ad:
  • Python Discussion Thread
  • Marked Solved
  • Views: 2383
  • Python RSS
Jun 19th, 2007
0

python program with italian explanation ,

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ThePATRIOT is offline Offline
6 posts
since May 2007
Jun 19th, 2007
0

Re: python program with italian explanation ,

Moderator
Reputation Points: 1333
Solved Threads: 1404
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jun 25th, 2007
0

Re: Just translating verbatim

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
Reputation Points: 10
Solved Threads: 2
Newbie Poster
demetrio is offline Offline
4 posts
since Jun 2007
Jun 27th, 2007
0

Re: python program with italian explanation ,

Tnx a lot :}
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ThePATRIOT is offline Offline
6 posts
since May 2007

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Python Forum Timeline: PyQt and Qt Designer: KActionSelector
Next Thread in Python Forum Timeline: Reverse Data File





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC