Skip to content

Commit

Permalink
Merge pull request #137 from mcci-usb/version-440
Browse files Browse the repository at this point in the history
Version 440
  • Loading branch information
vinaynmcci authored May 13, 2024
2 parents cf07d1a + f30ecae commit 0ecfbea
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 265 deletions.
2 changes: 1 addition & 1 deletion src/uiGlobals.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
# GLOBAL VARIABLES
##############################################################################
APP_NAME = "Cricket"
APP_VERSION = "4.3.1"
APP_VERSION = "4.4.0"

# StatusBar ID
SB_PORT_ID = 0
Expand Down
4 changes: 2 additions & 2 deletions src/updateDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ def ClickOk(self, e):
Note:
The method also destroys the parent window after opening the web browser.
"""
# webbrowser.open("https://github.com/mcci-usb/COLLECTION-cricket-ui/releases/tag/"+self.latest_version)
webbrowser.open(None+self.latest_version)
webbrowser.open("https://github.com/mcci-usb/COLLECTION-cricket-ui/releases/tag/"+self.latest_version)
# webbrowser.open(None+self.latest_version)
self.parent.Destroy()


Expand Down
64 changes: 17 additions & 47 deletions src/usb3tree/linuxusb3parse.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

##############################################################################
#
# Module: linuxusb3parse.py
# Module: LinuxUsb3TreeParse.py
#
# Description:
# parsing the USB3 Tree view data in Linux
# parsing the USB4 Tree view data in Windows
#
# Author:
# Vinay N, MCCI Corporation Mar 2024
Expand All @@ -13,44 +12,17 @@
# V4.3.1 Mon Apr 15 2024 17:00:00 Seenivasan V
# Module created
##############################################################################
class LinuxUsb4TreeParse():
class LinuxUsb3TreeParse():
def __init__(self):
self.idata = None
self.ldata = None

def parse_usb3tb_data(self, usb3data):
"""
Parse USB3 data and organize it into internal data structures.
This method takes USB3 data and organizes it into internal data structures
for easier access and manipulation.
Args:
usb4data (dict): USB4TB data to be parsed.
Returns:
None
"""
self.idata = self.get_item_data(usb3data)
self.ldata = self.get_level_data(self.idata)
# if self.idata is not None:
# self.ldata = self.get_level_data(self.idata)
# else:
# print("Error: idata is None")

def get_item_data(self, msg):
"""
Parse USB 3.0 data from a list of dictionaries containing USB device information.
Args:
msg (list): A list of dictionaries containing USB device information.

Returns:
dict: A dictionary containing parsed USB 3.0 data with keys formatted as 'vid,pid,bus,speed'.
Each value is a dictionary containing details such as type, vid, pid, bus, speed, ifc,
and optionally mport and port if available.
None: If the input 'msg' is not a list or if there are missing required fields in any item.
"""
if not isinstance(msg, list):
print("Error: usb3data is not a list")
return None
Expand All @@ -65,9 +37,13 @@ def get_item_data(self, msg):
ifc = item.get('ifc')
mport = item.get('mport')
port = item.get('port')

if vid is not None and pid is not None and bus is not None and speed is not None and ifc is not None:
key = f"{vid},{pid},{bus},{speed}"

# if vid is not None and pid is not None and bus is not None and speed is not None and ifc is not None:
if bus is not None and speed is not None and ifc is not None:
# key = f"{vid},{pid},{bus},{speed}"
# key = f"{vid},{pid}"
key = f"{mport}"

parsed_item = {
'type': 'usb3',
'vid': vid,
Expand All @@ -84,22 +60,16 @@ def get_item_data(self, msg):
print("Error: Missing required fields in item")
else:
print("Error: Item is not a dictionary")


# parsed_usb3 = {
# '7': {'type': 'usb3', 'vid': '5967', 'pid': '9317', 'bus': '1', 'speed': 3, 'ifc': [14, 14, 254], 'mport': '(7,)', 'port': '7'},
# '(10,)': {'type': 'usb3', 'vid': '32903', 'pid': '38', 'bus': '1', 'speed': 2, 'ifc': [224, 224], 'mport': '(10,)', 'port': '10'},
# '(9, 4)': {'type': 'usb3', 'vid': '1118', 'pid': '1606', 'bus': '1', 'speed': 2, 'ifc': [2, 10], 'mport': '(9, 4)', 'port': '4'},
# '(9, 1)': {'type': 'usb3', 'vid': '1121', 'pid': '20052', 'bus': '1', 'speed': 1, 'ifc': [3], 'mport': '(9, 1)', 'port': '1'},
# '(6,)': {'type': 'usb3', 'vid': '1267', 'pid': '3147', 'bus': '1', 'speed': 2, 'ifc': [255], 'mport': '(6,)', 'port': '6'}}
return parsed_usb3

def get_level_data(self, u3tbuf):
"""
Organize USB 3.0 data into levels based on the count of comma-separated keys.
Args:
u3tbuf (dict): A dictionary containing USB 3.0 data where keys are formatted as 'vid,pid,bus,speed'.
Returns:
dict: A dictionary organizing USB 3.0 data into levels based on the count of comma-separated keys.
Keys are formatted as 'levelX' where X is the count of commas in the keys of u3tbuf.
Values are lists containing keys from u3tbuf that match the respective level.
None: If the input 'u3tbuf' is not a dictionary.
"""
if not isinstance(u3tbuf, dict):
print("Error: u3tbuf is not a dictionary")
return None
Expand Down
86 changes: 86 additions & 0 deletions src/usb3tree/macusb3parse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
##############################################################################
#
# Module: MacUsb3TreeParse.py
#
# Description:
# parsing the USB4 Tree view data in Windows
#
# Author:
# Vinay N, MCCI Corporation Mar 2024
#
# Revision history:
# V4.3.1 Mon Apr 15 2024 17:00:00 Seenivasan V
# Module created
##############################################################################
class MacUsb3TreeParse():
def __init__(self):
self.idata = None
self.ldata = None

def parse_usb3tb_data(self, usb3data):
self.idata = self.get_item_data(usb3data)
self.ldata = self.get_level_data(self.idata)

def get_item_data(self, msg):

if not isinstance(msg, list):
print("Error: usb3data is not a list")
return None

parsed_usb3 = {}
for item in msg:
if isinstance(item, dict):
vid = item.get('vid')
pid = item.get('pid')
bus = item.get('bus')
speed = item.get('speed')
ifc = item.get('ifc')
mport = item.get('mport')
port = item.get('port')

# if vid is not None and pid is not None and bus is not None and speed is not None and ifc is not None:
if bus is not None and speed is not None and ifc is not None:
# key = f"{vid},{pid},{bus},{speed}"
# key = f"{vid},{pid}"
key = f"{mport}"

parsed_item = {
'type': 'usb3',
'vid': vid,
'pid': pid,
'bus': bus,
'speed': speed,
'ifc': ifc
}
if mport is not None:
parsed_item['mport'] = mport
parsed_item['port'] = port
parsed_usb3[key] = parsed_item
else:
print("Error: Missing required fields in item")
else:
print("Error: Item is not a dictionary")

# parsed_usb3 = {
# '7': {'type': 'usb3', 'vid': '5967', 'pid': '9317', 'bus': '1', 'speed': 3, 'ifc': [14, 14, 254], 'mport': '(7,)', 'port': '7'},
# '(10,)': {'type': 'usb3', 'vid': '32903', 'pid': '38', 'bus': '1', 'speed': 2, 'ifc': [224, 224], 'mport': '(10,)', 'port': '10'},
# '(9, 4)': {'type': 'usb3', 'vid': '1118', 'pid': '1606', 'bus': '1', 'speed': 2, 'ifc': [2, 10], 'mport': '(9, 4)', 'port': '4'},
# '(9, 1)': {'type': 'usb3', 'vid': '1121', 'pid': '20052', 'bus': '1', 'speed': 1, 'ifc': [3], 'mport': '(9, 1)', 'port': '1'},
# '(6,)': {'type': 'usb3', 'vid': '1267', 'pid': '3147', 'bus': '1', 'speed': 2, 'ifc': [255], 'mport': '(6,)', 'port': '6'}}
return parsed_usb3

def get_level_data(self, u3tbuf):
if not isinstance(u3tbuf, dict):
print("Error: u3tbuf is not a dictionary")
return None

pdict = {}
for rkitem in u3tbuf.keys():
lcnt = rkitem.count(',')
kl = list(pdict.keys())
if 'level'+str(lcnt) in kl:
pdict['level'+str(lcnt)].append(rkitem)
else:
pdict['level'+str(lcnt)] = [rkitem]
return pdict

127 changes: 0 additions & 127 deletions src/usb3tree/macusb4parse.py

This file was deleted.

Loading

0 comments on commit 0ecfbea

Please sign in to comment.