Exemplo n.º 1
0
Arquivo: Key.cpp Projeto: ellis/gcead
Key Key::parse(const QString& sKey) {
	const int iColonLast = sKey.lastIndexOf(':');
	CHECK_ASSERT_RETVAL(iColonLast != 0, Key::empty);

	const QString sParent = (iColonLast > 0) ? sKey.left(iColonLast) : QString();
	const QString sSelf = sKey.mid(iColonLast + 1);
	const int iEqual = sKey.indexOf('=');
	CHECK_ASSERT_RETVAL(iEqual > 0, Key::empty);

	const QString sKind = sSelf.left(iEqual);
	const QString sName = sSelf.mid(iEqual + 1);
	CHECK_ASSERT_RETVAL(!sName.isEmpty(), Key::empty);

	Key key(sKey, sKind, sName, sParent);
	return key;
}
Exemplo n.º 2
0
bool IdacDriverUsb24Base::claim(bool bUnhalt)
{
	CHECK_PRECOND_RETVAL(handle() != NULL, false);

	int res;

	libusb_device* dev = libusb_get_device(handle());
	CHECK_ASSERT_RETVAL(dev != NULL, false);

	libusb_config_descriptor* config = NULL;
	res = libusb_get_config_descriptor(dev, 0, &config);
	CHECK_USBRESULT_RETVAL(res, false);

	// Select configuration for the first descriptor
	res = libusb_set_configuration(handle(), config->bConfigurationValue);
	CHECK_USBRESULT_RETVAL(res, false);

	CHECK_ASSERT_RETVAL(config->bNumInterfaces > 0, false);
	const libusb_interface* interface = &config->interface[0];
	CHECK_ASSERT_RETVAL(interface->num_altsetting > 0, false);
	const libusb_interface_descriptor* altsetting = &interface->altsetting[0];
	const int idInterface = altsetting->bInterfaceNumber;
	res = libusb_claim_interface(handle(), idInterface);
	CHECK_USBRESULT_RETVAL(res, false);

	res = libusb_set_interface_alt_setting(handle(), idInterface, altsetting->bAlternateSetting);
	CHECK_USBRESULT_RETVAL(res, false);

	if (bUnhalt) {
		for (int i = 0; i < altsetting->bNumEndpoints; i++)
		{
			const int idEndpoint = altsetting->endpoint[i].bEndpointAddress;
			res = libusb_clear_halt(handle(), idEndpoint);
			CHECK_USBRESULT_RETVAL(res, false);
		}
	}

	return true;
}
Exemplo n.º 3
0
bool IdacDriverES::boot_2_USB()
{
    CHECK_ASSERT_RETVAL(IdacType() == IDAC_TYPE_2_USB, false);
    CHECK_ASSERT_RETVAL(IdacPresent(0), false);

    bool b = false;
    DWORD Result = IdacBoot(NULL, 1);
    switch (Result)
    {
    case 0:
        addError(tr("Invalid address"));
        break;
    case 1:
        b = true;
        break;
    case 3:
        addError(tr("Booting failed"));
        break;
    default:
        addError(tr("Error"));
        break;
    }
    return b;
}
Exemplo n.º 4
0
bool IdacDriverUsb24Base::checkUsbFirmwareReady()
{
	CHECK_PRECOND_RETVAL(handle() != NULL, false);

	bool b = false;
	libusb_device* dev = libusb_get_device(handle());
	CHECK_ASSERT_RETVAL(dev != NULL, false);
	libusb_config_descriptor* config = NULL;
	int res = libusb_get_config_descriptor(dev, 0, &config);
	CHECK_USBRESULT_RETVAL(res, false);
	if (config->bNumInterfaces == 1) {
		const libusb_interface* interface = &config->interface[0];
		b = (interface->num_altsetting == 1);
	}

	//interface[0].altsetting[0].bNumEndpoints != 3
	return b;
}
Exemplo n.º 5
0
bool IdacDriverES::startSampling()
{
    for (int iChan = 0; iChan < 3; iChan++)
    {
        const IdacChannelSettings* chan = desiredChannelSettings(iChan);
        CHECK_ASSERT_RETVAL(chan != NULL, false);

        IdacEnableChannel(iChan, chan->mEnabled);
        IdacSetDecimation(iChan, chan->nDecimation);
        if (iChan != 0)
        {
            IdacScaleRange(iChan, chan->iRange);
            IdacLowPass(iChan, chan->iHighcut);
            IdacHighPass(iChan, chan->iLowcut);
            IdacSetOffsetAnalogIn(iChan, chan->nOffset);
        }
    }

    startSamplingThread();
    return true;
}