Exemple #1
0
//-----------------------------------------------------------------------------
int dbg_enumerate(debugger_t *debuggers, int size) 
{
  struct hid_device_info *devs, *cur_dev;
  int rsize = 0;

  if (hid_init())
    return 0;

  devs = hid_enumerate(0, 0);
  cur_dev = devs;	

  for (cur_dev = devs; cur_dev && rsize < size; cur_dev = cur_dev->next)
  {
    debuggers[rsize].path = strdup(cur_dev->path);
    debuggers[rsize].serial = cur_dev->serial_number ? wcstombsdup(cur_dev->serial_number) : "<unknown>";
    debuggers[rsize].wserial = cur_dev->serial_number ? wcsdup(cur_dev->serial_number) : NULL;
    debuggers[rsize].manufacturer = cur_dev->manufacturer_string ? wcstombsdup(cur_dev->manufacturer_string) : "<unknown>";
    debuggers[rsize].product = cur_dev->product_string ? wcstombsdup(cur_dev->product_string) : "<unknown>";
    debuggers[rsize].vid = cur_dev->vendor_id;
    debuggers[rsize].pid = cur_dev->product_id;

    if (strstr(debuggers[rsize].product, "CMSIS-DAP"))
      rsize++;
  }

  hid_free_enumeration(devs);

  return rsize;
}
Exemple #2
0
char *
mbunconvert(wchar_t *str)
{
	static char *op = 0;

	if (op != 0)
		free(op);
	return (op = wcstombsdup(str));
}