lib: open by serial number

parent 5e7c1b3d
......@@ -40,7 +40,7 @@ static struct {
};
int oau_att_open(int lun)
int oau_att_open(char *serial)
{
int ret;
......@@ -56,18 +56,26 @@ int oau_att_open(int lun)
return -ENOMEM;
}
if ((ret = ftdi_usb_open(ctx->ftdi, OAU_VENDOR_ID, OAU_DEVICE_ID)) < 0)
{
ftdi_free(ctx->ftdi);
return ret;
}
if (serial) {
ret = ftdi_usb_open_desc(ctx->ftdi,
OAU_VENDOR_ID, OAU_DEVICE_ID, NULL, serial);
if (ret < 0) {
ftdi_free(ctx->ftdi);
return ret;
}
} else { /* open first, and maybe only, device at hand */
ret = ftdi_usb_open(ctx->ftdi, OAU_VENDOR_ID, OAU_DEVICE_ID);
if (ret < 0) {
ftdi_free(ctx->ftdi);
return ret;
}
}
if( (ret = ftdi_set_bitmode(ctx->ftdi, 0xff, BITMODE_BITBANG)) < 0 )
{
if( (ret = ftdi_set_bitmode(ctx->ftdi, 0xff, BITMODE_BITBANG)) < 0 ) {
ftdi_usb_close( ctx->ftdi );
ftdi_free(ctx->ftdi);
return ret;
}
}
uint8_t pins;
......
......@@ -40,11 +40,11 @@ enum oau_att_value_enum {
* A board is selected by lun, and a handle is returned for further
* reference to it.
*
* @param lun - LUN of msatt card
* @param serial - serial number of USB attenuator
*
* @return >0 - on success, device file descriptor number
*/
int oau_att_open(int lun);
int oau_att_open(char *serial);
/**
* @brief close a channel handle
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment