Skip to content

Commit

Permalink
Updated local usb catalog in Python SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
pradolis committed Aug 10, 2023
1 parent 6881f61 commit baa678c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,18 @@ def query_dtdl_model(board_id, fw_id):
usb_device_catalog_path = os.path.join(os.path.dirname(sys.modules[__name__].__file__),"usb_device_catalog.json")
with open(usb_device_catalog_path, "r") as catalog:
temp = json.load(catalog)
dtdl_model_ids = []
for entry in temp:
if entry["board_id"] == board_id and entry["fw_id"] == fw_id:
if "custom_dtmi" in entry and entry["custom_dtmi"] != "":
print("DeviceTemplateManager - ALERT - CUSTOM User dtmi Overwrites the base supported model. Call remove_custom_dtdl_model(...) to restore the original one.")
dtdl_model_id = entry["custom_dtmi"]
dtdl_model_ids.append(dtdl_model_id)
print("dtmi: {}".format(dtdl_model_id))
elif "local_dtmi" in entry and entry["local_dtmi"] != "":
print("dtmi found in locally in base supported models")
dtdl_model_id = entry["local_dtmi"]
dtdl_model_ids.append(dtdl_model_id)
print("dtmi: {}".format(dtdl_model_id))
#NOTE for the next version
# print("Searching the corresponding Device Template model in Azure Device Models repository...")
Expand Down Expand Up @@ -152,7 +155,15 @@ def query_dtdl_model(board_id, fw_id):
# print("dtmi found in locally in base supported models")
# dtdl_model_id = entry["local_dtmi"]
# print("dtmi: {}".format(dtdl_model_id))
dtdl_json_path = os.path.join(os.path.dirname(sys.modules[__name__].__file__), dtdl_model_id)
if len(dtdl_model_ids) == 1:
dtdl_json_path = os.path.join(os.path.dirname(sys.modules[__name__].__file__), dtdl_model_id)
with open(dtdl_json_path, "r") as device_model:
return json.load(device_model)
else:
device_models = {}
for dtm_id in dtdl_model_ids:
dtdl_json_path = os.path.join(os.path.dirname(sys.modules[__name__].__file__), dtm_id)
with open(dtdl_json_path, "r") as device_model:
return json.load(device_model)
device_models[dtm_id] = json.load(device_model)
return device_models
return ""
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,26 @@
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_mkboxpro/fpSnsDatalog2_datalog2-2.json"
},
{
"board_id": "0xd",
"fw_id": "0xa",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_mkboxpro/fpSnsDatalog2_datalog2-2.json"
},
{
"board_id": "0xd",
"fw_id": "0xff",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_mkboxpro/fpSnsDatalog2_datalog2-3.json"
},
{
"board_id": "0xe",
"fw_id": "0xff",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_stwinbx1/fp_motor_control-3.json"
"local_dtmi": "dtmi/appconfig/steval_stwinbx1/fp_motor_control-4.json"
},
{
"board_id": "0xe",
Expand Down Expand Up @@ -96,6 +110,19 @@
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_stwinbx1/fpSnsDatalog2_ultrasoundFft-3.json"
},
{
"board_id": "0xe",
"fw_id": "0x17",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_stwinbx1/fpSnsDatalog2_datalog2-3.json"
},
{
"board_id": "0xe",
"fw_id": "0x18",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_stwinbx1/fpSnsDatalog2_datalog2Ispu-3.json"
},
{
"board_id": "0xe",
"fw_id": "0x2",
Expand All @@ -111,7 +138,7 @@
},
{
"board_id": "0x10",
"fw_id": "0x01",
"fw_id": "0x1",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/nucleo_u575zi_q/x_nucleo_iks02a1/fpSnsDatalog2_datalog2-1.json"
Expand All @@ -125,16 +152,23 @@
},
{
"board_id": "0x20",
"fw_id": "0x01",
"fw_id": "0x1",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/b_u585i_iot02a/fpSnsDatalog2_datalog2-1.json"
},
{
"board_id": "0x30",
"fw_id": "0x01",
"fw_id": "0x1",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/nucleo_h7a3zi_q/x_nucleo_iks02a1/fpSnsDatalog2_datalog2-1.json"
},
{
"board_id": "0x9",
"fw_id": "0xff",
"az_cloud_dtmi": "",
"st_cloud_dtmi": "",
"local_dtmi": "dtmi/appconfig/steval_stwinkt1b/fpSnsDatalog2_datalog2-1.json"
}
]

0 comments on commit baa678c

Please sign in to comment.