|
发表于 2024-1-31 05:46:17
|
显示全部楼层
不一定。看上位机情况。上位机可以用PID/VID白名单,也可以看设备名。
插一段openocd识别CMSIS-DAP的代码
-
- /*
- * The CMSIS-DAP specification stipulates:
- * "The Product String must contain "CMSIS-DAP" somewhere in the string. This is used by the
- * debuggers to identify a CMSIS-DAP compliant Debug Unit that is connected to a host computer."
- */
- devs = hid_enumerate(0x0, 0x0);
- cur_dev = devs;
- while (cur_dev) {
- bool found = false;
- if (vids[0] == 0) {
- if (!cur_dev->product_string) {
- LOG_DEBUG("Cannot read product string of device 0x%x:0x%x",
- cur_dev->vendor_id, cur_dev->product_id);
- } else if (wcsstr(cur_dev->product_string, L"CMSIS-DAP")) {
- /* if the user hasn't specified VID:PID *and*
- * product string contains "CMSIS-DAP", pick it
- */
- found = true;
- }
- } else {
- /* otherwise, exhaustively compare against all VID:PID in list */
- for (i = 0; vids[i] || pids[i]; i++) {
- if ((vids[i] == cur_dev->vendor_id) && (pids[i] == cur_dev->product_id))
- found = true;
- }
- }
复制代码
|
|