本文整理汇总了C++中closeDevice函数的典型用法代码示例。如果您正苦于以下问题:C++ closeDevice函数的具体用法?C++ closeDevice怎么用?C++ closeDevice使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了closeDevice函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: reset
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__);
}
}
开发者ID:Homegear,项目名称:Homegear-MAX,代码行数:60,代码来源:TICC1100.cpp
示例2: closeBlockDevice
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);
}
开发者ID:michalsc,项目名称:AROS,代码行数:10,代码来源:os_aros_support.c
示例3: TRACE
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;
}
开发者ID:illyah,项目名称:android_device_samsung_volans,代码行数:54,代码来源:V4L2JpegEncoder.cpp
示例4: catch
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__);
}
}
开发者ID:skohlmus,项目名称:Homegear,代码行数:28,代码来源:TICC1100.cpp
示例5: closeDevice
VideoCaptureDirectShow2::~VideoCaptureDirectShow2() {
if(media_control) {
closeDevice();
}
CoUninitialize();
}
开发者ID:basseyndon,项目名称:roxlu_experimental,代码行数:7,代码来源:VideoCaptureDirectShow.cpp
示例6: if
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
}
开发者ID:Firmeware,项目名称:max-tdt,代码行数:33,代码来源:vfd.cpp
示例7: main
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;
}
开发者ID:hendorog,项目名称:signalhoundiq,代码行数:33,代码来源:signalhoundiq.cpp
示例8: sys_time_clock_get_time_usec
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;
}
开发者ID:taco24,项目名称:flapindicator-plugin-xplane,代码行数:60,代码来源:thread.c
示例9: closeDevice
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;
}
开发者ID:Wayt,项目名称:Skypy,代码行数:32,代码来源:audiostream.cpp
示例10: lockfileStream
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__);
}
}
开发者ID:skohlmus,项目名称:Homegear,代码行数:60,代码来源:RS485.cpp
示例11: LogText
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;
}
开发者ID:123woodman,项目名称:minko,代码行数:30,代码来源:OVR_OSX_HIDDevice.cpp
示例12: isMounted
// 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;
}
开发者ID:garybuhrmaster,项目名称:mythtv,代码行数:26,代码来源:mythcdrom-freebsd.cpp
示例13: closeDevice
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;
}
开发者ID:RomTok,项目名称:disco-light,代码行数:26,代码来源:mmsinputlisthread.cpp
示例14: Logger
ComediAnalogIOSoftCal::~ComediAnalogIOSoftCal()
{
Logger(Debug, "ComediAnalogIOSoftCal::~ComediAnalogIOSoftCal()\n");
comedi_cleanup_calibration(m_calibration);
delete m_calibrationFile;
closeDevice();
}
开发者ID:danielelinaro,项目名称:dynclamp,代码行数:7,代码来源:comedi_io.cpp
示例15: openDevice
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;
}
开发者ID:Doeme,项目名称:MySmartUSB-MK3-Interface,代码行数:32,代码来源:dev.c
示例16: LogError
//-----------------------------------------------------------------------------
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;
}
开发者ID:sebjf,项目名称:OculusSDK_0.3.2_CentOS,代码行数:61,代码来源:OVR_Linux_HIDDevice.cpp
示例17: closeDevice
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;
}
开发者ID:sigysmund,项目名称:sdrangel,代码行数:28,代码来源:fcdproinput.cpp
示例18: closeDevice
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;
}
开发者ID:rudolfovich,项目名称:linux_input_system,代码行数:27,代码来源:InputDriverAbstract.cpp
示例19: lockfileStream
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__);
}
}
开发者ID:Homegear,项目名称:Homegear-MAX,代码行数:59,代码来源:TICC1100.cpp
示例20: closeDevice
//---------------------------------------------------------------------------
void TRig::closeOak(void)
{
if(isOakOpen())
closeDevice(oakHandle);
oakHandle = -1;
oak_flags = 0;
}
开发者ID:poes-weather,项目名称:poes-usrp,代码行数:9,代码来源:rig.cpp
注:本文中的closeDevice函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论