void nglContext::Dump(uint Level) const { nglContextInfo info; if (!GetContextInfo(info)) return; info.Dump(Level); nglString version((const char*)glGetString(GL_VERSION)); nglString renderer((const char*)glGetString(GL_RENDERER)); nglString vendor((const char*)glGetString(GL_VENDOR)); nglString exts((const char*)glGetString(GL_EXTENSIONS)); #if (!defined _UIKIT_) && (!defined _ANDROID_) nglString sl((const char*)glGetString(GL_SHADING_LANGUAGE_VERSION)); #endif NGL_LOG(_T("context"), Level, _T(" OpenGL Version: %s"), version.GetChars()); NGL_LOG(_T("context"), Level, _T(" Renderer : %s"), renderer.GetChars()); NGL_LOG(_T("context"), Level, _T(" Vendor : %s"), vendor.GetChars()); #if (!defined _UIKIT_) && (!defined _ANDROID_) NGL_LOG(_T("context"), Level, _T(" GLSL version : %s"), sl.GetChars()); #endif NGL_LOG(_T("context"), Level, _T(" Extensions :")); std::vector<nglString> tokens; exts.Tokenize(tokens); for (int32 i = 0; i < tokens.size(); i++) { NGL_LOG(_T("context"), Level, _T(" %3d %s"), i, tokens[i].GetChars()); } }
string HardwareDevice::display_name( const DeviceManager &device_manager) const { const auto hw_dev = hardware_device(); // If we can find another device with the same model/vendor then // we have at least two such devices and need to distinguish them. const auto &devices = device_manager.devices(); const bool multiple_dev = hw_dev && any_of( devices.begin(), devices.end(), [&](shared_ptr<devices::HardwareDevice> dev) { return dev->hardware_device()->vendor() == hw_dev->vendor() && dev->hardware_device()->model() == hw_dev->model() && dev->device_ != device_; }); vector<string> parts = {device_->vendor(), device_->model()}; if (multiple_dev) { parts.push_back(device_->version()); parts.push_back(device_->serial_number()); if ((device_->serial_number().length() == 0) && (device_->connection_id().length() > 0)) parts.push_back("(" + device_->connection_id() + ")"); } return join(parts, " "); }
USBDB::USBDB() { QString db = "/usr/share/hwdata/usb.ids"; /* on Fedora */ if (!QFile::exists(db)) db = KStandardDirs::locate("data", "kcmusb/usb.ids"); if (db.isEmpty()) return; QFile f(db); if (f.open(QIODevice::ReadOnly)) { QTextStream ts(&f); ts.setCodec("UTF-8"); QString line, name; int id=0, subid=0, protid=0; QRegExp vendor("[0-9a-fA-F]+ "); QRegExp product("\\s+[0-9a-fA-F]+ "); QRegExp cls("C [0-9a-fA-F][0-9a-fA-F]"); QRegExp subclass("\\s+[0-9a-fA-F][0-9a-fA-F] "); QRegExp prot("\\s+[0-9a-fA-F][0-9a-fA-F] "); while (!ts.atEnd()) { line = ts.readLine(); if (line.left(1) == "#" || line.trimmed().isEmpty()) continue; // skip AT lines if (line.left(2) == "AT") continue; if (cls.indexIn(line) == 0 && cls.matchedLength() == 4) { id = line.mid(2,2).toInt(0, 16); name = line.mid(4).trimmed(); _classes.insert(QString("%1").arg(id), name); } else if (prot.indexIn(line) == 0 && prot.matchedLength() > 5) { line = line.trimmed(); protid = line.left(2).toInt(0, 16); name = line.mid(4).trimmed(); _classes.insert(QString("%1-%2-%3").arg(id).arg(subid).arg(protid), name); } else if (subclass.indexIn(line) == 0 && subclass.matchedLength() > 4) { line = line.trimmed(); subid = line.left(2).toInt(0, 16); name = line.mid(4).trimmed(); _classes.insert(QString("%1-%2").arg(id).arg(subid), name); } else if (vendor.indexIn(line) == 0 && vendor.matchedLength() == 5) { id = line.left(4).toInt(0, 16); name = line.mid(6); _ids.insert(QString("%1").arg(id), name); } else if (product.indexIn(line) == 0 && product.matchedLength() > 5) { line = line.trimmed(); subid = line.left(4).toInt(0, 16); name = line.mid(6); _ids.insert(QString("%1-%2").arg(id).arg(subid), name); } } f.close(); } }
/*! Returns the list of \l{Vendor}{Vendors} supported by this DevicePlugin. */ QList<Vendor> DevicePlugin::supportedVendors() const { QList<Vendor> vendors; foreach (const QJsonValue &vendorJson, m_metaData.value("vendors").toArray()) { Vendor vendor(vendorJson.toObject().value("id").toString(), vendorJson.toObject().value("name").toString()); vendors.append(vendor); } return vendors; }
/** Initialise GPGPU engine. */ void GLEngine::initialise() { /// Initialize GL extension wrangler mDisplay = glXGetCurrentDisplay(); if(mDisplay == 0) { /// If there is none, create one mDisplay = XOpenDisplay(NULL); if(!mDisplay) GPGPU_EXCEPT(ERR_RENDERSYSTEM, "Could not open X display"); } mPBuffers.resize(PT_COUNT); /// Initialize PBuffer for BYTE format getPBuffer(PT_BYTE, 256, 256)->makeCurrent(); /// Initialize GL here (load extensions etc) glewInit(); /// Get card model std::string vendor(reinterpret_cast<const char*>(glGetString(GL_VENDOR))); std::string renderer(reinterpret_cast<const char*>(glGetString(GL_RENDERER))); mHWInfo.model = vendor + " " + renderer; /// Get number of texture units GLint maxTextureUnits; glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &maxTextureUnits); mMaxTextureUnits = (size_t)maxTextureUnits; if(mMaxTextureUnits > GPGPU_TEXUNITS) mMaxTextureUnits = GPGPU_TEXUNITS; mHWInfo.textureUnits = mMaxTextureUnits; // Check for NV or ATI float textures if(GLEW_ATI_texture_float) { mFloatTexType = FTT_ATI; mHWInfo.mFloatTextures = true; mHWInfo.mFullFloatTextures = true; } else if(GLEW_NV_float_buffer) { mFloatTexType = FTT_NV; mHWInfo.mFloatTextures = true; mHWInfo.mFullFloatTextures = false; } /// Register program factories mProgramFactories["Cg"] = ProgramFactoryPtr(new CgProgramFactory()); if(GLEW_ARB_shader_objects) mProgramFactories["GLSL"] = ProgramFactoryPtr(new GLSLProgramFactory()); // Initialize program managers for(ProgramFactoryMap::iterator i=mProgramFactories.begin(); i!=mProgramFactories.end(); ++i) { mHWInfo.languages.push_back(i->first); i->second->initialise(mHWInfo); } }
int KisOpenGL::initializeContext(QOpenGLContext* s) { #ifdef HAVE_OPENGL KisConfig cfg; dbgUI << "OpenGL: Opening new context"; // Double check we were given the version we requested QSurfaceFormat format = s->format(); glVersion = 100 * format.majorVersion() + format.minorVersion(); if (!SharedSurface) { SharedSurface = new QOffscreenSurface(); SharedSurface->setFormat(format); SharedSurface->create(); } if (!SharedContext) { SharedContext = new QOpenGLContext; SharedContext->setFormat(format); SharedContext->setShareContext(s); SharedContext->create(); SharedContext->makeCurrent(SharedSurface); } QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); QFile log(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/krita-opengl.txt"); log.open(QFile::WriteOnly); QString vendor((const char*)f->glGetString(GL_VENDOR)); log.write(vendor.toLatin1()); log.write(", "); QString renderer((const char*)f->glGetString(GL_RENDERER)); log.write(renderer.toLatin1()); log.write(", "); QString version((const char*)f->glGetString(GL_VERSION)); log.write(version.toLatin1()); // Check if we have a bugged driver that needs fence workaround bool isOnX11 = false; #ifdef HAVE_X11 isOnX11 = true; #endif if ((isOnX11 && renderer.startsWith("AMD")) || cfg.forceOpenGLFenceWorkaround()) { NeedsFenceWorkaround = true; } #else Q_UNUSED(s); NeedsFenceWorkaround = false; #endif return glVersion; }
QString EnttecDMXUSBProRX::additionalInfo() const { QString info; info += QString("<P>"); info += QString("<B>%1:</B> %2 (%3)").arg(QObject::tr("Protocol")) .arg("DMX USB Pro Rx") .arg(QObject::tr("Input")); info += QString("<BR>"); info += QString("<B>%1:</B> %2").arg(QObject::tr("Manufacturer")) .arg(vendor()); info += QString("<BR>"); info += QString("<B>%1:</B> %2").arg(QObject::tr("Serial number")) .arg(serial()); info += QString("</P>"); return info; }
std::vector<DebugInfo::InfoGroup> DebugInfo::generalInfo() { InfoGroup generalGroup; InfoUnit generalInfo; InfoUnit memoryInfo; InfoUnit textureInfo; generalGroup.name = "General"; generalInfo.name = "OpenGL"; memoryInfo.name = "Memory"; textureInfo.name = "General Texture Info"; generalInfo.addProperty("version", versionString()); generalInfo.addProperty("vendor", vendor()); generalInfo.addProperty("renderer", renderer()); generalInfo.addProperty("core profile", isCoreProfile()?"true":"false"); generalInfo.addProperty("GLSL version", getString(gl::GL_SHADING_LANGUAGE_VERSION)); memoryInfo.addProperty("total", humanReadableSize(1024ll*memory::total())); memoryInfo.addProperty("dedicated", humanReadableSize(1024ll*memory::dedicated())); memoryInfo.addProperty("available", humanReadableSize(1024ll*memory::available())); memoryInfo.addProperty("evicted", humanReadableSize(1024ll*memory::evicted())); memoryInfo.addProperty("evictionCount", memory::evictionCount()); int maxTextureSize = getInteger(gl::GL_MAX_TEXTURE_SIZE); textureInfo.addProperty("Max Texture Size", std::to_string(maxTextureSize)+" x "+std::to_string(maxTextureSize)); textureInfo.addProperty("Max Vertex Texture Image Units", getInteger(gl::GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS)); textureInfo.addProperty("Max Texture Image Units", getInteger(gl::GL_MAX_IMAGE_UNITS)); textureInfo.addProperty("Max Geometry Texture Units", getInteger(gl::GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS)); auto maxViewportSize = getIntegers<2>(gl::GL_MAX_VIEWPORT_DIMS); textureInfo.addProperty("Max viewport size", std::to_string(maxViewportSize[0])+" x "+std::to_string(maxViewportSize[1])); textureInfo.addProperty("Max clip distances", getInteger(gl::GL_MAX_CLIP_DISTANCES)); textureInfo.addProperty("Max Samples", getInteger(gl::GL_MAX_SAMPLES)); generalGroup.addInfoUnit(generalInfo); generalGroup.addInfoUnit(memoryInfo); generalGroup.addInfoUnit(textureInfo); return std::vector<InfoGroup>({ generalGroup }); }
void KisOpenGL::initializeContext(QOpenGLContext *ctx) { initialize(); dbgUI << "OpenGL: Opening new context"; // Double check we were given the version we requested QSurfaceFormat format = ctx->format(); QOpenGLFunctions *f = ctx->functions(); f->initializeOpenGLFunctions(); #ifndef GL_RENDERER # define GL_RENDERER 0x1F01 #endif Renderer = QString((const char*)f->glGetString(GL_RENDERER)); QFile log(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/krita-opengl.txt"); log.open(QFile::WriteOnly); QString vendor((const char*)f->glGetString(GL_VENDOR)); log.write(vendor.toLatin1()); log.write(", "); log.write(Renderer.toLatin1()); log.write(", "); QString version((const char*)f->glGetString(GL_VERSION)); log.write(version.toLatin1()); log.close(); // Check if we have a bugged driver that needs fence workaround bool isOnX11 = false; #ifdef HAVE_X11 isOnX11 = true; #endif KisConfig cfg; if ((isOnX11 && Renderer.startsWith("AMD")) || cfg.forceOpenGLFenceWorkaround()) { NeedsFenceWorkaround = true; } }
USBDB::USBDB() { #ifndef USBIDS_FILE QString db = "/usr/share/hwdata/usb.ids"; /* on Fedora */ if (!QFile::exists(db)) db = locate("data", "kcmusb/usb.ids"); #else QString db = USBIDS_FILE; #endif if (db.isEmpty()) return; _classes.setAutoDelete(true); _ids.setAutoDelete(true); QFile f(db); if (f.open(IO_ReadOnly)) { QTextStream ts(&f); QString line, name; int id=0, subid=0, protid=0; QRegExp vendor("[0-9a-fA-F]+ "); QRegExp product("\\s+[0-9a-fA-F]+ "); QRegExp cls("C [0-9a-fA-F][0-9a-fA-F]"); QRegExp subclass("\\s+[0-9a-fA-F][0-9a-fA-F] "); QRegExp prot("\\s+[0-9a-fA-F][0-9a-fA-F] "); while (!ts.eof()) { line = ts.readLine(); if (line.left(1) == "#" || line.stripWhiteSpace().isEmpty()) continue; // skip AT lines if (line.left(2) == "AT") continue; if (cls.search(line) == 0 && cls.matchedLength() == 4) { id = line.mid(2,2).toInt(0, 16); name = line.mid(4).stripWhiteSpace(); _classes.insert(QString("%1").arg(id), new QString(name)); } else if (prot.search(line) == 0 && prot.matchedLength() > 5) { line = line.stripWhiteSpace(); protid = line.left(2).toInt(0, 16); name = line.mid(4).stripWhiteSpace(); _classes.insert(QString("%1-%2-%3").arg(id).arg(subid).arg(protid), new QString(name)); } else if (subclass.search(line) == 0 && subclass.matchedLength() > 4) { line = line.stripWhiteSpace(); subid = line.left(2).toInt(0, 16); name = line.mid(4).stripWhiteSpace(); _classes.insert(QString("%1-%2").arg(id).arg(subid), new QString(name)); } else if (vendor.search(line) == 0 && vendor.matchedLength() == 5) { id = line.left(4).toInt(0,16); name = line.mid(6); _ids.insert(QString("%1").arg(id), new QString(name)); } else if (product.search(line) == 0 && product.matchedLength() > 5 ) { line = line.stripWhiteSpace(); subid = line.left(4).toInt(0,16); name = line.mid(6); _ids.insert(QString("%1-%2").arg(id).arg(subid), new QString(name)); } } f.close(); } }
QString KSaneWidget::make() const { return vendor(); }
void Connection::init() { connect(m_socket, SIGNAL(disconnected()), m_socket, SLOT(deleteLater())); connect(m_socket, SIGNAL(disconnected()), this, SLOT(emitDisconnected())); connect(m_socket, SIGNAL(readyRead()), this, SLOT(onReadyRead())); //const int timeout = 3 * 1000; quint16 s; readByteOrder(); readByte(); // Unused. s = readShort(); // Protocol major version. qDebug() << "Protocol major version: " << s; s = readShort(); // Protocol minor version. qDebug() << "Protocol minor version: " << s; int nameLength = readShort(); int dataLength = readShort(); readShort(); // Unused. if (nameLength > 0) { readOmit(nameLength); // Authorization protocol name. readOmit(-nameLength & 3); // Padding. } if (dataLength > 0) { readOmit(dataLength); // Authorization protocol data. readOmit(-dataLength & 3); // Padding. } QByteArray vendor(Server::m_vendor.toLatin1()); int pad = -1 * vendor.length() & 3; int extra = 26 + 2 * m_server->numberOfPixmapFormats() + (vendor.length() + pad) / 4; Keyboard *keyboard = m_server->keyboard(); writeByte(1); // Success. writeByte(0); // Unused. writeShort(Server::m_protocol_major_version); writeShort(Server::m_protocol_minor_version); writeShort(extra); // Length of data. writeInt(Server::m_release_number); // Release number. writeInt(m_resource_id_base); writeInt(m_resource_id_mask); writeInt(0); // Motion buffer size. writeShort(vendor.length()); // Vendor length. writeShort(0xffff); // Max request length. writeByte(1); // Number of screens. writeByte(m_server->numberOfPixmapFormats()); writeByte(0); // Image byte order (0=LSB, 1=MSB). writeByte(1); // Bitmap bit order (0=LSB, 1=MSB). writeByte(8); // Bitmap format scanline unit. writeByte(8); // Bitmap format scanline pad. writeByte(keyboard->minimumKeycode()); writeByte(keyboard->maximumKeycode()); writePaddingBytes(4); // Unused. if (vendor.length() > 0) { // Write padded vendor string. writeBytes(vendor); writePaddingBytes(pad); } m_server->writeFormats(this); //m_server->getScreen().write(_inputOutput); flush(); }
// get network interface info from file (should include all available interfaces) std::vector<std::map<std::string,std::string> > Responder::read_eth_info() { const std::string eth_file(_eth_file); std::vector<std::map<std::string,std::string> > eths; try { ifstream eth_info(eth_file.c_str()); if(!eth_info.is_open()){ return eths; } const int len = 256; char cline[len]; for(; !eth_info.eof() ;) { eth_info.getline(cline, len); std::string line(cline); if(line.find("## ETH Interface") != std::string::npos) { eth_info.getline(cline, len); std::string eth(cline); // cout << "interface=" << eth << endl; std::map<std::string,std::string> iface; iface["interface"] = eth; eths.push_back(iface); } const std::string ipstr("\tip "); if(line.find(ipstr) != std::string::npos) { std::string ip( line.replace(line.begin(), line.begin()+ipstr.length(), "") ); // cout << "ip=" << ip << endl; eths.back()["addr"] = ip; } const std::string macstr("\tmac "); if(line.find(macstr) != std::string::npos) { std::string mac( line.replace(line.begin(), line.begin()+macstr.length(), "") ); // cout << "mac=" << mac << endl; eths.back()["mac"] = mac; } const std::string vstr("\t\tvendor "); if(line.find(vstr) != std::string::npos) { std::string vendor( line.replace(line.begin(), line.begin()+vstr.length(), "") ); std::string vid( vendor.substr(0,6) ); vendor.replace(0, 7, ""); // cout << "id=" << vid << endl; // cout << "vendor=" << vendor << endl; eths.back()["vendor"] = vendor; eths.back()["vendor_id"] = vid; } const std::string dstr("\t\tdevice "); if(line.find(dstr) != std::string::npos) { std::string device( line.replace(line.begin(), line.begin()+dstr.length(), "") ); std::string did( device.substr(0,6) ); device.replace(0, 7, ""); // cout << "id=" << did << endl; // cout << "device=" << device << endl; eths.back()["device"] = device; eths.back()["device_id"] = did; } } } catch(...) { // nothing in yet } return eths; }
/** \brief Parse an architecture string and defines the triplet accordingly. * * This function parses the \p arch parameter in an architecture triplet. * If the architecture information is invalid, then the function returns * false and this architecture object is not modified. * * The input is an architecture triplet where the \<vendor> part is optional. * Also the system understands a certain number of architectures that are * one word abbreviations such as "linux" which means "linux-i386", and * "win64" which means "win64-amd64". * * The list of operating systems and processors supported can be listed * using the os_list() and the processor_list() functions. * * When a vendor is specified, the operating system and the processor must * also be present or the function returns false (error.) * * You may set the architecture to the empty architecture by using the * empty string as the \p arch parameter. * * \param[in] arch The architecture triplet defined as: \<os>-\<vendor>-\<processor>. * * \return true if the \p arch parameter was a valid architecture string. */ bool architecture::set(const std::string& arch) { // the empty architecture if(arch.empty()) { f_os = ""; f_vendor = ""; f_processor = ""; return true; } // valid on any architecture (but not a pattern) if(arch == "all") { f_os = "all"; f_vendor = "all"; f_processor = "all"; return true; } // special case of a source package if(arch == "src" || arch == "source") { f_os = "all"; f_vendor = "all"; f_processor = "source"; return true; } // any triplet if(arch == "any") { f_os = "any"; f_vendor = "any"; f_processor = "any"; return true; } std::string os; std::string vendor(UNKNOWN_VENDOR); std::string processor; const std::string::size_type p(arch.find_first_of('-')); if(p == std::string::npos) { // <abbreviation> const abbreviation_t *abbr(find_abbreviation(arch)); if(abbr == NULL) { // unknown abbreviation return false; } os = abbr->f_os; processor = abbr->f_processor; } else { // an architecture name cannot start with a '-' if(p == 0) { // same as testing 'os.empty()' return false; } os = arch.substr(0, p); const std::string::size_type q(arch.find_first_of('-', p + 1)); if(q == std::string::npos) { // <os>-<processor> processor = arch.substr(p + 1); if(processor.empty()) { return false; } } else { // <os>-<vendor>-<processor> vendor = arch.substr(p + 1, q - p - 1); processor = arch.substr(q + 1); // should we allow for an empty vendor? if(vendor.empty() || processor.empty()) { return false; } if(!valid_vendor(vendor)) { return false; } } } // here we have a semi-valid triplet in os, vendor, and processor // variables now we want to verify that these are valid (supported) // architecture parameters as found in our lists and as we are at // it we canonicalize const os_t *co(find_os(os)); const processor_t *cp(find_processor(processor, true)); if(co == NULL || cp == NULL) { return false; } f_os = co->f_name; f_vendor = vendor; f_processor = cp->f_name; return true; }
QList<DMXInterface *> LibFTDIInterface::interfaces(QList<DMXInterface *> discoveredList) { QList <DMXInterface*> interfacesList; int id = 0; struct ftdi_context ftdi; ftdi_init(&ftdi); #ifdef LIBFTDI1 libusb_device *dev; libusb_device **devs; struct libusb_device_descriptor dev_descriptor; int i = 0; if (libusb_get_device_list(ftdi.usb_ctx, &devs) < 0) { qDebug() << "usb_find_devices() failed"; return interfacesList; } while ((dev = devs[i++]) != NULL) { libusb_get_device_descriptor(dev, &dev_descriptor); #else struct usb_bus *bus; struct usb_device *dev; struct usb_device_descriptor dev_descriptor; usb_init(); if (usb_find_busses() < 0) { qDebug() << "usb_find_busses() failed"; return interfacesList; } if (usb_find_devices() < 0) { qDebug() << "usb_find_devices() failed"; return interfacesList; } for (bus = usb_get_busses(); bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { dev_descriptor = dev->descriptor; #endif Q_ASSERT(dev != NULL); // Skip non wanted devices if (validInterface(dev_descriptor.idVendor, dev_descriptor.idProduct) == false) continue; char ser[256]; memset(ser, 0, 256); char nme[256]; char vend[256]; ftdi_usb_get_strings(&ftdi, dev, vend, 256, nme, 256, ser, 256); QString serial(ser); QString name(nme); QString vendor(vend); qDebug() << Q_FUNC_INFO << "DMX USB VID:" << QString::number(dev_descriptor.idVendor, 16) << "PID:" << QString::number(dev_descriptor.idProduct, 16); qDebug() << Q_FUNC_INFO << "DMX USB serial: " << serial << "name:" << name << "vendor:" << vendor; bool found = false; for (int c = 0; c < discoveredList.count(); c++) { if (discoveredList.at(c)->checkInfo(serial, name, vendor) == true) { found = true; break; } } if (found == false) { LibFTDIInterface *iface = new LibFTDIInterface(serial, name, vendor, dev_descriptor.idVendor, dev_descriptor.idProduct, id++); #ifdef LIBFTDI1 iface->setBusLocation(libusb_get_port_number(dev)); #else iface->setBusLocation(dev->bus->location); #endif interfacesList << iface; } #ifndef LIBFTDI1 } #endif } #ifdef LIBFTDI1 libusb_free_device_list(devs, 1); #endif ftdi_deinit(&ftdi); return interfacesList; } bool LibFTDIInterface::open() { if (isOpen() == true) return true; QByteArray sba = serial().toLatin1(); const char *ser = NULL; if (serial().isEmpty() == false) ser = (const char *)sba.data(); if (ftdi_usb_open_desc(&m_handle, vendorID(), productID(), name().toLatin1(), ser) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::openByPID(const int PID) { if (isOpen() == true) return true; if (ftdi_usb_open(&m_handle, DMXInterface::FTDIVID, PID) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::close() { if (ftdi_usb_close(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::isOpen() const { return (m_handle.usb_dev != NULL) ? true : false; } bool LibFTDIInterface::reset() { if (ftdi_usb_reset(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::setLineProperties() { if (ftdi_set_line_property(&m_handle, BITS_8, STOP_BIT_2, NONE) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::setBaudRate() { if (ftdi_set_baudrate(&m_handle, 250000) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::setFlowControl() { if (ftdi_setflowctrl(&m_handle, SIO_DISABLE_FLOW_CTRL) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::clearRts() { if (ftdi_setrts(&m_handle, 0) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::purgeBuffers() { if (ftdi_usb_purge_buffers(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool LibFTDIInterface::setBreak(bool on) { ftdi_break_type type; if (on == true) type = BREAK_ON; else type = BREAK_OFF; if (ftdi_set_line_property2(&m_handle, BITS_8, STOP_BIT_2, NONE, type) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } }
void DownloadFromDCWidget::on_downloadCancelRetryButton_clicked() { if (currentState == DOWNLOADING) { updateState(CANCELLING); return; } if (currentState == DONE) { // this means we are retrying - so we better clean out the partial // list of downloaded dives from the last attempt diveImportedModel->clearTable(); clear_table(&downloadTable); } updateState(DOWNLOADING); // you cannot cancel the dialog, just the download ui.cancel->setEnabled(false); ui.downloadCancelRetryButton->setText(tr("Cancel download")); auto data = thread.data(); data->setVendor(ui.vendor->currentText()); data->setProduct(ui.product->currentText()); #if defined(BT_SUPPORT) data->setBluetoothMode(ui.bluetoothMode->isChecked()); if (data->bluetoothMode()) { // Get the selected device address from dialog or from preferences if (btDeviceSelectionDialog != NULL) { data->setDevName(btDeviceSelectionDialog->getSelectedDeviceAddress()); data->setDevBluetoothName(btDeviceSelectionDialog->getSelectedDeviceName()); } else { data->setDevName(qPrefDiveComputer::device()); data->setDevBluetoothName(qPrefDiveComputer::device_name()); } } else // this breaks an "else if" across lines... not happy... #endif if (data->vendor() == "Uemis") { char *colon; char *devname = copy_qstring(ui.device->currentText()); if ((colon = strstr(devname, ":\\ (UEMISSDA)")) != NULL) { *(colon + 2) = '\0'; fprintf(stderr, "shortened devname to \"%s\"", devname); } data->setDevName(devname); } else { data->setDevName(ui.device->currentText()); } data->setForceDownload(ui.forceDownload->isChecked()); data->setCreateNewTrip(ui.createNewTrip->isChecked()); data->setSaveLog(ui.logToFile->isChecked()); data->setSaveDump(ui.dumpToFile->isChecked()); qPrefDiveComputer::set_vendor(data->vendor()); qPrefDiveComputer::set_product(data->product()); qPrefDiveComputer::set_device(data->devName()); #if defined(BT_SUPPORT) qPrefDiveComputer::set_download_mode(ui.bluetoothMode->isChecked() ? DC_TRANSPORT_BLUETOOTH : DC_TRANSPORT_SERIAL); #endif // before we start, remember where the dive_table ended previousLast = dive_table.nr; thread.start(); // FIXME: We should get the _actual_ device info instead of whatever // the user entered in the dropdown. // You can enter "OSTC 3" and download just fine from a "OSTC Sport", but // this check will compair apples and oranges, firmware wise, then. QString product(ui.product->currentText()); // // We shouldn't do this for memory dumps. if ((product == "OSTC 3" || product == "OSTC 3+" || product == "OSTC cR" || product == "OSTC Sport" || product == "OSTC 4" || product == "OSTC Plus") && !data->saveDump()) { ostcFirmwareCheck = new OstcFirmwareCheck(product); } }
int main(int, const char**) { auto platforms = cl::Platform::getPlatforms(); std::cout << "Count platforms: " << platforms.size() << "\n"; auto platform = platforms[0]; std::cout << "Platform ...\n" << "\tProfile: " << platform.profile() << "\n" << "\tName: " << platform.name() << "\n" << "\tVendor: " << platform.vendor() << "\n" << "\tVersion: " << platform.version() << "\n" << "\tExtensions: \n"; for (auto&& ext : platform.getExtensions()) { std::cout << "\t\t" << ext << '\n'; } auto devices = platform.getDevices(cl::DeviceType::all); std::cout << "Count devices: " << devices.size() << '\n'; auto device = devices[0]; std::cout << "Devices ...\n" << "\tName: " << device.name() << '\n' << "\tAvailable: " << device.available() << '\n' << "\tCompiler available: " << device.compilerAvailable() << '\n' << "\tAddress bits: " << device.addressBits() << '\n' << "\tAvailable: " << ((device.available()) ? "true" : "false") << '\n'; for (auto&& size : device.maxWorkItemSizes()) { std::cout << "\t\t" << size << "\n"; } auto usr_data = int{5}; auto properties = cl::ContextProperties().setPlatform(platform); //auto context_id = cl::Context(properties, devices); auto context = cl::Context( properties, devices, [](std::string const& error_info, std::vector<uint8_t> const& private_info, int user_data) { std::cout << "error_info: " << error_info << '\n' << "private_info: " << '\n'; for (auto&& t : private_info) std::cout << '\t' << t << '\n'; std::cout << "user_data: " << user_data << '\n'; }, usr_data ); std::cout << "Context created successfully!\n"; std::ignore = context; //std::cout << "Context information ...\n"; //std::cout << "\tReference Count = " << context.referenceCount() << '\n'; /* //auto usr_data = int{5}; std::cout << "Properties:\n"; for (auto&& p : properties.get()) { std::cout << p << '\n'; } std::cout << "CL_CONTEXT_PLATFORM = " << CL_CONTEXT_PLATFORM << '\n'; std::cout << "static_cast<size_t>(platform) = " << ((size_t)(platform.id())) << '\n'; */ /* auto context = cl::Context( properties, devices, [](std::string const& error_info, std::vector<uint8_t> const& private_info, int user_data) { std::cout << "error_info: " << error_info << '\n' << "private_info: " << '\n'; for (auto&& t : private_info) std::cout << '\t' << t << '\n'; std::cout << "user_data: " << user_data << '\n'; }, usr_data ); */ //auto context = cl::Context(properties, devices); /* try { auto error = cl_int{CL_SUCCESS}; auto context_id = clCreateContext( properties.get().data(), devices.size(), reinterpret_cast<const cl_device_id*>(devices.data()), nullptr, nullptr, & error ); cl::error::handle<cl::Exception>(error); std::ignore = context_id; } catch (cl::Exception const& e) { std::cout << "cl::Exception caught!\n" << "\twhat() = " << e.what() << "\n\tcode() = " << static_cast<std::underlying_type<cl::ErrorCode>::type>(e.code()) << '\n'; } */ //auto tmp = context; //std::ignore = tmp; //std::ignore = context_id; return 0; }
static const char *const digital[] = { 0, "DC21040", "DC21140", "DC21041", "DC21140A", "DC21142" }; static const char *const westerndigital[] = { 0, "83C690", "83C790" }; #define vendor(name, sets) { name, sets, (sizeof sets)/(sizeof sets[0]) } static struct { const char *name; const char *const *chips; size_t len; } chipset_names[] = { { 0 }, vendor("AMD", amd), vendor("Intel", intel), { 0 }, vendor("National Semiconductor", national), vendor("Fujitsu", fujitsu), vendor("Digital", digital), vendor("Western Digital", westerndigital) }; static void identify_chipset(u_int32_t chipset) { enum dot3Vendors vendor = DOT3CHIPSET_VENDOR(chipset); u_int part = DOT3CHIPSET_PART(chipset); printf("\tChipset: ");
djvWglContext::djvWglContext(djvCoreContext * context) throw (djvError) : djvOpenGlContext(context), _p(new djvWglContextPrivate) { # if defined(DJV_WINDOWS) //DJV_DEBUG("djvWglContext::djvWglContext"); // Create a dummy window and OpenGL context for glewInit. // According to the docs, glewInit can be called just once per-process? DJV_LOG(context->debugLog(), "djvWglContext", "Creating dummy window..."); HINSTANCE hinstance = GetModuleHandle(0); if (! hinstance) { throw djvError( "djvWglContext", errorLabels()[ERROR_MODULE_HANDLE].arg(int(GetLastError()))); } static const char name [] = "djv"; WNDCLASS wc; if (! GetClassInfo(hinstance, name, &wc)) { wc.style = CS_OWNDC; //wc.lpfnWndProc = (WNDPROC)MainWndProc; wc.lpfnWndProc = DefWindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = hinstance; wc.hIcon = LoadIcon(0, IDI_APPLICATION); wc.hCursor = LoadCursor(0, IDC_ARROW); wc.hbrBackground = 0; wc.lpszMenuName = 0; wc.lpszClassName = name; if (! RegisterClass(&wc)) { throw djvError( "djvWglContext", errorLabels()[ERROR_REGISTER_CLASS].arg(int(GetLastError()))); } } _p->id = CreateWindow(name, 0, 0, 0, 0, 0, 0, 0, 0, hinstance, 0); if (! _p->id) { throw djvError( "djvWglContext", errorLabels()[ERROR_CREATE_WINDOW].arg(int(GetLastError()))); } _p->device = GetDC(_p->id); if (! _p->device) { throw djvError( "djvWglContext", errorLabels()[ERROR_GET_DC].arg(int(GetLastError()))); } PIXELFORMATDESCRIPTOR pixelFormatInfo; const int pixelFormatCount = DescribePixelFormat(_p->device, 0, 0, 0); //DJV_DEBUG_PRINT("pixel format count = " << pixelFormatCount); DJV_LOG(context->debugLog(), "djvWglContext", QString("Pixel format count: %1").arg(pixelFormatCount)); for (int i = 1; i < pixelFormatCount; ++i) { DescribePixelFormat( _p->device, i, sizeof(PIXELFORMATDESCRIPTOR), &pixelFormatInfo); //DJV_DEBUG_PRINT(" id " << i << ": " << // ((PFD_SUPPORT_OPENGL & pixelFormatInfo.dwFlags) ? "gl " : "") << // ((PFD_GENERIC_FORMAT & pixelFormatInfo.dwFlags) ? "" : "accel ") << // ((PFD_TYPE_RGBA == pixelFormatInfo.iPixelType) ? "rgba " : "") << // "depth = " << pixelFormatInfo.cColorBits << "/" << // pixelFormatInfo.cRedBits << "/" << // pixelFormatInfo.cGreenBits << "/" << // pixelFormatInfo.cBlueBits << "/" << // pixelFormatInfo.cAlphaBits << " "); QStringList tmp; if (PFD_SUPPORT_OPENGL & pixelFormatInfo.dwFlags) tmp += "gl"; if (! (PFD_GENERIC_FORMAT & pixelFormatInfo.dwFlags)) tmp += "accel"; if (PFD_TYPE_RGBA == pixelFormatInfo.iPixelType) tmp += "rgba"; DJV_LOG(context->debugLog(), "djvWglContext", QString("Pixel format %1: %2 %3/%4/%5/%6/%7"). arg(i). arg(tmp.join(" ")). arg(pixelFormatInfo.cColorBits). arg(pixelFormatInfo.cRedBits). arg(pixelFormatInfo.cGreenBits). arg(pixelFormatInfo.cBlueBits). arg(pixelFormatInfo.cAlphaBits)); } PIXELFORMATDESCRIPTOR pixelFormat = { sizeof(PIXELFORMATDESCRIPTOR), 1, PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL, PFD_TYPE_RGBA, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, PFD_MAIN_PLANE, 0, 0, 0, 0 }; int pixelFormatId = ChoosePixelFormat(_p->device, &pixelFormat); //DJV_DEBUG_PRINT("pixel format = " << pixelFormatId); DJV_LOG(context->debugLog(), "djvWglContext", QString("Chosen pixel format: %1").arg(pixelFormatId)); if (! pixelFormatId) { throw djvError( "djvWglContext", errorLabels()[ERROR_GET_PIXEL_FORMAT].arg(int(GetLastError()))); } if (! SetPixelFormat(_p->device, pixelFormatId, &pixelFormat)) { throw djvError( "djvWglContext", errorLabels()[ERROR_SET_PIXEL_FORMAT].arg(int(GetLastError()))); } // Create OpengGL context. DJV_LOG(context->debugLog(), "djvWglContext", "Creating OpenGL context..."); _p->context = wglCreateContext(_p->device); if (! _p->context) { throw djvError( "djvWglContext", errorLabels()[ERROR_CREATE_CONTEXT].arg(int(GetLastError()))); } if (! wglMakeCurrent(_p->device, _p->context)) { throw djvError( "djvWglContext", errorLabels()[ERROR_BIND_CONTEXT].arg(int(GetLastError()))); } // Initialize GLEW. DJV_LOG(context->debugLog(), "djvWglContext", "Initializing GLEW..."); GLenum err = glewInit(); if (err != GLEW_OK) { throw djvError( "djvWglContext", errorLabels()[ERROR_INIT_GLEW].arg((char *)glewGetErrorString(err))); } setVendor(QString((const char *)glGetString(GL_VENDOR))); setRenderer(QString((const char *)glGetString(GL_RENDERER))); setVersion(QString((const char *)glGetString(GL_VERSION))); //DJV_DEBUG_PRINT("OpenGL vendor string = " << vendor()); //DJV_DEBUG_PRINT("OpenGL renderer string = " << renderer()); //DJV_DEBUG_PRINT("OpenGL version string = " << version()); //DJV_DEBUG_PRINT("OpenGL extensions = " << // (const char *)glGetString(GL_EXTENSIONS)); //DJV_DEBUG_PRINT("glu version = " << // (const char *)gluGetString(GLU_VERSION)); //DJV_DEBUG_PRINT("glu extensions = " << // (const char *)gluGetString(GLU_EXTENSIONS)); DJV_LOG(context->debugLog(), "djvWglContext", QString("GL vendor: \"%1\"").arg(vendor())); DJV_LOG(context->debugLog(), "djvWglContext", QString("GL renderer: \"%1\"").arg(renderer())); DJV_LOG(context->debugLog(), "djvWglContext", QString("GL version: \"%1\"").arg(version())); # endif // DJV_WINDOWS }
QList <DMXUSBWidget*> QLCFTDI::widgets() { QList <DMXUSBWidget*> widgetList; quint32 input_id = 0; struct ftdi_context ftdi; ftdi_init(&ftdi); #ifdef LIBFTDI1 libusb_device *dev; libusb_device **devs; int i = 0; if (libusb_get_device_list(ftdi->usb_ctx, &devs) < 0) { qDebug() << "usb_find_devices() failed"; ftdi_error_return(-5, "libusb_get_device_list() failed"); } while ((dev = devs[i++]) != NULL) { #else struct usb_bus *bus; struct usb_device *dev; usb_init(); if (usb_find_busses() < 0) { qDebug() << "usb_find_busses() failed"; return widgetList; } if (usb_find_devices() < 0) { qDebug() << "usb_find_devices() failed"; return widgetList; } for (bus = usb_get_busses(); bus; bus = bus->next) { for (dev = bus->devices; dev; dev = dev->next) { #endif Q_ASSERT(dev != NULL); // Skip non wanted devices if (dev->descriptor.idVendor != QLCFTDI::FTDIVID && dev->descriptor.idVendor != QLCFTDI::ATMELVID) continue; if (dev->descriptor.idProduct != QLCFTDI::FTDIPID && dev->descriptor.idProduct != QLCFTDI::DMX4ALLPID && dev->descriptor.idProduct != QLCFTDI::NANODMXPID) continue; char ser[256]; char nme[256]; char vend[256]; ftdi_usb_get_strings(&ftdi, dev, vend, 256, nme, 256, ser, 256); QString serial(ser); QString name(nme); QString vendor(vend); QMap <QString,QVariant> types(typeMap()); qDebug() << Q_FUNC_INFO << "DMX USB VID:" << QString::number(dev->descriptor.idVendor, 16) << "PID:" << QString::number(dev->descriptor.idProduct, 16); qDebug() << Q_FUNC_INFO << "DMX USB serial: " << serial << "name:" << name << "vendor:" << vendor; if (types.contains(serial) == true) { // Force a widget with a specific serial to either type DMXUSBWidget::Type type = (DMXUSBWidget::Type) types[serial].toInt(); switch (type) { case DMXUSBWidget::OpenTX: widgetList << new EnttecDMXUSBOpen(serial, name, vendor); break; case DMXUSBWidget::ProRX: { EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++); widgetList << prorx; break; } case DMXUSBWidget::ProMk2: { EnttecDMXUSBProTX* protx = new EnttecDMXUSBProTX(serial, name, vendor, 1); widgetList << protx; widgetList << new EnttecDMXUSBProTX(serial, name, vendor, 2, protx->ftdi()); EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++, protx->ftdi()); widgetList << prorx; break; } case DMXUSBWidget::UltraProTx: { UltraDMXUSBProTx* protx = new UltraDMXUSBProTx(serial, name, vendor, 1); widgetList << protx; widgetList << new UltraDMXUSBProTx(serial, name, vendor, 2, protx->ftdi()); EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++, protx->ftdi()); widgetList << prorx; break; } case DMXUSBWidget::VinceTX: widgetList << new VinceUSBDMX512TX(serial, name, vendor); break; default: case DMXUSBWidget::ProTX: widgetList << new EnttecDMXUSBProTX(serial, name, vendor); break; } } else if (name.toUpper().contains("PRO MK2") == true) { EnttecDMXUSBProTX* protx = new EnttecDMXUSBProTX(serial, name, vendor, 1); widgetList << protx; widgetList << new EnttecDMXUSBProTX(serial, name, vendor, 2, protx->ftdi()); EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++, protx->ftdi()); widgetList << prorx; } else if (name.toUpper().contains("DMX USB PRO")) { /** Check if the device responds to label 77 and 78, so it might be a DMXking adapter */ int ESTAID = 0; int DEVID = 0; QString manName = readLabel(&ftdi, name.toLatin1().data(), serial.toLatin1().data(), USB_DEVICE_MANUFACTURER, &ESTAID); qDebug() << "--------> Device Manufacturer: " << manName; QString devName = readLabel(&ftdi, name.toLatin1().data(), serial.toLatin1().data(), USB_DEVICE_NAME, &DEVID); qDebug() << "--------> Device Name: " << devName; qDebug() << "--------> ESTA Code: " << QString::number(ESTAID, 16) << ", Device ID: " << QString::number(DEVID, 16); if (ESTAID == DMXKING_ESTA_ID) { if (DEVID == ULTRADMX_PRO_DEV_ID) { UltraDMXUSBProTx* protxP1 = new UltraDMXUSBProTx(serial, name, vendor, 1); protxP1->setRealName(devName); widgetList << protxP1; UltraDMXUSBProTx* protxP2 = new UltraDMXUSBProTx(serial, name, vendor, 2, protxP1->ftdi()); protxP2->setRealName(devName); widgetList << protxP2; EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++, protxP1->ftdi()); prorx->setRealName(devName); widgetList << prorx; } else { EnttecDMXUSBProTX* protx = new EnttecDMXUSBProTX(serial, name, vendor); protx->setRealName(devName); widgetList << protx; } } else { /* This is probably a Enttec DMX USB Pro widget */ EnttecDMXUSBProTX* protx = new EnttecDMXUSBProTX(serial, name, vendor); widgetList << protx; EnttecDMXUSBProRX* prorx = new EnttecDMXUSBProRX(serial, name, vendor, input_id++, protx->ftdi()); widgetList << prorx; } } else if (name.toUpper().contains("USB-DMX512 CONVERTER") == true) { widgetList << new VinceUSBDMX512TX(serial, name, vendor); } else if (dev->descriptor.idVendor == QLCFTDI::FTDIVID && dev->descriptor.idProduct == QLCFTDI::DMX4ALLPID) { widgetList << new Stageprofi(serial, name, vendor); } #if defined(Q_WS_X11) || defined(Q_OS_LINUX) else if (dev->descriptor.idVendor == QLCFTDI::ATMELVID && dev->descriptor.idProduct == QLCFTDI::NANODMXPID) { widgetList << new NanoDMX(serial, name, vendor); } #endif else { /* This is probably an Open DMX USB widget */ widgetList << new EnttecDMXUSBOpen(serial, name, vendor, 0); } #ifndef LIBFTDI1 } #endif } #ifdef LIBFTDI1 libusb_free_device_list(devs, 1); #endif ftdi_deinit(&ftdi); return widgetList; } bool QLCFTDI::open() { if (m_openCount < m_refCount) m_openCount++; if (isOpen() == true) return true; if (ftdi_usb_open_desc(&m_handle, QLCFTDI::FTDIVID, QLCFTDI::FTDIPID, name().toLatin1(), serial().toLatin1()) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::openByPID(const int PID) { if (m_openCount < m_refCount) m_openCount++; if (isOpen() == true) return true; if (ftdi_usb_open(&m_handle, QLCFTDI::FTDIVID, PID) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::close() { if (m_openCount > 1) { m_openCount--; return true; } if (ftdi_usb_close(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::isOpen() const { return (m_handle.usb_dev != NULL) ? true : false; } bool QLCFTDI::reset() { if (ftdi_usb_reset(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::setLineProperties() { if (ftdi_set_line_property(&m_handle, BITS_8, STOP_BIT_2, NONE) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::setBaudRate() { if (ftdi_set_baudrate(&m_handle, 250000) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::setFlowControl() { if (ftdi_setflowctrl(&m_handle, SIO_DISABLE_FLOW_CTRL) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::clearRts() { if (ftdi_setrts(&m_handle, 0) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::purgeBuffers() { if (ftdi_usb_purge_buffers(&m_handle) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } } bool QLCFTDI::setBreak(bool on) { ftdi_break_type type; if (on == true) type = BREAK_ON; else type = BREAK_OFF; if (ftdi_set_line_property2(&m_handle, BITS_8, STOP_BIT_2, NONE, type) < 0) { qWarning() << Q_FUNC_INFO << name() << ftdi_get_error_string(&m_handle); return false; } else { return true; } }