|
|
|
@ -48,15 +48,8 @@ cable_probe (char *params[])
|
|
|
|
|
static int
|
|
|
|
|
cmd_cable_run (urj_chain_t *chain, char *params[])
|
|
|
|
|
{
|
|
|
|
|
urj_cable_t *cable = NULL;
|
|
|
|
|
int i;
|
|
|
|
|
int j;
|
|
|
|
|
int paramc = urj_cmd_params (params);
|
|
|
|
|
const urj_param_t **cable_params;
|
|
|
|
|
urj_cable_parport_devtype_t devtype = -1;
|
|
|
|
|
const char *devname = NULL;
|
|
|
|
|
int param_start = 2;
|
|
|
|
|
const urj_cable_driver_t *driver;
|
|
|
|
|
|
|
|
|
|
/* we need at least one parameter for 'cable' command */
|
|
|
|
|
if (paramc < 2)
|
|
|
|
@ -102,78 +95,7 @@ cmd_cable_run (urj_chain_t *chain, char *params[])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* search cable driver list */
|
|
|
|
|
for (i = 0; urj_tap_cable_drivers[i]; i++)
|
|
|
|
|
if (strcasecmp (params[1], urj_tap_cable_drivers[i]->name) == 0)
|
|
|
|
|
break;
|
|
|
|
|
driver = urj_tap_cable_drivers[i];
|
|
|
|
|
if (!driver)
|
|
|
|
|
{
|
|
|
|
|
urj_error_set (URJ_ERROR_NOTFOUND, _("Unknown cable type: '%s'"),
|
|
|
|
|
params[1]);
|
|
|
|
|
return URJ_STATUS_FAIL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (paramc >= 3 && strcasecmp (params[2], "help") == 0)
|
|
|
|
|
{
|
|
|
|
|
driver->help (URJ_LOG_LEVEL_NORMAL, driver->name);
|
|
|
|
|
return URJ_STATUS_OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (driver->device_type == URJ_CABLE_DEVICE_PARPORT)
|
|
|
|
|
{
|
|
|
|
|
if (paramc < 4)
|
|
|
|
|
{
|
|
|
|
|
urj_error_set (URJ_ERROR_SYNTAX,
|
|
|
|
|
"parallel cable requires >= 4 parameters");
|
|
|
|
|
return URJ_STATUS_FAIL;
|
|
|
|
|
}
|
|
|
|
|
for (j = 0; j < URJ_CABLE_PARPORT_N_DEVS; j++)
|
|
|
|
|
if (strcasecmp (params[2],
|
|
|
|
|
urj_cable_parport_devtype_string(j)) == 0)
|
|
|
|
|
break;
|
|
|
|
|
if (j == URJ_CABLE_PARPORT_N_DEVS)
|
|
|
|
|
{
|
|
|
|
|
urj_error_set (URJ_ERROR_INVALID,
|
|
|
|
|
"unknown parallel port device type '%s'", params[2]);
|
|
|
|
|
return URJ_STATUS_FAIL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
devtype = j;
|
|
|
|
|
devname = params[3];
|
|
|
|
|
param_start = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
urj_param_init (&cable_params);
|
|
|
|
|
for (j = param_start; params[j] != NULL; j++)
|
|
|
|
|
if (urj_param_push (&urj_cable_param_list, &cable_params,
|
|
|
|
|
params[j]) != URJ_STATUS_OK)
|
|
|
|
|
{
|
|
|
|
|
urj_param_clear (&cable_params);
|
|
|
|
|
return URJ_STATUS_FAIL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switch (driver->device_type)
|
|
|
|
|
{
|
|
|
|
|
case URJ_CABLE_DEVICE_PARPORT:
|
|
|
|
|
cable = urj_tap_cable_parport_connect (chain, driver, devtype, devname,
|
|
|
|
|
cable_params);
|
|
|
|
|
break;
|
|
|
|
|
case URJ_CABLE_DEVICE_USB:
|
|
|
|
|
cable = urj_tap_cable_usb_connect (chain, driver, cable_params);
|
|
|
|
|
break;
|
|
|
|
|
case URJ_CABLE_DEVICE_OTHER:
|
|
|
|
|
cable = urj_tap_cable_other_connect (chain, driver, cable_params);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
urj_param_clear (&cable_params);
|
|
|
|
|
|
|
|
|
|
if (cable == NULL)
|
|
|
|
|
return URJ_STATUS_FAIL;
|
|
|
|
|
|
|
|
|
|
chain->cable->chain = chain;
|
|
|
|
|
return URJ_STATUS_OK;
|
|
|
|
|
return urj_tap_chain_connect (chain, params[1], ¶ms[2]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|