summaryrefslogtreecommitdiffstats
path: root/Handler
diff options
context:
space:
mode:
authortt412011-07-07 05:26:22 +0200
committertt412011-07-07 05:26:22 +0200
commit478182c75a96ef924de7149647379c40044c73ab (patch)
tree07c682b8688e9be028745481912a0417dc482b9e /Handler
parentedit password for DB.remember to use our default password. (diff)
downloadgsm-selftest-478182c75a96ef924de7149647379c40044c73ab.tar.gz
gsm-selftest-478182c75a96ef924de7149647379c40044c73ab.tar.xz
gsm-selftest-478182c75a96ef924de7149647379c40044c73ab.zip
add weekly test folder. also store files for test on July 7, 2011.
Diffstat (limited to 'Handler')
-rw-r--r--Handler/gsmcall_.py95
-rw-r--r--Handler/gsmincom_.py138
2 files changed, 233 insertions, 0 deletions
diff --git a/Handler/gsmcall_.py b/Handler/gsmcall_.py
new file mode 100644
index 0000000..1e2a010
--- /dev/null
+++ b/Handler/gsmcall_.py
@@ -0,0 +1,95 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import MySQLdb
+import subprocess
+
+import classServer
+
+from time import sleep
+from datetime import datetime
+import string
+
+
+stop ="false"
+
+LOG_LEVEL=2
+current_call = None
+success = ""
+
+
+
+while stop <> "true":
+
+
+ try:
+ global ser
+ portAddress = '/dev/ttyUSB1'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+ ser.open()
+
+
+ server = classServer.ServerHandler(50097)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ server.sendData('I am ready')#send message to controller
+ print "here:", server.connected
+
+ while 1:
+ try:
+ data = server.receiveData() # waiting mode, until receiver start message or terminate message
+
+ if data == "start": # if receiver start message, handler start to call destination
+
+ while 1:
+
+ num = server.receiveData() # waiting destination number
+ if num <> "":
+
+ callBackNumber=
+ ser.write('ATD' + num + ';\r')
+ sleep(5)
+ server.sendData('success')
+ ser.write('AT+CHUP\r')
+ break
+
+ if data == "terminated": # will terminate the handler if controller send terminate message
+ stop = "true"
+ break
+
+ except ValueError:
+ print "error when sending message"
+ server.closeConnection()
+ del server
+ ser.close()
+
+ server.closeConnection()
+ del server
+ ser.close()
+
+ except ValueError:
+ print "Exception: " + str(e)
+
+print "Goodbye"
+sleep(3)
diff --git a/Handler/gsmincom_.py b/Handler/gsmincom_.py
new file mode 100644
index 0000000..018bede
--- /dev/null
+++ b/Handler/gsmincom_.py
@@ -0,0 +1,138 @@
+import sys
+import pjsua as pj
+import socket
+import time
+import os
+import string
+import classServer
+
+from time import sleep
+from datetime import datetime
+
+stop ="false"
+
+
+success = ""
+
+
+
+
+try:
+
+ global ser
+ portAddress = '/dev/ttyUSB1'
+ portName = portAddress[-4:]
+ portExist = os.popen('dmesg | grep ' + portName).read()
+
+ if portExist == '':
+ print 'The serial port does not exist'
+ sys.exit()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+ ser.open()
+
+ server = classServer.ServerHandler(50097)
+ tried = server.openSocket()
+
+ if server.error != 'No error':
+ print server.error
+ if server.error == '[Errno 98] Address already in use':
+ print 'one should try to kill the port'
+ print server.killPort()
+ server.closeConection()
+
+
+ print "here:", server.connected
+
+
+ if server.connected == 1:
+
+ server.sendData('I am ready')
+
+ while stop <> "true":
+
+ data = server.receiveData()
+ if data == "terminated":
+ print "I will", data
+ break
+
+ buffer = buffer + ser.read(ser.inWaiting())
+ if '\n' in buffer:
+ lines = buffer.split('\n')
+ last_received = lines.pop(0)
+
+ buffer = '\n'.join(lines)
+
+ last_received=last_received.split('\n')
+ line = last_received[0].replace(chr(13), '')
+
+
+ if len(line) > 0:
+
+ if line=='RING':
+ if pickUp == 0:
+
+ print "Somebody calling"
+ sleep(1)
+ ser.write('ATA\r')
+
+ sleep(1)
+ ser.write('AT+CSQ\r')
+
+ sleep(2)
+ ser.write('AT+CLCC\r')
+ line=''
+
+ if line[0:5] == '+CSQ:':
+
+ space = int(string.find(line,' '))+1
+ coma = int(string.find(line,','))
+ signalStr = (int(line[space:coma])*2)-113
+
+ line=''
+
+ if line[0:6]=='+CLCC:':
+
+ pickUp = 1
+
+ print "I will hangup the call"
+ sleep(5)
+
+ ser.write('AT+CHUP\r')
+ pickUp = 0
+
+ quotation1 = int(string.find(line,'"'))+1
+ lineTemp = line[quotation1:]
+
+ quotation2 = int(string.find(lineTemp,'"'))
+ numberOfCaller = line[quotation1:quotation1+quotation2]
+
+ server.sendData('I got call from' +numberOfCaller)
+ print "caller number", numberOfCaller
+ sleep(1)
+ server.sendData('success')
+ sleep (3)
+ ser.close()
+
+
+ server.closeConnection()
+ del server
+ else:
+
+ print "not connected"
+
+ del server
+
+ ser.close()
+except ValueError:
+ print "Exception: " + str(e)
+ server.closeConnection()
+ del server
+
+print "GOODBYE"
+sleep(5)