Exemple #1
0
void TICC1100::initChip()
{
	try
	{
		if(_fileDescriptor->descriptor == -1)
		{
			_out.printError("Error: Could not initialize TI CC1100. The spi device's file descriptor is not valid.");
			return;
		}
		reset();

		int32_t index = 0;
		for(std::vector<uint8_t>::const_iterator i = _config.begin(); i != _config.end(); ++i)
		{
			if(writeRegister((Registers::Enum)index, *i, true) != *i)
			{
				closeDevice();
				return;
			}
			index++;
		}
		if(writeRegister(Registers::Enum::FSTEST, 0x59, true) != 0x59)
		{
			closeDevice();
			return;
		}
		if(writeRegister(Registers::Enum::TEST2, 0x81, true) != 0x81) //Determined by SmartRF Studio
		{
			closeDevice();
			return;
		}
		if(writeRegister(Registers::Enum::TEST1, 0x35, true) != 0x35) //Determined by SmartRF Studio
		{
			closeDevice();
			return;
		}
		if(writeRegister(Registers::Enum::PATABLE, _settings->txPowerSetting, true) != _settings->txPowerSetting)
		{
			closeDevice();
			return;
		}

		sendCommandStrobe(CommandStrobes::Enum::SFRX);
		usleep(20);

		enableRX(true);
	}
    catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemple #2
0
void closeBlockDevice(struct AFSBase *afsbase, struct IOHandle *ioh) {

	remChangeInt(afsbase, ioh);
	if (ioh->iochangeint != NULL)
		closeDevice(afsbase, ioh->iochangeint);
	if (ioh->ioreq != NULL)
		closeDevice(afsbase, ioh->ioreq);
	if (ioh->mp != NULL)
		DeleteMsgPort(ioh->mp);
}
int V4L2JpegEncoder::run(void)
{
	int ret;
	sp<Buffer> thumbData;
	sp<Buffer> exifData;

	TRACE();

	ret = openDevice();
	if (ret < 0) {
		ERR("Failed to open JPEG encoder device");
		return -1;
	}

	if (thumbnail.allocation != 0) {
		ret = encodeImage(&thumbnail);
		if (ret >= 0) {
			V4L2Buffer *buf =
					output.allocation->getBuffer(0);
			thumbData = new Buffer(buf->getUsed(),
							buf->getAddress());
		}
	}

	ret = encodeImage(&input);
	if (ret < 0) {
		ERR("Failed to encode JPEG image");
		closeDevice();
		return -1;
	}

	closeDevice();

	uint32_t exifSize = EXIF_SIZE;
	if (thumbData != 0)
		exifSize += thumbData->getSize();

	exifData = new Buffer(exifSize);
	if (exifData == 0 || !exifData->initCheck()) {
		ERR("Failed to allocate exif buffer");
		return -1;
	}
	exifData->zero();

	exifSize = buildExif(exifData, thumbData);

	V4L2Buffer *buf = output.allocation->getBuffer(0);
	char *addr = (char *)buf->getAddress();
	memmove(addr + exifSize, addr, buf->getUsed());
	memcpy(addr, addr + exifSize, 2);
	memcpy(addr + 2, exifData->getData(), exifSize);

	return buf->getUsed() + exifSize;
}
Exemple #4
0
void TICC1100::stopListening()
{
	try
	{
		if(_listenThread.joinable())
		{
			_stopCallbackThread = true;
			_listenThread.join();
		}
		_stopCallbackThread = false;
		if(_fileDescriptor->descriptor != -1) closeDevice();
		closeGPIO(1);
		_stopped = true;
		IPhysicalInterface::stopListening();
	}
	catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
VideoCaptureDirectShow2::~VideoCaptureDirectShow2() {
  if(media_control) {
    closeDevice();
  }

  CoUninitialize();
}
Exemple #6
0
void CVFD::setlcdparameter(int dimm, const int power)
{
	if(!has_lcd) return;

	if(dimm < 0)
		dimm = 0;
	else if(dimm > 15)
		dimm = 15;

	if(!power)
		dimm = 0;

	if(brightness == dimm)
		return;

	brightness = dimm;

printf("CVFD::setlcdparameter dimm %d power %d\n", dimm, power);
#ifdef __sh__
        openDevice();

        struct vfd_ioctl_data data;
	data.start_address = dimm;
	
	int ret = ioctl(fd, VFDBRIGHTNESS, &data);

        closeDevice();
#else
	int ret = ioctl(fd, IOC_VFD_SET_BRIGHT, dimm);
	if(ret < 0)
		perror("IOC_VFD_SET_BRIGHT");
#endif
}
Exemple #7
0
// Helper function, perform a sanity check on the device
MediaError MythCDROMFreeBSD::testMedia()
{
    //cout << "MythCDROMLinux::testMedia - ";
    bool OpenedHere = false;
    if (!isDeviceOpen()) 
    {
        //cout << "Device is not open - ";
        if (!openDevice()) 
        {
            //cout << "failed to open device - ";
            if (errno == EBUSY)
            {
                //cout << "errno == EBUSY" << endl;
                return isMounted(true) ? MEDIAERR_OK : MEDIAERR_FAILED;
            } 
            else 
            { 
                return MEDIAERR_FAILED; 
            }
        }
        //cout << "Opened it - ";
        OpenedHere = true;
    }

    // Be nice and close the device if we opened it, otherwise it might be locked when the user doesn't want it to be.
    if (OpenedHere)
        closeDevice();

    return MEDIAERR_OK;
}
int main(int argc, char **argv)
{
	
	if (argc >= 3) {

		float freq = strtof(argv[1], NULL);
		float bandwidth = strtof(argv[2], NULL);
		int decimation = atoi(argv[3]);

		std::cout << "Frequency: " << freq << "\n";
		std::cout << "Bandwidth " << bandwidth << "\n";
		std::cout << "Decimation " << decimation << "\n";

		std::cout << "Opening Signalhound SA device\n";
		int id = openDevice();

		startIQ(id, freq, bandwidth, decimation);

//		startIQ(id, 915.0e6, 50.0e3, 8);

		closeDevice(id);
	}
	else {
		std::cout << "Stream IQ pairs at a particualar frequency\n";
		std::cout << "Usage:\n";

		std::cout << "signalhoundiq frequency bandwidth [decimation]\n";
		std::cout << "Frequency in Hz\n";
		std::cout << "Bandwidth in Hz\n";
		std::cout << "Decimation 1-16 (default 8)\n";
	}
	return 0;
}
void *run(void *ptr_shared_data) {
	char cTmp[MAX_LINE];

	int l_change = 0;

	g_ptr_shared_data = (struct shared_data *) ptr_shared_data;
	// Initialize datarefs
	g_comFreq = g_ptr_shared_data->comFreq;

	last_mainloop_idle = sys_time_clock_get_time_usec();
	// while stop == 0 calculate position.
	while (g_ptr_shared_data->stop == 0) {
		long loop_start_time = sys_time_clock_get_time_usec();

		///////////////////////////////////////////////////////////////////////////
		/// CRITICAL FAST 20 Hz functions
		///////////////////////////////////////////////////////////////////////////
		if (us_run_every(50000, COUNTER3, loop_start_time)) {
			// read usb board values
			l_change = readDevice(&g_usb_data);
			// Update xplane
			updateHost();
			// Update board
			updateBoard();
		}
		///////////////////////////////////////////////////////////////////////////

		///////////////////////////////////////////////////////////////////////////
		/// NON-CRITICAL SLOW 10 Hz functions
		///////////////////////////////////////////////////////////////////////////
		else if (us_run_every(100000, COUNTER6, loop_start_time)) {
			//update_screen();
		}
		///////////////////////////////////////////////////////////////////////////

		if (loop_start_time - last_mainloop_idle >= 100000) {
			writeLog("CRITICAL WARNING! CPU LOAD TOO HIGH.\n");
			last_mainloop_idle = loop_start_time;//reset to prevent multiple messages
		} else {
			//writeConsole(0, 0, "CPU LOAD OK.");
		}

		// wait 1 milliseconds
#if IBM
		Sleep(1);
#endif
#if LIN
		usleep(10);
#endif
		g_counter++;
	}
	sprintf(cTmp, "thread closing usb device %d...\n", 0);
	writeLog(cTmp);
	closeDevice();
	sprintf(cTmp, "thread info : stopping thread #%d, %d!\n",
			g_ptr_shared_data->thread_id, g_counter);
	writeLog(cTmp);
	pthread_exit(NULL);
	return 0;
}
Exemple #10
0
bool AudioStream::openDevice(AudioSample::eFrequency frequency)
{
    PaError err;
    PaStreamParameters *input = (_streamType & INPUT_STREAM) ? &_inputParameter : NULL;
    PaStreamParameters *output = (_streamType & OUTPUT_STREAM) ? &_outputParameter : NULL;
    double sample = AudioSample::frequencyToDouble(frequency);

    if (_isOpen)
        closeDevice();

    if (_channelCount == 0)
    {
        _errText = "The input or the output must be set before openning";
        return false;
    }

    if (qFuzzyCompare(sample, 0.))
    {
        _errText = "Invalid frequency choose";
        return false;
    }

    if ((err = Pa_OpenStream(&_stream, input, output, sample, NB_FRAMES_PER_BUFFER * _channelCount, paClipOff, &AudioStream::_callback, this)) != paNoError)
    {
        _errText = Pa_GetErrorText(err);
        return false;
    }

    _frequency = frequency;
    _isOpen = true;
    return true;
}
Exemple #11
0
void RS485::openDevice()
{
	try
	{
		if(_fileDescriptor->descriptor != -1) closeDevice();

		_lockfile = "/var/lock" + _settings->device.substr(_settings->device.find_last_of('/')) + ".lock";
		int lockfileDescriptor = open(_lockfile.c_str(), O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
		if(lockfileDescriptor == -1)
		{
			if(errno != EEXIST)
			{
				_out.printCritical("Couldn't create lockfile " + _lockfile + ": " + strerror(errno));
				return;
			}

			int processID = 0;
			std::ifstream lockfileStream(_lockfile.c_str());
			lockfileStream >> processID;
			if(getpid() != processID && kill(processID, 0) == 0)
			{
				_out.printCritical("CRC RS485 device is in use: " + _settings->device);
				return;
			}
			unlink(_lockfile.c_str());
			lockfileDescriptor = open(_lockfile.c_str(), O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
			if(lockfileDescriptor == -1)
			{
				_out.printCritical("Couldn't create lockfile " + _lockfile + ": " + strerror(errno));
				return;
			}
		}
		dprintf(lockfileDescriptor, "%10i", getpid());
		close(lockfileDescriptor);
		//std::string chmod("chmod 666 " + _lockfile);
		//system(chmod.c_str());

		_fileDescriptor = _bl->fileDescriptorManager.add(open(_settings->device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY ));

		if(_fileDescriptor->descriptor == -1)
		{
			_out.printCritical("Couldn't open CRC RS485 device \"" + _settings->device + "\": " + strerror(errno));
			return;
		}

		setupDevice();
	}
	catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
bool HIDDevice::HIDInitialize(const String& path)
{

    DevDesc.Path = path;

    if (!openDevice())
    {
        LogText("OVR::OSX::HIDDevice - Failed to open HIDDevice: %s", path.ToCStr());
        return false;
    }

    // Setup notification for when a device is unplugged and plugged back in.
    if (!setupDevicePluggedInNotification())
    {
        LogText("OVR::OSX::HIDDevice - Failed to setup notification for when device plugged back in.");
        closeDevice(false);
        return false;
    }
    
    HIDManager->DevManager->pThread->AddTicksNotifier(this);

    
    LogText("OVR::OSX::HIDDevice - Opened '%s'\n"
            "                    Manufacturer:'%s'  Product:'%s'  Serial#:'%s'\n",
            DevDesc.Path.ToCStr(),
            DevDesc.Manufacturer.ToCStr(), DevDesc.Product.ToCStr(),
            DevDesc.SerialNumber.ToCStr());
    
    return true;
}
// Helper function, perform a sanity check on the device
MythMediaError MythCDROMFreeBSD::testMedia()
{
    bool OpenedHere = false;
    if (!isDeviceOpen())
    {
        if (!openDevice())
        {
            if (errno == EBUSY)
            {
                return isMounted() ? MEDIAERR_OK : MEDIAERR_FAILED;
            }
            else
            {
                return MEDIAERR_FAILED;
            }
        }
        OpenedHere = true;
    }

    // Be nice and close the device if we opened it, otherwise it might be locked when the user doesn't want it to be.
    if (OpenedHere)
        closeDevice();

    return MEDIAERR_OK;
}
bool MMSInputLISThread::openDevice() {
	// close device if already opened
	closeDevice();

	MSG2OUT("MMSINPUTMANAGER", "Opening %s, type=%s (%s)\n",
						this->device.name.c_str(),
						this->device.type.c_str(),
						this->device.desc.c_str());

	// open the device
	if ((this->dv_fd = open(this->device.name.c_str(), O_RDWR)) < 0) {
		MSG2OUT("MMSINPUTMANAGER", "could not open device: %s\n", this->device.name.c_str());
		this->dv_fd = -1;
		return false;
	}

	// try to grab the device
	if (ioctl(this->dv_fd, EVIOCGRAB, 1)) {
		MSG2OUT("MMSINPUTMANAGER", "could not grab device: %s\n", this->device.name.c_str());
		close(this->dv_fd);
		this->dv_fd = -1;
		return false;
	}

	return true;
}
Exemple #15
0
ComediAnalogIOSoftCal::~ComediAnalogIOSoftCal()
{
        Logger(Debug, "ComediAnalogIOSoftCal::~ComediAnalogIOSoftCal()\n");
        comedi_cleanup_calibration(m_calibration);
        delete m_calibrationFile;
        closeDevice();
}
Exemple #16
0
int openDevice(char *dev){
	int fd = open(dev, O_RDWR | O_NOCTTY );
	if(fd<0){
		do_log("openDevice", "Couldn't open Device", LOG_LEVEL_FATAL,LOG_TYPE_SIGNAL);
		return -1;
	}
	//ioctl(fd, TIOCEXCL);
	struct termios options;
	tcgetattr(fd, &options);
	
    options.c_cflag|=(CLOCAL | CREAD);
    options.c_cflag&=~CSIZE;
    options.c_cflag|=CS8;
    options.c_cflag&=~PARENB;
    options.c_cflag&=~CSTOPB;
    options.c_lflag &= ~(ECHO | ECHONL | ICANON | IEXTEN | ISIG);
    options.c_iflag &= ~(IXON | IXOFF | IXANY );
    options.c_oflag &= ~(OCRNL | ONLCR | ONLRET |ONOCR | OFILL | OLCUC | OPOST);

    options.c_cc[VTIME]=5;
	options.c_cc[VMIN]=0;
    
    if(tcsetattr(fd, TCSANOW, &options)<0){
		do_log("openDevice","Couldn't set Options",LOG_LEVEL_FATAL,LOG_TYPE_SIGNAL);
		closeDevice(fd);
		return -4;
	}
    if(autoConfigBaud(fd)<0){
		return -5;
	}
	return fd;
}
//-----------------------------------------------------------------------------
bool HIDDevice::OnDeviceNotification(MessageType messageType,
                                     HIDDeviceDesc* device_info,
                                     bool* error)
{
    const char* device_path = device_info->Path.ToCStr();

    if (messageType == Message_DeviceAdded && DeviceHandle < 0)
    {
        // Is this the correct device?
        if (!(device_info->VendorId == DevDesc.VendorId
            && device_info->ProductId == DevDesc.ProductId
            && device_info->SerialNumber == DevDesc.SerialNumber))
        {
            return false;
        }

        // A closed device has been re-added. Try to reopen.
        if (!openDevice(device_path))
        {
            LogError("OVR::Linux::HIDDevice - Failed to reopen a device '%s' that was re-added.\n", 
                     device_path);
            *error = true;
            return true;
        }

        LogText("OVR::Linux::HIDDevice - Reopened device '%s'\n", device_path);

        if (Handler)
        {
            Handler->OnDeviceMessage(HIDHandler::HIDDeviceMessage_DeviceAdded);
        }
    }
    else if (messageType == Message_DeviceRemoved)
    {
        // Is this the correct device?
        // For disconnected device, the device description will be invalid so
        // checking the path is the only way to match them
        if (DevDesc.Path.CompareNoCase(device_path) != 0)
        {
            return false;
        }

        if (DeviceHandle >= 0)
        {
            closeDevice(true);
        }

        if (Handler)
        {
            Handler->OnDeviceMessage(HIDHandler::HIDDeviceMessage_DeviceRemoved);
        }
    }
    else
    {
        OVR_ASSERT(0);
    }

    *error = false;
    return true;
}
Exemple #18
0
bool FCDProInput::openDevice()
{
    if (m_dev != 0) {
        closeDevice();
    }

    int device = m_deviceAPI->getSampleSourceSequence();
    qDebug() << "FCDProInput::openDevice with device #" << device;
    m_dev = fcdOpen(fcd_traits<Pro>::vendorId, fcd_traits<Pro>::productId, device);

    if (m_dev == 0)
    {
        qCritical("FCDProInput::start: could not open FCD");
        return false;
    }

    if (!openFCDAudio(fcd_traits<Pro>::qtDeviceName))
    {
        qCritical("FCDProInput::start: could not open FCD audio source");
        return false;
    }
    else
    {
        qDebug("FCDProInput::start: FCD audio source opened");
    }

    return true;
}
int InputDriverAbstract::finalize()
{
	int ret;

	ret = closeDevice();

	mDeviceStatus = IDS_UNITIALIZED;
	mDeviceType = IDT_UNITIALIZED;
	mSupportedEvents = IDET_UNITIALIZED;
	mDeviceName = UNITIALIZED_DEVICE_STRING;
	mDevicePhisicalPath = UNITIALIZED_DEVICE_STRING;
	mDeviceUnique = UNITIALIZED_DEVICE_STRING;

	if (mMapKeys) {
		delete mMapKeys;
		mMapKeys = NULL;
	}
	if (mMapAbs) {
		delete mMapAbs;
		mMapAbs = NULL;
	}
	if (mMapRel) {
		delete mMapRel;
		mMapRel = NULL;
	}
	return ret;
}
Exemple #20
0
void TICC1100::openDevice()
{
	try
	{
		if(_fileDescriptor->descriptor != -1) closeDevice();

		_lockfile = GD::bl->settings.lockFilePath() + "LCK.." + _settings->device.substr(_settings->device.find_last_of('/') + 1);
		int lockfileDescriptor = open(_lockfile.c_str(), O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
		if(lockfileDescriptor == -1)
		{
			if(errno != EEXIST)
			{
				_out.printCritical("Couldn't create lockfile " + _lockfile + ": " + strerror(errno));
				return;
			}

			int processID = 0;
			std::ifstream lockfileStream(_lockfile.c_str());
			lockfileStream >> processID;
			if(getpid() != processID && kill(processID, 0) == 0)
			{
				_out.printCritical("Rf device is in use: " + _settings->device);
				return;
			}
			unlink(_lockfile.c_str());
			lockfileDescriptor = open(_lockfile.c_str(), O_WRONLY | O_EXCL | O_CREAT, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
			if(lockfileDescriptor == -1)
			{
				_out.printCritical("Couldn't create lockfile " + _lockfile + ": " + strerror(errno));
				return;
			}
		}
		dprintf(lockfileDescriptor, "%10i", getpid());
		close(lockfileDescriptor);

		_fileDescriptor = _bl->fileDescriptorManager.add(open(_settings->device.c_str(), O_RDWR | O_NONBLOCK));
		usleep(1000);

		if(_fileDescriptor->descriptor == -1)
		{
			_out.printCritical("Couldn't open rf device \"" + _settings->device + "\": " + strerror(errno));
			return;
		}

		setupDevice();
	}
	catch(const std::exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(BaseLib::Exception& ex)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__, ex.what());
    }
    catch(...)
    {
        _out.printEx(__FILE__, __LINE__, __PRETTY_FUNCTION__);
    }
}
Exemple #21
0
//---------------------------------------------------------------------------
void TRig::closeOak(void)
{
   if(isOakOpen())
       closeDevice(oakHandle);

    oakHandle = -1;
    oak_flags = 0;
}
Exemple #22
0
ComediDigitalIO::~ComediDigitalIO()
{
        Logger(Debug, "ComediDigitalIO::~ComediDigitalIO()\n");
        closeDevice();
        if (m_nChannels > 0) {
                delete m_channels;
        }
}
Exemple #23
0
AudioStream::~AudioStream()
{
    stop();
    closeDevice();

    --_nbStream;
    if (_nbStream == 0)
        Pa_Terminate();
}
Exemple #24
0
bool Bladerf1Output::openDevice()
{
    if (m_dev != 0)
    {
        closeDevice();
    }

    int res;

    m_sampleSourceFifo.resize(m_settings.m_devSampleRate/(1<<(m_settings.m_log2Interp <= 4 ? m_settings.m_log2Interp : 4)));

    if (m_deviceAPI->getSourceBuddies().size() > 0)
    {
        DeviceSourceAPI *sourceBuddy = m_deviceAPI->getSourceBuddies()[0];
        DeviceBladeRF1Params *buddySharedParams = (DeviceBladeRF1Params *) sourceBuddy->getBuddySharedPtr();

        if (buddySharedParams == 0)
        {
            qCritical("BladerfOutput::start: could not get shared parameters from buddy");
            return false;
        }

        if (buddySharedParams->m_dev == 0) // device is not opened by buddy
        {
            qCritical("BladerfOutput::start: could not get BladeRF handle from buddy");
            return false;
        }

        m_sharedParams = *(buddySharedParams); // copy parameters from buddy
        m_dev = m_sharedParams.m_dev;          // get BladeRF handle
    }
    else
    {
        if (!DeviceBladeRF1::open_bladerf(&m_dev, qPrintable(m_deviceAPI->getSampleSinkSerial())))
        {
            qCritical("BladerfOutput::start: could not open BladeRF %s", qPrintable(m_deviceAPI->getSampleSinkSerial()));
            return false;
        }

        m_sharedParams.m_dev = m_dev;
    }

    // TODO: adjust USB transfer data according to sample rate
    if ((res = bladerf_sync_config(m_dev, BLADERF_TX_X1, BLADERF_FORMAT_SC16_Q11, 64, 8192, 32, 10000)) < 0)
    {
        qCritical("BladerfOutput::start: bladerf_sync_config with return code %d", res);
        return false;
    }

    if ((res = bladerf_enable_module(m_dev, BLADERF_MODULE_TX, true)) < 0)
    {
        qCritical("BladerfOutput::start: bladerf_enable_module with return code %d", res);
        return false;
    }

    return true;
}
void HIDDevice::HIDShutdown()
{

    HIDManager->Manager->pThread->RemoveTicksNotifier(this);
    HIDManager->Manager->pThread->RemoveMessageNotifier(this);

    closeDevice();
    LogText("OVR::Win32::HIDDevice - Closed '%s'\n", DevDesc.Path.ToCStr());
}
cAudio::~cAudio(void)
{
	closeDevice();
	free(dmxbuf);
	if (adevice)
		ao_close(adevice);
	adevice = NULL;
	ao_shutdown();
}
Exemple #27
0
ComediAnalogIO::~ComediAnalogIO()
{
        Logger(Debug, "ComediAnalogIO::~ComediAnalogIO()\n");
        closeDevice();
        if (m_nChannels > 0) {
                delete m_channels;
                delete m_data;
        }
}
Exemple #28
0
int mcp2200_hid_read_io(int connectionID, uint8_t *data){
	if (connectionID >= MCP2200_MAX_DEVICE_NUM) return MCP2200_INVALID_CONNECTION_ID;
	if (connection_list[connectionID] == NULL) return MCP2200_INVALID_CONNECTION_ID;

	uint8_t buffer[MCP2200_HID_REPORT_SIZE];
	uint8_t rbuffer[MCP2200_HID_REPORT_SIZE];
	clearBuffer(buffer);
	clearBuffer(rbuffer);

	buffer[0] = MCP2200_HID_COMMAND_READ_ALL;

	int t = 0;
	int r = libusb_interrupt_transfer(connection_list[connectionID], MCP2200_HID_ENDPOINT_OUT, buffer, MCP2200_HID_REPORT_SIZE, &t, MCP2200_HID_TRANSFER_TIMEOUT);

	if (r == LIBUSB_ERROR_NO_DEVICE){
		//Device is disconnected
		closeDevice(connectionID);
	}
	if (r != 0) return r;
	if (t < MCP2200_HID_REPORT_SIZE) return MCP2200_IO_ERROR;

	t = 0;
	r = libusb_interrupt_transfer(connection_list[connectionID], MCP2200_HID_ENDPOINT_IN, rbuffer, MCP2200_HID_REPORT_SIZE, &t, MCP2200_HID_TRANSFER_TIMEOUT);

	if (r == LIBUSB_ERROR_NO_DEVICE){
		//Device is disconnected
		closeDevice(connectionID);
	}
	if (r != 0) return r;

	if (rbuffer[0] != MCP2200_HID_COMMAND_READ_ALL) return MCP2200_INVALID_RESPONSE;
	if (t < MCP2200_HID_REPORT_SIZE) return MCP2200_IO_ERROR;

	int i;
	
	printf ("Config values: \n");
	
	for (i = 0; i<11; i++) {
	  printf("[%d] : %x\n",i,rbuffer[i]); 
	}
	
	*data = rbuffer[10];
	return 0;
}
Exemple #29
0
void mcp2200_disconnect(int connectionID){
	if (connectionID < MCP2200_MAX_DEVICE_NUM){
		if (connection_list[connectionID] != NULL){
			//Release HID interface
			libusb_release_interface(connection_list[connectionID], MCP2200_HID_INTERFACE);
			//Close device
			closeDevice(connectionID);
		}
	}
}
Exemple #30
0
mp_sint32 PlayerBase::stopPlaying()
{
	stop();
	
	mp_sint32 err = closeDevice();
	
	module = NULL;
	
	return err;
}