Ejemplo n.º 1
0
Archivo: yusb.c Proyecto: emmt/yusb
static void* get_data(int iarg, long* the_size)
{
  void* data;
  long size, ntot;
  int type;

  data = NULL;
  size = 0;
  if (! yarg_nil(iarg)) {
    data = ygeta_any(iarg, &ntot, NULL, &type);
    switch(type) {
    case Y_CHAR:
      size = sizeof(char)*ntot;
      break;
    case Y_SHORT:
      size = sizeof(short)*ntot;
      break;
    case Y_INT:
      size = sizeof(int)*ntot;
      break;
    case Y_LONG:
      size = sizeof(long)*ntot;
      break;
    case Y_FLOAT:
      size = sizeof(float)*ntot;
      break;
    case Y_DOUBLE:
      size = sizeof(double)*ntot;
      break;
    case Y_COMPLEX:
      size = 2*sizeof(double)*ntot;
      break;
    default:
      y_error("bad data type");
    }
  }
  if (the_size != NULL) {
    *the_size = size;
  }
  return data;
}
Ejemplo n.º 2
0
Archivo: yusb.c Proyecto: emmt/yusb
void Y__usb_probe_devices(int argc)
{
  struct libusb_device_descriptor desc;
  libusb_device* dev;
  long dims[3];
  int* data;
  int i, ret;

  if (argc != 1 || ! yarg_nil(0)) {
    y_error("expecting exactly one nil argument");
  }
  load_device_list();
  if (dev_count > 0) {
    dims[0] = 2;
    dims[1] = 7;
    dims[2] = dev_count;
    data = ypush_i(dims);
    for (i = 0; i < dev_count; ++i) {
      dev = dev_list[i];
      ret = libusb_get_device_descriptor(dev, &desc);
      if (ret != 0) {
        free_dev_list();
        failure("unable to get device descriptor", ret);
      }
      data[0] = libusb_get_bus_number(dev);
      data[1] = libusb_get_port_number(dev);
      data[2] = libusb_get_device_address(dev);
      data[3] = desc.idVendor;
      data[4] = desc.idProduct;
      data[5] = desc.iManufacturer;
      data[6] = desc.iSerialNumber;
      data += 7;
    }
  } else {
    ypush_nil();
  }
  free_dev_list();
}
Ejemplo n.º 3
0
inline int yav_arg_set(iarg) { return (iarg >= 0) && !yarg_nil(iarg); }
Ejemplo n.º 4
0
void
Y_gy_debug(int argc)
{
  ypush_long(_gy_debug);
  if (argc && !yarg_nil(argc)) _gy_debug = ygets_l(argc);
}