summaryrefslogtreecommitdiffstats
path: root/For Weekly Test/12-09-2011/usbDetect.py
diff options
context:
space:
mode:
Diffstat (limited to 'For Weekly Test/12-09-2011/usbDetect.py')
-rw-r--r--For Weekly Test/12-09-2011/usbDetect.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/For Weekly Test/12-09-2011/usbDetect.py b/For Weekly Test/12-09-2011/usbDetect.py
index 311ebb2..695b59c 100644
--- a/For Weekly Test/12-09-2011/usbDetect.py
+++ b/For Weekly Test/12-09-2011/usbDetect.py
@@ -1,9 +1,12 @@
from serial import * #serial port library
+from time import sleep
import sys
+import checkingNumberClass
def initLog():
+ sleep(0.5)
portLog = os.popen('dmesg | grep \'pl2303 converter now attached to ttyUSB\'').read()
-
+ sleep(0.5)
dmesgfile = open('dmesg.log', 'w')
dmesgfile.write(portLog)
dmesgfile.close()
@@ -12,10 +15,8 @@ def initLine():
global i
logfile = open('dmesg.log')
i = 0
-
while 1:
line = logfile.readline()
-
if not line:
break
i = i+1
@@ -33,12 +34,17 @@ def initPort():
if x == i:
lines = line
logfile.close()
+ print lines
def newConf(device):
+ x = checkingNumberClass.serialPort(port)
+ x.findNumber()
+ number = x.number
- portDev = '[/dev/'+port+']\n'
- file.write('['+device+'] ')
+ portDev = '[/dev/'+port+']'
+ file.write('\n['+device+'] ')
file.writelines(portDev)
+ file.writelines('['+number+']\n')
def searchList():
global found
@@ -63,24 +69,23 @@ def initVoda():
searchList()
if found == 1:
initRepeat()
- if found == 0:
+ elif found == 0:
portList.append(['Voda', port])
newConf('Voda')
- if repeat == True:
+ elif repeat == True:
initVoda()
def initEplus():
print "pluged in, Eplus Mobile Device [then Enter]"
input = sys.stdin.readline().rstrip("\r\n")
scanPort()
-
searchList()
if found == 1:
initRepeat()
- if found == 0:
+ elif found == 0:
portList.append(['Eplus', port])
newConf('Eplus')
- if repeat == True:
+ elif repeat == True:
initEplus()
def initTmobile():
@@ -143,6 +148,7 @@ while True:
if input == "q":
break
+sys.exit()