summaryrefslogtreecommitdiffstats
path: root/For Weekly Test
diff options
context:
space:
mode:
authortriatmoko2011-07-07 15:31:53 +0200
committertriatmoko2011-07-07 15:31:53 +0200
commitc8058300235e94321db99423e0de37acf3db44f3 (patch)
treefc858824b39a2d6cf414f87227cbc59ff355bcd6 /For Weekly Test
parent... (diff)
downloadgsm-selftest-c8058300235e94321db99423e0de37acf3db44f3.tar.gz
gsm-selftest-c8058300235e94321db99423e0de37acf3db44f3.tar.xz
gsm-selftest-c8058300235e94321db99423e0de37acf3db44f3.zip
modify for friday test
Diffstat (limited to 'For Weekly Test')
-rw-r--r--For Weekly Test/07-08-2011/Controller-SecondType.py42
-rw-r--r--For Weekly Test/07-08-2011/SIPIncoming.py2
-rw-r--r--For Weekly Test/07-08-2011/classServer.py2
-rw-r--r--For Weekly Test/07-08-2011/classServer.pycbin3273 -> 3309 bytes
-rw-r--r--For Weekly Test/07-08-2011/gsmcall_.py21
-rw-r--r--For Weekly Test/07-08-2011/gsmincom_.py105
6 files changed, 84 insertions, 88 deletions
diff --git a/For Weekly Test/07-08-2011/Controller-SecondType.py b/For Weekly Test/07-08-2011/Controller-SecondType.py
index 3d87eb9..8ae229f 100644
--- a/For Weekly Test/07-08-2011/Controller-SecondType.py
+++ b/For Weekly Test/07-08-2011/Controller-SecondType.py
@@ -46,11 +46,8 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
repeatTest = ""
-
-
-
try:
- x = None
+
if dest =="gsmBox1" or dest =="gsmBox2":
if dest =="gsmBox1":
@@ -64,11 +61,12 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
else:
# open SIP caller handler
+
command="--command=python " +orig
subprocess.Popen(args=["gnome-terminal", command])
- sleep(2)
- print "here"
+ sleep(5)
+
if orig=="SIPCall.py":
portOrig = 50097
@@ -81,11 +79,12 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
if orig == "LocalSIPCall.py":
portOrig = 50100
- else: #mean external GSM
- print "have not yet define"
+ #else: #mean external GSM
+ # print "have not yet define"
#portOrig = 50101
print "port?", portOrig
+ print origAdd
x = classClient.Connection(origAdd,portOrig)
print "handler", x.connect()
x.sendData('hello Handler')
@@ -124,7 +123,7 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
sleep(2)
- if dest=="SIPReceiver.py":
+ if dest=="SIPIncoming.py":
portDest = 50104
if dest=="gsmincom_.py":
@@ -143,26 +142,28 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
print portDest
print destAdd
y = classClient.Connection(destAdd,portDest)
- print "handler", y.connect()
+ print "Destination handler", y.connect()
y.sendData('hello Receiver, caller number')
#wait respond from destination handler
while 1:
destHandler = y.receiveData()
if destHandler <> "":
+ print destHandler
break
#should have timeout = think about timeout
if destHandler == "ready":
x.sendData("start")#send message to handler to start the call
- sleep(2)
+ sleep(5)
x.sendData(destNo)
#send destination number to caller and signal to start the call
#wait respond from both of handler
while 1:
- resultOrig = X.receiveData()
+
+ resultOrig = x.receiveData()
resultDest = y.receiveData()
if resultOrig <> "" or resultDest <> "":
@@ -176,10 +177,8 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
x.sendData(destNo)
while 1:
- resultOrig =""
- X.receiveData()
- resultDest = ""
- y.receiveData()
+ resultOrig = X.receiveData()
+ resultDest = y.receiveData()
print "Origin1: ", resultOrig
print "Destination1: ", resultDest
@@ -195,8 +194,8 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
else: #save to database, tell handler to terminated
#db.execute ("update result table")
- print "I am here on this stage"
- #x.sendData("terminated") # signal caller to terminate
+ print "Test Result: ", resultOrig
+ x.sendData("terminated") # signal caller to terminate
#y.sendData("terminated") # signal receiver to terminate
else:
@@ -243,8 +242,8 @@ if dbStatus == 1:
# taskID = item[0]
# callFrom = item[1]
# callTo = item[2]
- callFrom = "sip"
- callTo = "gsmrz1"
+ callFrom = "gsmrz1"
+ callTo = "sip"
#J = 1, 2
#for A in J:
# print "call from to ", taskID , callFrom , callTo
@@ -256,6 +255,7 @@ if dbStatus == 1:
if callTo == "gsmrz1":
FuncTest("SIPCall.py", "localhost", "gsmincom_.py", "localhost","473")
+ print "Finish test"
if repeatTest == "true":
#select temporary table, if there are have test from gsmrz to sip then skip
#else, update db, put new data to tasktable. from gsmrz to sip
@@ -283,7 +283,7 @@ if dbStatus == 1:
if callFrom =="gsmrz1":
if callTo =="sip" and sipServerStatus <> 0:
- FuncTest("gsmincom_.py", "localhost", "SIPIncoming.py", "localhost","929")
+ FuncTest("gsmcall_.py", "localhost", "SIPIncoming.py", "localhost","929")
if callTo =="gsmrz2" and gsmBox1Status <> 0:
diff --git a/For Weekly Test/07-08-2011/SIPIncoming.py b/For Weekly Test/07-08-2011/SIPIncoming.py
index 8f181b9..bbe16e2 100644
--- a/For Weekly Test/07-08-2011/SIPIncoming.py
+++ b/For Weekly Test/07-08-2011/SIPIncoming.py
@@ -121,7 +121,7 @@ try:
my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
- server.sendData('I am ready')#send message to controller that the handler ready
+ server.sendData('ready')#send message to controller that the handler ready
while stop <> "true":
diff --git a/For Weekly Test/07-08-2011/classServer.py b/For Weekly Test/07-08-2011/classServer.py
index 109fa0b..5adf681 100644
--- a/For Weekly Test/07-08-2011/classServer.py
+++ b/For Weekly Test/07-08-2011/classServer.py
@@ -57,7 +57,7 @@ class ServerHandler:
def receiveData(self):
if self.connected == 1:
while 1:
- data = self.connection.recv(1024)
+ data = self.connection.recv(64)
if not data:
return 'NO DATA'
else:
diff --git a/For Weekly Test/07-08-2011/classServer.pyc b/For Weekly Test/07-08-2011/classServer.pyc
index 2c80f27..abca7ce 100644
--- a/For Weekly Test/07-08-2011/classServer.pyc
+++ b/For Weekly Test/07-08-2011/classServer.pyc
Binary files differ
diff --git a/For Weekly Test/07-08-2011/gsmcall_.py b/For Weekly Test/07-08-2011/gsmcall_.py
index 31fe2c6..d360d11 100644
--- a/For Weekly Test/07-08-2011/gsmcall_.py
+++ b/For Weekly Test/07-08-2011/gsmcall_.py
@@ -2,8 +2,10 @@ import sys
import pjsua as pj
import socket
import time
-import MySQLdb
+
import subprocess
+import os
+from serial import *
import classServer
@@ -27,8 +29,8 @@ while stop <> "true":
portExist = os.popen('dmesg | grep ' + portName).read()
if portExist == '':
- print 'The serial port does not exist'
- sys.exit()
+ print 'The serial port does not exist'
+ sys.exit()
ser = Serial(
port=portAddress,
@@ -50,26 +52,27 @@ while stop <> "true":
server.closeConection()
- server.sendData('I am ready')#send message to controller
+ server.sendData('ready')#send message to controller
print "here:", server.connected
while 1:
try:
data = server.receiveData() # waiting mode, until receiver start message or terminate message
- ser.write('AT+CSQ\r')
- signalQuality = ser.read(35)
+ #ser.write('AT+CSQ\r')
+ #signalQuality = ser.read(35)
- print "signal Quality ", signalQuality
+ #print "signal Quality ", signalQuality
print ""
if data == "start": # if receiver start message, handler start to call destination
while 1:
- num = server.receiveData() # waiting destination number
+ #num = server.receiveData() # waiting destination number
+ num = 929
+ print "here"
if num <> "":
- callBackNumber=
ser.write('ATD' + num + ';\r')
sleep(5)
server.sendData('success')
diff --git a/For Weekly Test/07-08-2011/gsmincom_.py b/For Weekly Test/07-08-2011/gsmincom_.py
index c11583e..3c64937 100644
--- a/For Weekly Test/07-08-2011/gsmincom_.py
+++ b/For Weekly Test/07-08-2011/gsmincom_.py
@@ -15,12 +15,13 @@ from serial import *
from time import sleep
from datetime import datetime
-stop ="false"
+
success = ""
try:
global ser
+ global server
portAddress = '/dev/ttyUSB0'
portName = portAddress[-4:]
portExist = os.popen('dmesg | grep ' + portName).read()
@@ -49,90 +50,82 @@ try:
print "here:", server.connected
-
- sleep(5)
if server.connected == 1:
server.sendData('ready')
signalQuality = ser.write('AT+CSQ\r')
print "signal Quality ", signalQuality
print ""
-
+ buffer = ""
+ stop ="false"
while stop <> "true":
global pickUp
pickUp = None
- data = server.receiveData()
- if data == "terminated":
- print "I will", data
- break
-
- buffer = ser.read(ser.inWaiting())
- print "what is it", buffer
- sleep(5)
- if '\n' in buffer:
- lines = buffer.split('\n')
- last_received = lines.pop(0)
- buffer = '\n'.join(lines)
+ buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
+ if '\n' in buffer: #if a new line character is found in the buffer then the cellphone has sent something
+ lines = buffer.split('\n') #parse the buffer variable with the new line character
+ last_received = lines.pop(0) #put into last_received variable the first content from lines (FIFO)
+
+ buffer = '\n'.join(lines) #add a new line to the buffer variable
- last_received=last_received.split('\n')
- line = last_received[0].replace(chr(13), '')
+ last_received=last_received.split('\n') #parse the last received value with new lines
+ line = last_received[0].replace(chr(13), '')
- print "buffer:", buffer
- print "line:", line
+ print "buffer:", buffer
+ print "line:", line
- #if len(buffer) <> 0:
+ if len(line) > 0:
- if buffer=="RING":
-
+ if line=="RING":
- print "Somebody calling"
- print ""
- sleep(1)
- ser.write('ATA\r')
- sleep(1)
- ser.write('AT+CSQ\r')
+ print "Somebody calling"
+ print ""
+ sleep(1)
+ ser.write('ATA\r')
+ sleep(1)
+ ser.write('AT+CSQ\r')
- sleep(2)
- ser.write('AT+CLCC\r')
- sline=''
+ sleep(2)
+ ser.write('AT+CLCC\r')
+ sline=''
- if buffer[0:5] == '+CSQ:':
+ if line[0:5] == '+CSQ:':
- space = int(string.find(line,' '))+1
- coma = int(string.find(line,','))
- signalStr = (int(line[space:coma])*2)-113
+ space = int(string.find(line,' '))+1
+ coma = int(string.find(line,','))
+ signalStr = (int(line[space:coma])*2)-113
- line=''
+ line=''
- if buffer[0:6]=='+CLCC:':
+ if line[0:6]=='+CLCC:':
- pickUp = 1
+ pickUp = 1
- print "I will hangup the call"
- print ""
- sleep(5)
+ print "I will hangup the call"
+ print ""
+ sleep(5)
- ser.write('AT+CHUP\r')
- pickUp = 0
+ ser.write('AT+CHUP\r')
+ pickUp = 0
- quotation1 = int(string.find(line,'"'))+1
- lineTemp = line[quotation1:]
+ quotation1 = int(string.find(line,'"'))+1
+ lineTemp = line[quotation1:]
- quotation2 = int(string.find(lineTemp,'"'))
- numberOfCaller = line[quotation1:quotation1+quotation2]
+ quotation2 = int(string.find(lineTemp,'"'))
+ numberOfCaller = line[quotation1:quotation1+quotation2]
- print "Signal Strength: ", signalStr
- print ""
- server.sendData('I got call from' +numberOfCaller)
- print "caller number", numberOfCaller
- sleep(1)
- server.sendData('success')
- sleep (3)
- ser.close()
+ print "Signal Strength: ", signalStr
+ print ""
+ server.sendData('I got call from' +numberOfCaller)
+ print "caller number", numberOfCaller
+ sleep(1)
+ server.sendData('success')
+ sleep (3)
+ ser.close()
server.closeConnection()