-static const int *hw_hwcap_get_all(void)
-{
- sr_spew("genericdmm: Returning list of device capabilities.");
-
- return hwcaps;
-}
-
-static int parse_conn_vidpid(struct sr_dev_inst *sdi, const char *conn)
-{
- struct context *ctx;
- libusb_device **devlist;
- struct libusb_device_descriptor des;
- GRegex *reg;
- GMatchInfo *match;
- int vid, pid, found, err, i;
- char *vidstr, *pidstr;
-
- found = FALSE;
-
- reg = g_regex_new(DMM_CONN_USB_VIDPID, 0, 0, NULL);
- if (g_regex_match(reg, conn, 0, &match)) {
- /* Extract VID. */
- if (!(vidstr = g_match_info_fetch(match, 0))) {
- sr_err("failed to fetch VID from regex");
- goto err;
- }
- vid = strtoul(vidstr, NULL, 16);
- g_free(vidstr);
- if (vid > 0xffff) {
- sr_err("invalid VID");
- goto err;
- }
-
- /* Extract PID. */
- if (!(pidstr = g_match_info_fetch(match, 0))) {
- sr_err("failed to fetch PID from regex");
- goto err;
- }
- pid = strtoul(pidstr, NULL, 16);
- g_free(pidstr);
- if (pid > 0xffff) {
- sr_err("invalid PID");
- goto err;
- }
-
- /* Looks like a valid VID:PID, but is it connected? */
- libusb_get_device_list(genericdmm_usb_context, &devlist);
- for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("genericdmm: failed to get device descriptor: %d", err);
- goto err;
- }
-
- if (des.idVendor == vid && des.idProduct == pid) {
- ctx = sdi->priv;
- ctx->usb = sr_usb_dev_inst_new(
- libusb_get_bus_number(devlist[i]),
- libusb_get_device_address(devlist[i]), NULL);
- found = TRUE;
- break;
- }
- }
- libusb_free_device_list(devlist, 1);
- }
-
-err:
- if (match)
- g_match_info_unref(match);
- g_regex_unref(reg);
-
- return found;
-}
-
-static int parse_conn_busaddr(struct sr_dev_inst *sdi, const char *conn)
-{
- struct context *ctx;
- libusb_device **devlist;
- struct libusb_device_descriptor des;
- GRegex *reg;
- GMatchInfo *match;
- int bus, addr, found, err, i;
- char *busstr, *addrstr;
-
- found = FALSE;
-
- reg = g_regex_new(DMM_CONN_USB_BUSADDR, 0, 0, NULL);
- if (g_regex_match(reg, conn, 0, &match)) {
- /* Extract bus. */
- if (!(busstr = g_match_info_fetch(match, 0))) {
- sr_err("failed to fetch bus from regex");
- goto err;
- }
- bus = strtoul(busstr, NULL, 16);
- g_free(busstr);
- if (bus > 64) {
- sr_err("invalid bus");
- goto err;
- }
-
- /* Extract address. */
- if (!(addrstr = g_match_info_fetch(match, 0))) {
- sr_err("failed to fetch address from regex");
- goto err;
- }
- addr = strtoul(addrstr, NULL, 16);
- g_free(addrstr);
- if (addr > 127) {
- sr_err("invalid address");
- goto err;
- }
-
- /* Looks like a valid bus/address, but is it connected? */
- libusb_get_device_list(genericdmm_usb_context, &devlist);
- for (i = 0; devlist[i]; i++) {
- if ((err = libusb_get_device_descriptor(devlist[i], &des))) {
- sr_err("genericdmm: failed to get device descriptor: %d", err);
- goto err;
- }
-
- if (libusb_get_bus_number(devlist[i]) == bus
- && libusb_get_device_address(devlist[i]) == addr) {
- ctx = sdi->priv;
- ctx->usb = sr_usb_dev_inst_new(bus, addr, NULL);
- found = TRUE;
- break;
- }
- }
- libusb_free_device_list(devlist, 1);
- }
-
-err:
- if (match)
- g_match_info_unref(match);
- g_regex_unref(reg);
-
- return found;
-}
-
-static int parse_conn_serial(struct sr_dev_inst *sdi, const char *conn)
-{
- int found;
-
- found = FALSE;
-
- /* TODO */
-
- return found;
-}
-
-static int parse_conn(struct sr_dev_inst *sdi, const char *conn)
-{
-
- if (parse_conn_vidpid(sdi, conn))
- return SR_OK;
-
- if (parse_conn_busaddr(sdi, conn))
- return SR_OK;
-
- if (parse_conn_serial(sdi, conn))
- return SR_OK;
-
- sr_err("Invalid connection specification");
-
- return SR_ERR;
-}
-
-static int parse_serialcomm(struct sr_dev_inst *sdi, const char *conn)
-{
-
- /* TODO */
- /* set ctx->serial_* */
-
- return SR_OK;
-}
-