From 310e98501ed13c8fae7bdc53b8c96b8d326c34e9 Mon Sep 17 00:00:00 2001 From: tt41 Date: Mon, 5 Sep 2011 01:34:27 +0200 Subject: add gsm device detecting feature --- For Weekly Test/12-09-2011/gsmselftest1.py | 62 +++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) (limited to 'For Weekly Test/12-09-2011/gsmselftest1.py') diff --git a/For Weekly Test/12-09-2011/gsmselftest1.py b/For Weekly Test/12-09-2011/gsmselftest1.py index aa72974..81d23cf 100644 --- a/For Weekly Test/12-09-2011/gsmselftest1.py +++ b/For Weekly Test/12-09-2011/gsmselftest1.py @@ -1,15 +1,19 @@ #! /usr/bin/env python -import sys +from serial import * #serial port library +import sys import ControllerClass import DbClass import PingClass import trueTableClass import initTestClass +import usbDetectClass from time import sleep global resultsList resultsList = list() +GSMListPrefix = [['GSMExt.Tm','0151'],['GSMExt.Tm','0160'],['GSMExt.Tm','0170'],['GSMExt.Tm','0171'],['GSMExt.Tm','0175'],['GSMExt.Voda','0152'],['GSMExt.Voda','0162'],['GSMExt.Voda','0172'],['GSMExt.Voda','0173'],['GSMExt.Voda','0174'],['GSMExt.Eplus','0157'],['GSMExt.Eplus','0177'],['GSMExt.Eplus','0155'],['GSMExt.Eplus','0163'],['GSMExt.Eplus','0178'],['GSMExt.O2','0159'],['GSMExt.O2','0176'],['GSMExt.O2','0179']] + def allPing(): @@ -138,6 +142,59 @@ def regularTest(): regulartest = initTestClass.doTheTest() regulartest.smartTest() +def findPort(portName): + global connect + global prefix + global num + global IMEI + global portClass + sleep(0.5) + portLog = os.popen('dmesg | grep \'pl2303 converter now attached to '+portName+'\'').read() + sleep(0.5) + if portLog != '': + connect = 1 + portClass = usbDetectClass.serialPort(portName) + portClass.findNumber() + portClass.findIMEI() + IMEI = portClass.IMEI + num = portClass.number + number = portClass.number + prefix = number[0:4] + else: + connect = 0 + +def updateDevice(): + + while True: + print "Mobile device configuration" + print "Menu: s = start device configuration, q = quit" + + input = sys.stdin.readline().rstrip("\r\n") + print '' + if input == 's': + i = 0 + while i !=10: + portName ='ttyUSB'+str(i) + findPort(portName) + i=i+1 + if connect == 1: + for listNum in GSMListPrefix: + if prefix == listNum[1]: + print 'Device Name :', listNum[0] + print 'IME :',IMEI + print 'Phone Number :',num + print 'Port Name : /dev/'+portName + + newPortName = '/dev/'+portName + portClass.initUpdate(listNum[0], newPortName, num) + print '\n' + + + + if input == "q": + break + sys.exit() + if len(sys.argv) > 1: command = sys.argv[1] @@ -161,6 +218,9 @@ if len(sys.argv) > 1: elif command == '--smart': regularTest() + elif command == '--devconf': + updateDevice() + elif command == '--help': file = open('help.txt', 'r') print file.read() -- cgit v1.2.3-55-g7522