Electronics Lab Philippines

python 2.6 (help!!! po sa program)

python 2.6 (help!!! po sa program)
« on: January 20, 2011, 07:16:39 PM »
mga bro's.

need help po

...kung ano po yung tamang algorithm sa pag receive ng sms. we are using a python 2.6 program.. we need to get the data message from a phone. na-a access naman namin yung message from the phone pero kulang, imbes na 7 messages, 3 lang ang pinapakita nya..

eto po yung program.





import serial
import time

# configure the serial connections (the parameters differs on the device you are connecting to)
ser = serial.Serial(
        port='/dev/ttyUSB0',
        baudrate=9600,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=
)
ser.close()
ser.open()
if ser.isOpen():       
        ser.write('at\r');
        s = ser.readline();     s = ser.readline()
        s = s.strip() #cut the newline or spaces at end
        if s == 'OK':
                print 'Connection is made.\n'
                ser.write('AT+CMGF=1\r') # AT command to switch to text mode
                ser.write('AT+CPMS="me","sm"\r')                 #.. //this line po ba ang may problem  Huh  //
                s = ser.readline();     s = ser.readline(); s = s.strip()
                print '\nMESSAGES: \n'
                if s == 'OK':
                        ser.write('AT+CMGL="ALL"\r');
                        s = ser.readline(); msg = ''# initialize message
                        while msg != 'OK':
                                s = ser.readline()
                                s = s.strip()
                                msg = s
                                print msg
        else:
                print 'Connection failed.'
        ser.close()
else:
        pass