summaryrefslogtreecommitdiffstats
path: root/For Weekly Test
diff options
context:
space:
mode:
authortriatmoko2011-07-11 19:50:20 +0200
committertriatmoko2011-07-11 19:50:20 +0200
commite0fb9720add69e2ca1914847f0a583f709ecfee1 (patch)
tree86f02072c2caa2570af27554a33a3d59e6508e63 /For Weekly Test
parentexpand controller script. (diff)
downloadgsm-selftest-e0fb9720add69e2ca1914847f0a583f709ecfee1.tar.gz
gsm-selftest-e0fb9720add69e2ca1914847f0a583f709ecfee1.tar.xz
gsm-selftest-e0fb9720add69e2ca1914847f0a583f709ecfee1.zip
edit some part of code and expand controller part. you can test our software on for weekly test folder. just download all the file put plug the device. have fun
Diffstat (limited to 'For Weekly Test')
-rw-r--r--For Weekly Test/07-08-2011/Controller-SecondType_withDB.py85
-rw-r--r--For Weekly Test/07-08-2011/classPing.py28
-rw-r--r--For Weekly Test/07-08-2011/gsmcall_.py44
-rw-r--r--For Weekly Test/07-08-2011/gsmincom_.py51
-rw-r--r--For Weekly Test/07-08-2011/sipCall.py (renamed from For Weekly Test/07-08-2011/SIPCall.py)0
-rw-r--r--For Weekly Test/07-08-2011/sipReceiver.py (renamed from For Weekly Test/07-08-2011/SIPIncoming.py)0
6 files changed, 141 insertions, 67 deletions
diff --git a/For Weekly Test/07-08-2011/Controller-SecondType_withDB.py b/For Weekly Test/07-08-2011/Controller-SecondType_withDB.py
index 96a9599..a45fd05 100644
--- a/For Weekly Test/07-08-2011/Controller-SecondType_withDB.py
+++ b/For Weekly Test/07-08-2011/Controller-SecondType_withDB.py
@@ -8,30 +8,40 @@ import subprocess
import classClient #import class socket
import classDb #import class db
+import classPing
from time import sleep
from datetime import datetime
-user = 'root'
-passw = 'randompasswordSQL' #default password we agree with this password before!
-host = 'localhost'
-dbname = 'gsmselftesting'
+user = 'root'
+passw = 'randompasswordSQL' #default password we agree with this password before!
+host = 'localhost'
+dbname = 'gsmselftesting'
-stop = "False"
-status = ""
-dbSStatus = ""
+stop = "False"
+status = ""
+dbSStatus = ""
+sipNum = "4661929"
+landlnNum = "076145875681"
-#function to ping
-def FuncPing(host):
- ping_cmd = os.popen('ping '+ host + ' -c 1 -W 1').read()
- pingAlive = int(string.find(ping_cmd, '1 received'))
- if pingAlive != -1:
- return 1
- else:
- return 0
+sipCall = "sipCall.py"
+sipRec = "sipReceiver.py"
+landlnCall = "landlineCall.py"
+landlnRec = "landlineReceiver.py"
+localSipCall = "localsipCall.py"
+localSipRec = "localsipReceiver.py"
+rz1Call = "rz1Call.py"
+rz1Rec = "rz1Receiver.py
+
+o2Call = "o2Call.py"
+o2Rec = "o2Receiver.py"
+vodafoneCall = "vodafoneCall.py"
+vodafoneRec = "vodafoneReceiver.py"
+tmobileCall = "tmobileCall.py"
+tmobilRec = "tmobileReceiver.py"
# One function for all test case
@@ -157,7 +167,11 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
print "Destination handler ready"
print ""
- x.sendData("start")#send message to handler to start the call
+ x.sendData("start ")#send message to handler to start the call
+ sleep(1)
+ x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
x.closeConnection()
x.connect()
@@ -178,6 +192,10 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
x.sendData("start")
sleep(2)
x.sendData(destNo)
+
+ #for refresh socket, so gsm handler can use socket to communicated with the phone
+ x.closeConnection()
+ x.connect()
while 1:
resultOrig = X.receiveData()
@@ -235,8 +253,15 @@ dbStatus = x.connectDB()
if dbStatus == 1:
# Check Ping to the Every Handler
- #sipServerStatus = FuncPing("132.230.4.8")
- sipServerStatus =1
+ sipServer = PingClass.Ping('132.230.4.60')
+ sipServerStatus = sipServer.ping(3)
+
+ sipGateServer = PingClass.Ping('sipgate.de')
+ sipGateServerStatus = sipGateServer.ping(3)
+
+ sipLocalServer = PingClass.Ping('132.230.4.60')
+ sipLocalServerStatus = sipLocalServer.ping(3)
+
#gsmBox1Status = FuncPing("132.230.4.8")
#gsmBox2Status = FuncPing("132.230.4.8")
@@ -254,7 +279,7 @@ if dbStatus == 1:
if callTo == "gsmrz1":
- FuncTest("SIPCall.py", "localhost", "gsmincom_.py", "localhost","473")
+ FuncTest(sipCall, "localhost", "gsmincom_.py", "localhost","4661473")
print "Finish test"
if repeatTest == "true":
#select temporary table, if there are have test from gsmrz to sip then skip
@@ -264,7 +289,7 @@ if dbStatus == 1:
if callTo == "gsmrz2":
if gsmBox1Status <> 0:
- FuncTest("SIPCall.py", "localhost", "Box1", "132.0.0.2","404")
+ FuncTest(sipCall, "localhost", "Box1", "132.0.0.2","404")
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
@@ -273,25 +298,37 @@ if dbStatus == 1:
if callTo == "gsmrz3":
if gsmBox2Status <> 0:
- FuncTest("SIPCall.py", "localhost", "Box2", "132.0.0.3","405")
+ FuncTest(sipCall, "localhost", "Box2", "132.0.0.3","405")
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
update
+ if callTo == "landline" and sipGateSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", landlnRec, "localhost",landlnNum)
+
+ if callTo == "localsip" and sipLocalSeverStatus <> 0:
+ FuncTest(sipCall, "localhost", localSipRec, "localhost","405")
+
+ if callTo == "externalgsm":
+ FuncTest(sipCall, "localhost", o2Rec, "localhost","405")
+ FuncTest(sipCall, "localhost", tmobileRec, "localhost","405")
+ FuncTest(sipCall, "localhost", vodafoneRec, "localhost","405")
+ FuncTest(sipCall, "localhost", "xx", "localhost","405")
+
if callFrom =="gsmrz1":
if callTo =="sip" and sipServerStatus <> 0:
- FuncTest("gsmcall_.py", "localhost", "SIPIncoming.py", "localhost","929")
+ FuncTest("gsmcall_.py", "localhost", sipRec, "localhost",sipNum)
sleep(10)
if callTo =="gsmrz2" and gsmBox1Status <> 0:
- FuncTest("Box1", "132.0.0.2", "SIPReceiver.py", "localhost","929")
+ FuncTest("Box1", "132.0.0.2", sipRec, "localhost",sipNum)
if callTo =="gsmrz3" and gsmBox2Status <> 0:
- FuncTest("Box2", "132.0.0.3", "SIPReceiver.py", "localhost","929")
+ FuncTest("Box2", "132.0.0.3", sipRec, "localhost",sipNum)
diff --git a/For Weekly Test/07-08-2011/classPing.py b/For Weekly Test/07-08-2011/classPing.py
new file mode 100644
index 0000000..e13b32b
--- /dev/null
+++ b/For Weekly Test/07-08-2011/classPing.py
@@ -0,0 +1,28 @@
+import subprocess
+import string
+
+class Ping:
+
+ def __init__(self, pingAddress):
+ self.pingAddress = pingAddress
+
+ def ping(self,numberTries):
+ tried = 1
+ while numberTries >= tried:
+ tried += 1
+ #the parameter c 1 means only one ping to be sent, parameter W 3 means how many seconds the time out should be, 3 seconds
+ ping_cmd = subprocess.Popen(['ping', self.pingAddress, '-c', '1', '-W', '2'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT).communicate()[0]
+
+ pingAlive = int(string.find(ping_cmd, '1 received'))
+ unknownHost = int(string.find(ping_cmd, 'unknown host'))
+
+
+ if pingAlive != -1:
+ break
+
+ if unknownHost != -1:
+ return 2 #unknown host
+ if pingAlive != -1:
+ return 1 #ping works fine
+ else:
+ return 0 #no ping response
diff --git a/For Weekly Test/07-08-2011/gsmcall_.py b/For Weekly Test/07-08-2011/gsmcall_.py
index 48466cb..039622c 100644
--- a/For Weekly Test/07-08-2011/gsmcall_.py
+++ b/For Weekly Test/07-08-2011/gsmcall_.py
@@ -1,5 +1,4 @@
import sys
-import pjsua as pj
import socket
import time
@@ -10,7 +9,6 @@ from serial import *
import classServer
from time import sleep
-from datetime import datetime
import string
@@ -55,32 +53,34 @@ while stop <> "true":#???
data = server.receiveData() # waiting mode, until receiver start message or terminate message
if data == "start": # if receiver start message, handler start to call destination
-
- num = "929"
- server.closeConnection()
+
+ while 1:
- ser = Serial(
- port=portAddress,
- baudrate=19200,
- bytesize=EIGHTBITS,
- parity=PARITY_NONE,
- stopbits=STOPBITS_ONE)
+ num = server.receiveData()
- ser.close()
- ser.open()
+ #num = "929"
+ if num <> "NO DATA":
+ server.closeConnection()
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
- if num <> "":
+ ser.close()
+ ser.open()
- ser.write('ATD4661' + num + ';\r')
- sleep(3)
- ser.write('AT+CHUP\r')
+ ser.write('ATD4661' + num + ';\r')
+ sleep(3)
+ ser.write('AT+CHUP\r')
- ser.close()
- tried = server.openSocket()
- sleep(2)
- success = "success"
- server.sendData(success)
+ ser.close()
+ tried = server.openSocket()
+ sleep(2)
+ success = "success"
+ server.sendData(success)
if data == "terminated": # will terminate the handler if controller send terminate message
stop = "true"
diff --git a/For Weekly Test/07-08-2011/gsmincom_.py b/For Weekly Test/07-08-2011/gsmincom_.py
index 3c64937..a49c24c 100644
--- a/For Weekly Test/07-08-2011/gsmincom_.py
+++ b/For Weekly Test/07-08-2011/gsmincom_.py
@@ -1,9 +1,8 @@
-from threading import Thread #library to make a thread (I guess)
+
import atexit
import signal
import sys
-import pjsua as pj
import socket
import time
import os
@@ -12,11 +11,9 @@ import classServer
from time import sleep
from serial import *
-from time import sleep
-from datetime import datetime
-
-success = ""
+success = None
+stop = False
try:
@@ -30,13 +27,7 @@ try:
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(50105)
tried = server.openSocket()
@@ -53,15 +44,29 @@ try:
if server.connected == 1:
server.sendData('ready')
+ server.closeConection()
+
+ ser = Serial(
+ port=portAddress,
+ baudrate=19200,
+ bytesize=EIGHTBITS,
+ parity=PARITY_NONE,
+ stopbits=STOPBITS_ONE)
+
+ ser.close()
+ ser.open()
+
signalQuality = ser.write('AT+CSQ\r')
print "signal Quality ", signalQuality
print ""
- buffer = ""
- stop ="false"
- while stop <> "true":
+
+
+
+ while stop <> True:
global pickUp
pickUp = None
+ buffer = ""
buffer = buffer + ser.read(ser.inWaiting()) #read the serial port and add it to the buffer variable
@@ -91,7 +96,7 @@ try:
sleep(2)
ser.write('AT+CLCC\r')
- sline=''
+
if line[0:5] == '+CSQ:':
@@ -110,7 +115,8 @@ try:
sleep(5)
ser.write('AT+CHUP\r')
- pickUp = 0
+ pickUp = 0
+ ser.close()
quotation1 = int(string.find(line,'"'))+1
lineTemp = line[quotation1:]
@@ -120,12 +126,15 @@ try:
print "Signal Strength: ", signalStr
print ""
- server.sendData('I got call from' +numberOfCaller)
- print "caller number", numberOfCaller
+
+ tried = server.openSocket()
+ server.sendData('I got call from :' +numberOfCaller)
+ print "with caller number", numberOfCaller
sleep(1)
server.sendData('success')
+ stop = True
sleep (3)
- ser.close()
+
server.closeConnection()
diff --git a/For Weekly Test/07-08-2011/SIPCall.py b/For Weekly Test/07-08-2011/sipCall.py
index eb44b4a..eb44b4a 100644
--- a/For Weekly Test/07-08-2011/SIPCall.py
+++ b/For Weekly Test/07-08-2011/sipCall.py
diff --git a/For Weekly Test/07-08-2011/SIPIncoming.py b/For Weekly Test/07-08-2011/sipReceiver.py
index 6404f10..6404f10 100644
--- a/For Weekly Test/07-08-2011/SIPIncoming.py
+++ b/For Weekly Test/07-08-2011/sipReceiver.py