Skip to content

Commit 9276c52

Browse files
committedDec 2, 2022
fix #91 Read port status
1 parent 26e8901 commit 9276c52

18 files changed

+144
-491
lines changed
 

‎src/batchWindow.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,12 @@ def __init__(self, parent, top):
8282
self.end_flg = False
8383
self.swpath = None
8484
self.repeat = 0
85-
self.done = 0
8685
self.seqIdx = 0
8786
self.tdelay = 500
87+
88+
self.done = 0
89+
self.cdpass = 0
90+
self.cdfail = 0
8891

8992
self.InitTopHbox()
9093
self.InitSeqBox()
@@ -169,7 +172,11 @@ def executeSerial(self, incmd):
169172
elif skey == "write":
170173
self.top.write_serial(incmd[skey])
171174
elif skey == "read":
172-
self.top.read_serial(incmd[skey])
175+
res = self.top.read_serial(incmd[skey])
176+
if res == True:
177+
self.cdpass = self.cdpass + 1
178+
else:
179+
self.cdfail = self.cdfail + 1
173180

174181
def executeRepeat(self, repeat):
175182
self.top.print_on_log("Repeat\n")
@@ -249,12 +256,17 @@ def runBatchSeq(self):
249256
self.btn_start.SetLabel("Stop")
250257

251258
self.done = 0
259+
self.cdpass = 0
260+
self.cdfail = 0
261+
252262
self.seqIdx = 0
253263
self.totSeq = len(self.finseq)
254264
self.tdelay = 500
255265

266+
self.top.print_on_log("\n######################################")
256267
self.top.print_on_log("\nBatch Mode Starting!")
257268
self.top.print_on_log("\nRepeat Count: "+str(self.repeat))
269+
self.top.print_on_log("\n######################################\n\n")
258270

259271
if(self.timer.IsRunning() == False):
260272
self.timer.Start(self.tdelay)
@@ -269,12 +281,16 @@ def TimerServ(self, evt):
269281
if self.seqIdx >= len(self.finseq):
270282
self.seqIdx = 0
271283
self.done += 1
272-
self.top.print_on_log("Cycle Completed: "+str(self.done)+"\n")
284+
resstr = "Cycle Completed: "+str(self.done)+"; Pass: "\
285+
+str(self.cdpass)+"; Fail: "+str(self.cdfail)+"\n\n"
286+
# self.top.print_on_log("Cycle Completed: "+str(self.done)+"\n")
287+
self.top.print_on_log(resstr)
273288

274289
if self.done >= self.repeat:
275290
self.timer.Stop()
276291
self.StopBatch()
277-
self.top.print_on_log("Batch Sequence Completed!\n")
292+
self.top.print_on_log("Batch Sequence Completed!")
293+
self.top.print_on_log("\n######################################\n\n")
278294

279295
def executeBatchSeq(self):
280296
self.done = 0

‎src/bydefault.py

-14
This file was deleted.

‎src/comDialog.py

-6
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,12 @@
2727
from matplotlib import style
2828
import wx
2929

30-
import os
31-
import sys
3230
from sys import platform
3331

3432
# Own modules
35-
import search
3633
from uiGlobals import *
3734

3835
import devControl
39-
import json
40-
import timeit
41-
import threading
4236

4337
##############################################################################
4438
# Utilities

‎src/defaultconfig.py

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
##############################################################################
2+
#
3+
# Module: defaultconfig.py
4+
#
5+
# Description:
6+
# Scan the USB bus and get the list of devices attached
7+
#
8+
# Copyright notice:
9+
# This file copyright (c) 2020 by
10+
#
11+
# MCCI Corporation
12+
# 3520 Krums Corners Road
13+
# Ithaca, NY 14850
14+
#
15+
# Released under the MCCI Corporation.
16+
#
17+
# Author:
18+
# Seenivasan V, MCCI Corporation Mar 2020
19+
#
20+
# Revision history:
21+
# V3.0.0 Wed Oct 12 2022 17:00:00 Seenivasan V
22+
# Module created
23+
################################################################################
24+
125
config_data = {
226
"name": "Cricket",
327
"version": "1.0.0",

‎src/dev2101Window.py

+2
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,10 @@ def read_status(self):
186186
ob = outbyte[0]
187187
if( ob == 6):
188188
self.rbtn[0].SetBitmap(self.picf)
189+
self.btnStat[0] = False
189190
else:
190191
self.rbtn[0].SetBitmap(self.picn)
192+
self.btnStat[0] = True
191193
if(ob == 5):
192194
self.rbtn_ss1.SetValue(True)
193195
elif(ob == 3):

‎src/dev2301Window.py

+21-3
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
# Built-in imports
2828
import os
2929

30+
import time
31+
3032
# Own modules
3133
import devControl as model
3234
import thControl
@@ -270,7 +272,7 @@ def get_voltage(self):
270272
None
271273
"""
272274
strin = "--"
273-
res, outstr = model.send_volts_cmd(self.top)
275+
res, outstr = model.send_volts_cmd(self.top, self.swid)
274276
if res < 0:
275277
outstr = "Comm Error\n"
276278
else:
@@ -310,7 +312,7 @@ def get_amps(self):
310312
None
311313
"""
312314
strin = "--"
313-
res, outstr = model.send_amps_cmd(self.top)
315+
res, outstr = model.send_amps_cmd(self.top, self.swid)
314316
if res < 0:
315317
outstr = "Comm Error\n"
316318
else:
@@ -627,6 +629,21 @@ def update_controls(self, mode):
627629
else:
628630
self.enable_controls(False)
629631

632+
def read_port_status(self, stat):
633+
if stat:
634+
time.sleep(1)
635+
res, outstr = model.read_port_status(self.top, self.swid)
636+
print("Read Port Status: ", res, outstr)
637+
638+
pstat = False
639+
if res == 0:
640+
port = int(outstr)
641+
if port > 0:
642+
port = port - 1
643+
pstat = True
644+
self.btnStat[port] = True
645+
self.port_led_update(port, pstat)
646+
630647
def enable_controls(self, stat):
631648
"""
632649
Enable/Disable All Widgets of 2301,
@@ -644,7 +661,8 @@ def enable_controls(self, stat):
644661
stat = False
645662
self.enable_port_controls(stat)
646663
self.enable_speed_controls(stat)
647-
self.enable_va_controls(stat)
664+
self.enable_va_controls(stat)
665+
self.read_port_status(stat)
648666

649667
def enable_port_controls(self, stat):
650668
"""

‎src/dev3141Window.py

+15
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,20 @@ def update_controls(self, mode):
428428
self.enable_controls(True)
429429
else:
430430
self.enable_controls(False)
431+
432+
def read_port_status(self, stat):
433+
if stat:
434+
res, outstr = model.read_port_status(self.top, self.swid)
435+
print("Read Port Status: ", res, outstr)
436+
437+
pstat = False
438+
if res == 0:
439+
port = int(outstr)
440+
if port > 0:
441+
port = port - 1
442+
pstat = True
443+
self.btnStat[port] = True
444+
self.port_led_update(port, pstat)
431445

432446
def enable_controls(self, stat):
433447
"""
@@ -446,6 +460,7 @@ def enable_controls(self, stat):
446460
self.enable_port_controls(stat)
447461
self.enable_speed_controls(stat)
448462
self.enable_do_controls(stat)
463+
self.read_port_status(stat)
449464

450465
def enable_port_controls(self, stat):
451466
"""

‎src/dev3201Window.py

+19
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,23 @@ def update_controls(self, mode):
640640
else:
641641
self.enable_controls(False)
642642

643+
644+
def read_port_status(self, stat):
645+
if stat:
646+
time.sleep(1)
647+
res, outstr = model.read_port_status(self.top, self.swid)
648+
print("Read Port Status: ", res, outstr)
649+
650+
pstat = False
651+
if res == 0:
652+
port = int(outstr)
653+
if port > 0:
654+
port = port - 1
655+
pstat = True
656+
self.btnStat[port] = True
657+
self.port_led_update(port, pstat)
658+
659+
643660
def enable_controls(self, stat):
644661
"""
645662
Enable/Disable All Widgets of 3201,
@@ -658,6 +675,7 @@ def enable_controls(self, stat):
658675
self.enable_port_controls(stat)
659676
self.enable_speed_controls(stat)
660677
self.enable_va_controls(stat)
678+
self.read_port_status(stat)
661679

662680
def enable_port_controls(self, stat):
663681
"""
@@ -788,6 +806,7 @@ def device_connected(self):
788806
Returns:
789807
None
790808
"""
809+
print("3201 Device Connected!!!!")
791810
if(self.con_flg):
792811
time.sleep(1)
793812
res, outstr = model.read_port_cmd(self.top)

‎src/devControl.py

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@
2626
# Built-in imports
2727

2828
import devClient as devnw
29-
import search
30-
import socket
31-
import json
3229

3330
from cricketlib import searchswitch
3431

@@ -177,7 +174,7 @@ def send_status_cmd(top, swid):
177174
top.ccflag = False
178175
return-1, "No CC"
179176

180-
def read_port_cmd(top):
177+
def read_port_status(top, swid):
181178
"""
182179
reading the port coammand
183180
Args:
@@ -187,7 +184,7 @@ def read_port_cmd(top):
187184
return findict: status in dict
188185
"""
189186
if top.devCtrl == "local":
190-
return top.devHand.read_port_cmd()
187+
return top.handlers[swid].get_port_status()
191188
elif top.devCtrl == "network":
192189
resdict = devnw.read_port_cmd(top.ldata['sccid'],
193190
int(top.ldata['ssccpn']))

‎src/devServer.py

-2
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@
2828

2929
import socket
3030
import threading
31-
import time
3231
import wx
3332
import json
34-
import search
3533

3634
from uiGlobals import *
3735

‎src/dutConfigDialog.py

-2
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
import wx
33

44
import serial.tools.list_ports
5-
import json
65
import os
7-
import sys
86
from sys import platform
97
import re
108

‎src/dutThread.py

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
##############################################################################
2424

2525
import threading
26-
import serial
2726
import time
2827
import wx
2928

‎src/getusb.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from usb.backend import libusb1
3232

3333
import xml.dom.minidom
34+
import platform
3435

3536
##############################################################################
3637
# Utilities
@@ -65,10 +66,22 @@ def scan_usb():
6566

6667
backend = None
6768
# Running Python-application on Windows
68-
if sys.platform == 'windows':
69-
backend = usb.backend.libusb1.get_backend(find_library=lambda x: ""+
70-
path + "Lib/site-packages/libusb/_platform/_windows/x86"+
71-
"/libusb-1.0.dll")
69+
if sys.platform == 'win32':
70+
pver = platform.architecture()
71+
if pver[0] == '64bit':
72+
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "" +
73+
path + "Lib\\site-packages\\libusb\\_platform\\_windows\\x64\\libusb-1.0.dll")
74+
print("64bit NBA")
75+
else:
76+
backend = usb.backend.libusb1.get_backend(find_library=lambda x: "" +
77+
path + "Lib\\site-packages\\libusb\\_platform\\_windows\\x86\\libusb-1.0.dll")
78+
print("32bit NBA")
79+
80+
usb_devices = []
81+
try:
82+
usb_devices = usb.core.find(find_all=True, backend=backend)
83+
except:
84+
print("No Back End Avail Error!")
7285

7386
# Generator object
7487
usb_devices = usb.core.find(find_all=True, backend=backend)

‎src/leftPanel.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
##############################################################################
22
#
3-
# Module: getusb.py
3+
# Module: leftPanel.py
44
#
55
# Description:
66
# Scan the USB bus and get the list of devices attached

‎src/libusb-1.0.dll

-101 KB
Binary file not shown.

0 commit comments

Comments
 (0)