summaryrefslogtreecommitdiffstats
path: root/For Weekly Test
diff options
context:
space:
mode:
authortriatmoko2011-07-07 13:48:47 +0200
committertriatmoko2011-07-07 13:48:47 +0200
commitc576caad3acb30e9daccff9fccdeb827bb73b014 (patch)
treec91d0c30dfbe3a28776ad8c4ec42681e8d609ccd /For Weekly Test
parentpasword for db (diff)
downloadgsm-selftest-c576caad3acb30e9daccff9fccdeb827bb73b014.tar.gz
gsm-selftest-c576caad3acb30e9daccff9fccdeb827bb73b014.tar.xz
gsm-selftest-c576caad3acb30e9daccff9fccdeb827bb73b014.zip
...
Diffstat (limited to 'For Weekly Test')
-rw-r--r--For Weekly Test/07-08-2011/Controller-SecondType.py164
-rw-r--r--For Weekly Test/07-08-2011/SIPCall.py4
-rw-r--r--For Weekly Test/07-08-2011/SIPIncoming.py4
-rw-r--r--For Weekly Test/07-08-2011/classClient.py8
-rw-r--r--For Weekly Test/07-08-2011/classClient.pycbin2780 -> 2759 bytes
-rw-r--r--For Weekly Test/07-08-2011/classDb.pycbin5666 -> 5926 bytes
-rw-r--r--For Weekly Test/07-08-2011/classServer.pycbin3066 -> 3273 bytes
-rw-r--r--For Weekly Test/07-08-2011/gsmcall_.py4
-rw-r--r--For Weekly Test/07-08-2011/gsmincom_.py111
9 files changed, 171 insertions, 124 deletions
diff --git a/For Weekly Test/07-08-2011/Controller-SecondType.py b/For Weekly Test/07-08-2011/Controller-SecondType.py
index 22b1990..3d87eb9 100644
--- a/For Weekly Test/07-08-2011/Controller-SecondType.py
+++ b/For Weekly Test/07-08-2011/Controller-SecondType.py
@@ -38,20 +38,28 @@ def FuncPing(host):
def FuncTest(orig, origAdd, dest, destAdd, destNo):
global repeatTest
+ global portOrig
+ global x
+ global y
+ portOrig = None
+
+
repeatTest = ""
+
+
try:
-
+ x = None
if dest =="gsmBox1" or dest =="gsmBox2":
if dest =="gsmBox1":
- x = classClient.Connection(origAdd,50095)
+ portOrig = 50095
if dest =="gsmBox2":
- x = classClient.Connection(origAdd,50096)
+ portOrig = 50096
- print "GSM server handler", y.connect()
+ print "GSM server handler", x.connect()
x.sendData('hello server please wakeup the handler and be caller')
else:
@@ -59,62 +67,83 @@ def FuncTest(orig, origAdd, dest, destAdd, destNo):
command="--command=python " +orig
subprocess.Popen(args=["gnome-terminal", command])
- sleep(5)
+ sleep(2)
+ print "here"
if orig=="SIPCall.py":
- x = classClient.Connection(origAdd,50097)
+ portOrig = 50097
+
+ if orig=="gsmcall_.py":
+ portOrig = 50098
if orig == "landlineCall.py":
- x = classClient.Connection(origAdd,50098)
+ portOrig = 50099
if orig == "LocalSIPCall.py":
- x = classClient.Connection(origAdd,50099)
+ portOrig = 50100
else: #mean external GSM
- x = classClient.Connection(origAdd,50100)
-
+ print "have not yet define"
+ #portOrig = 50101
+
+ print "port?", portOrig
+ x = classClient.Connection(origAdd,portOrig)
print "handler", x.connect()
x.sendData('hello Handler')
# wait respond from origin handler
while 1:
- origHandler = x.receive_data()
+ origHandler = x.receiveData()
if origHandler <> "":
+ print origHandler
break
#think about time out
if origHandler == "ready":
- print "sip handler ready"
+ print "Caller handler ready"
try:
+ y = None
+ global portDest
+ portDest = None
+
if dest =="gsmBox1" or dest =="gsmBox2":
if dest =="gsmBox1":
- y = classClient.Connection(destAdd,50101)
+ portDest = 50102
if dest =="gsmBox2":
- y = classClient.Connection(destAdd,50102)
+ portDest = 50103
+ y = classClient.Connection(destAdd,portDest)
print "GSM handler", y.connect()
y.sendData('hello server please wakeup the handler and be receiver')
else:
+ print "here I am"
command="--command=python " +dest
subprocess.Popen(args=["gnome-terminal", command])
- sleep(5)
+ sleep(2)
- if orig=="SIPReceiver.py":
- y = classClient.Connection(destAdd,50103)
+ if dest=="SIPReceiver.py":
+ portDest = 50104
- if orig == "landlineReceiver.py":
- y = classClient.Connection(destAdd,50104)
+ if dest=="gsmincom_.py":
+ portDest = 50105
- if orig == "LocalSIPReceiver.py":
- y = classClient.Connection(destAdd,50105)
+ if dest == "landlineReceiver.py":
+ portDest = 50106
- else: #mean external GSM
- y = classClient.Connection(destAdd,50106)
+ if dest == "LocalSIPReceiver.py":
+ portDest = 50107
- print "GSM Server handler", y.connect()
+ #mean external GSM
+ #print "not define yet"
+ #portDest = 50108
+
+ print portDest
+ print destAdd
+ y = classClient.Connection(destAdd,portDest)
+ print "handler", y.connect()
y.sendData('hello Receiver, caller number')
#wait respond from destination handler
@@ -147,21 +176,28 @@ 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
if resultOrig <> "" or resultDest <> "":
break
#if still failed, save to db and return repeat test, so we make automatic test vice versa
if resultOrig == "failed" or resultDest == "failed":
- db.execute ("update result table")
+ #db.execute ("update result table")
repeatTest="true"
+ print "Origin2: ", resultOrig
+ print "Destination1: ", resultDest
else: #save to database, tell handler to terminated
- db.execute ("update result table")
- x.sendData("terminated") # signal caller to terminate
- y.sendData("terminated") # signal receiver to terminate
+ #db.execute ("update result table")
+ print "I am here on this stage"
+ #x.sendData("terminated") # signal caller to terminate
+ #y.sendData("terminated") # signal receiver to terminate
else:
statusTest = "604 General Handler Error: Destination handler no respond"
@@ -195,60 +231,66 @@ dbStatus = x.connectDB()
if dbStatus == 1:
# Check Ping to the Every Handler
- sipServerStatus = FuncPing("132.230.4.8")
- gsmBox1Status = FuncPing("132.230.4.8")
- gsmBox2Status = FuncPing("132.230.4.8")
+ #sipServerStatus = FuncPing("132.230.4.8")
+ sipServerStatus =1
+ #gsmBox1Status = FuncPing("132.230.4.8")
+ #gsmBox2Status = FuncPing("132.230.4.8")
# Fetch The task information from DB
- print "do i have anything to do", x.anyTasksToDo()
+ #print "do i have anything to do", x.anyTasksToDo()
- for item in x.tasksList:
- taskID = item[0]
- callFrom = item[1]
- callTo = item[2]
- print "call from to ", taskID , callFrom , callTo
+ #for item in x.tasksList:
+ # taskID = item[0]
+ # callFrom = item[1]
+ # callTo = item[2]
+ callFrom = "sip"
+ callTo = "gsmrz1"
+ #J = 1, 2
+ #for A in J:
+# print "call from to ", taskID , callFrom , callTo
+ print "call :", callFrom , callTo
- if callFrom == "sip" and sipServerStatus <> 0:
+ if callFrom == "sip" and sipServerStatus <> 0:
- if callTo == "gsmrz1":
+ if callTo == "gsmrz1":
- FuncTest("SIPCall.py", "localhost", "RZ1Receiver.py", "132.0.0.1","406")
- if repeatTest == "true":
+ FuncTest("SIPCall.py", "localhost", "gsmincom_.py", "localhost","473")
+ 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
+ update
- if callTo == "gsmrz2":
+ if callTo == "gsmrz2":
- if gsmBox1Status <> 0:
- FuncTest("SIPCall.py", "localhost", "Box1", "132.0.0.2","404")
- if repeatTest == "true":
+ if gsmBox1Status <> 0:
+ FuncTest("SIPCall.py", "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
- update
+ update
- if callTo == "gsmrz3":
+ if callTo == "gsmrz3":
- if gsmBox2Status <> 0:
- FuncTest("SIPCall.py", "localhost", "Box2", "132.0.0.3","405")
- if repeatTest == "true":
+ if gsmBox2Status <> 0:
+ FuncTest("SIPCall.py", "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
+ update
- if callFrom =="gsmrz1":
+ if callFrom =="gsmrz1":
- if callTo =="sip" and sipServerStatus <> 0:
- FuncTest("rz1Caller.py", "132.0.0.1", "SIPReceiver.py", "localhost","928")
+ if callTo =="sip" and sipServerStatus <> 0:
+ FuncTest("gsmincom_.py", "localhost", "SIPIncoming.py", "localhost","929")
- if callTo =="gsmrz2" and gsmBox1Status <> 0:
- FuncTest("Box1", "132.0.0.2", "SIPReceiver.py", "localhost","928")
+ if callTo =="gsmrz2" and gsmBox1Status <> 0:
+ FuncTest("Box1", "132.0.0.2", "SIPReceiver.py", "localhost","929")
- if callTo =="gsmrz3" and gsmBox2Status <> 0:
- FuncTest("Box2", "132.0.0.3", "SIPReceiver.py", "localhost","928")
+ if callTo =="gsmrz3" and gsmBox2Status <> 0:
+ FuncTest("Box2", "132.0.0.3", "SIPReceiver.py", "localhost","929")
diff --git a/For Weekly Test/07-08-2011/SIPCall.py b/For Weekly Test/07-08-2011/SIPCall.py
index 55a917f..eb44b4a 100644
--- a/For Weekly Test/07-08-2011/SIPCall.py
+++ b/For Weekly Test/07-08-2011/SIPCall.py
@@ -121,8 +121,8 @@ while stop <> "true":
if acc.info().reg_status < 700:
my_sip_uri = "sip:" + transport.info().host + ":" + str(transport.info().port)
-
- server.sendData('I am ready')#send message to controller
+ print my_sip_uri
+ server.sendData('ready')#send message to controller
print "here:", server.connected
while 1:
try:
diff --git a/For Weekly Test/07-08-2011/SIPIncoming.py b/For Weekly Test/07-08-2011/SIPIncoming.py
index 7ef63a1..8f181b9 100644
--- a/For Weekly Test/07-08-2011/SIPIncoming.py
+++ b/For Weekly Test/07-08-2011/SIPIncoming.py
@@ -91,7 +91,7 @@ lib = pj.Lib()
try:
#open socket connection to the controller
- server = classServer.ServerHandler(50103)
+ server = classServer.ServerHandler(50104)
tried = server.openSocket()
if server.error != 'No error':
@@ -114,7 +114,7 @@ try:
# Create local account
- acc_cfg = pj.AccountConfig(server, username, password)
+ acc_cfg = pj.AccountConfig("132.230.4.8", "mpselftest2", "2mpselftest")
acc = lib.create_account(acc_cfg, cb=MyAccountCallback())
if acc.info().reg_status < 700:
diff --git a/For Weekly Test/07-08-2011/classClient.py b/For Weekly Test/07-08-2011/classClient.py
index 625e48e..ce02d19 100644
--- a/For Weekly Test/07-08-2011/classClient.py
+++ b/For Weekly Test/07-08-2011/classClient.py
@@ -64,11 +64,3 @@ class Connection:
else:
return 0
-#MAIN PART
-x = Connection('localhost',50008)
-print x.connect()
-x.sendData('hello server :)')
-print x.receiveData()
-x.sendData('I send you another message')
-x.closeConnection()
-
diff --git a/For Weekly Test/07-08-2011/classClient.pyc b/For Weekly Test/07-08-2011/classClient.pyc
index f0a0323..b93c110 100644
--- a/For Weekly Test/07-08-2011/classClient.pyc
+++ b/For Weekly Test/07-08-2011/classClient.pyc
Binary files differ
diff --git a/For Weekly Test/07-08-2011/classDb.pyc b/For Weekly Test/07-08-2011/classDb.pyc
index 522034d..92d31c6 100644
--- a/For Weekly Test/07-08-2011/classDb.pyc
+++ b/For Weekly Test/07-08-2011/classDb.pyc
Binary files differ
diff --git a/For Weekly Test/07-08-2011/classServer.pyc b/For Weekly Test/07-08-2011/classServer.pyc
index 473063e..2c80f27 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 1e60d8e..31fe2c6 100644
--- a/For Weekly Test/07-08-2011/gsmcall_.py
+++ b/For Weekly Test/07-08-2011/gsmcall_.py
@@ -22,7 +22,7 @@ while stop <> "true":
try:
global ser
- portAddress = '/dev/ttyUSB1'
+ portAddress = '/dev/ttyUSB0'
portName = portAddress[-4:]
portExist = os.popen('dmesg | grep ' + portName).read()
@@ -39,7 +39,7 @@ while stop <> "true":
ser.open()
- server = classServer.ServerHandler(50097)
+ server = classServer.ServerHandler(50098)
tried = server.openSocket()
if server.error != 'No error':
diff --git a/For Weekly Test/07-08-2011/gsmincom_.py b/For Weekly Test/07-08-2011/gsmincom_.py
index 305d161..c11583e 100644
--- a/For Weekly Test/07-08-2011/gsmincom_.py
+++ b/For Weekly Test/07-08-2011/gsmincom_.py
@@ -1,3 +1,7 @@
+from threading import Thread #library to make a thread (I guess)
+import atexit
+import signal
+
import sys
import pjsua as pj
import socket
@@ -5,6 +9,8 @@ import time
import os
import string
import classServer
+from time import sleep
+from serial import *
from time import sleep
from datetime import datetime
@@ -15,7 +21,7 @@ success = ""
try:
global ser
- portAddress = '/dev/ttyUSB1'
+ portAddress = '/dev/ttyUSB0'
portName = portAddress[-4:]
portExist = os.popen('dmesg | grep ' + portName).read()
@@ -31,7 +37,7 @@ try:
stopbits=STOPBITS_ONE)
ser.open()
- server = classServer.ServerHandler(50097)
+ server = classServer.ServerHandler(50105)
tried = server.openSocket()
if server.error != 'No error':
@@ -44,82 +50,89 @@ try:
print "here:", server.connected
-
+ sleep(5)
if server.connected == 1:
- server.sendData('I am ready')
+ server.sendData('ready')
signalQuality = ser.write('AT+CSQ\r')
print "signal Quality ", signalQuality
print ""
while stop <> "true":
+ global pickUp
+ pickUp = None
+
data = server.receiveData()
if data == "terminated":
print "I will", data
break
- buffer = buffer + ser.read(ser.inWaiting())
+ 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)
+ lines = buffer.split('\n')
+ last_received = lines.pop(0)
- last_received=last_received.split('\n')
- line = last_received[0].replace(chr(13), '')
+ buffer = '\n'.join(lines)
+ last_received=last_received.split('\n')
+ line = last_received[0].replace(chr(13), '')
+
+ print "buffer:", buffer
+ print "line:", line
- if len(line) > 0:
-
- if line=='RING':
- if pickUp == 0:
+ #if len(buffer) <> 0:
- print "Somebody calling"
- print ""
- sleep(1)
- ser.write('ATA\r')
- sleep(1)
- ser.write('AT+CSQ\r')
+ if buffer=="RING":
+
+
+ print "Somebody calling"
+ print ""
+ sleep(1)
+ ser.write('ATA\r')
+ sleep(1)
+ ser.write('AT+CSQ\r')
- sleep(2)
- ser.write('AT+CLCC\r')
- line=''
+ sleep(2)
+ ser.write('AT+CLCC\r')
+ sline=''
- if line[0:5] == '+CSQ:':
+ if buffer[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 line[0:6]=='+CLCC:':
+ if buffer[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()
@@ -132,7 +145,7 @@ try:
ser.close()
except ValueError:
- print "Exception: " + str(e)
+ print "Exception: "
server.closeConnection()
del server