コード例 #1
0
epicsStatus
mrmEvgSetupVME (
    const char* id,         // Card Identifier
    epicsInt32  slot,       // VME slot
    epicsUInt32 vmeAddress, // Desired VME address in A24 space
    epicsInt32  irqLevel,   // Desired interrupt level
    epicsInt32  irqVector,  // Desired interrupt vector number
    bool ignoreVersion)     // Ignore errors due to firmware checks
{
    volatile epicsUInt8* regCpuAddr = 0;
    volatile epicsUInt8* regCpuAddr2 = 0; //function 2 of regmap (fanout/concentrator specifics)
    struct VMECSRID info;
    deviceInfoT deviceInfo;

    info.board = 0; info.revision = 0; info.vendor = 0;

    deviceInfo.bus.busType = busType_vme;
    deviceInfo.bus.vme.slot = slot;
    deviceInfo.bus.vme.address = vmeAddress;
    deviceInfo.bus.vme.irqLevel = irqLevel;
    deviceInfo.bus.vme.irqVector = irqVector;
    deviceInfo.series = series_unknown;


    int status; // a variable to hold function return statuses

    try {
        if(mrf::Object::getObject(id)){
            errlogPrintf("ID %s already in use\n",id);
            return -1;
        }

        volatile unsigned char* csrCpuAddr; // csrCpuAddr is VME-CSR space CPU address for the board
        csrCpuAddr = //devCSRProbeSlot(slot);
                     devCSRTestSlot(vmeEvgIDs,slot,&info); //FIXME: add support for EVM id

        if(!csrCpuAddr) {
            errlogPrintf("No EVG in slot %d\n",slot);
            return -1;
        }

        epicsPrintf("##### Setting up MRF EVG in VME Slot %d #####\n",slot);
        epicsPrintf("Found Vendor: %08x\nBoard: %08x\nRevision: %08x\n",
                info.vendor, info.board, info.revision);

        epicsUInt32 xxx = CSRRead32(csrCpuAddr + CSR_FN_ADER(1));
        if(xxx)
            epicsPrintf("Warning: EVG not in power on state! (%08x)\n", xxx);

        /*Setting the base address of Register Map on VME Board (EVG)*/
        CSRSetBase(csrCpuAddr, 1, vmeAddress, VME_AM_STD_SUP_DATA);

        {
            epicsUInt32 temp=CSRRead32((csrCpuAddr) + CSR_FN_ADER(1));

            if(temp != CSRADER((epicsUInt32)vmeAddress,VME_AM_STD_SUP_DATA)) {
                errlogPrintf("Failed to set CSR Base address in ADER1.  Check VME bus and card firmware version.\n");
                return -1;
            }
        }

        /* Create a static string for the card description (needed by vxWorks) */
        char *Description = allocSNPrintf(40, "EVG-%d '%s' slot %d",
                                          info.board & MRF_BID_SERIES_MASK,
                                          id, slot);

        /*Register VME address and get corresponding CPU address */
        status = devRegisterAddress (
            Description,                           // Event Generator card description
            atVMEA24,                              // A24 Address space
            vmeAddress,                            // Physical address of register space
            EVG_REGMAP_SIZE,                       // Size of card's register space
            (volatile void **)(void *)&regCpuAddr  // Local address of card's register map
        );


        if(status) {
            errlogPrintf("Failed to map VME address %08x\n", vmeAddress);
            return -1;
        }


        epicsUInt32 version = checkVersion(regCpuAddr, 0x3);
        epicsPrintf("Firmware version: %08x\n", version);

        if(version == 0){
            if(ignoreVersion) {
                epicsPrintf("Ignoring version error.\n");
            }
            else {
                return -1;
            }
        }


        /* Set the base address of Register Map for function 2, if we have the right firmware version  */
        if(version >= EVG_FCT_MIN_FIRMWARE) {
            deviceInfo.series = series_300;
            CSRSetBase(csrCpuAddr, 2, vmeAddress+EVG_REGMAP_SIZE, VME_AM_STD_SUP_DATA);
            {
                epicsUInt32 temp=CSRRead32((csrCpuAddr) + CSR_FN_ADER(2));

                if(temp != CSRADER((epicsUInt32)vmeAddress+EVG_REGMAP_SIZE,VME_AM_STD_SUP_DATA)) {
                    epicsPrintf("Failed to set CSR Base address in ADER2 for FCT register mapping.  Check VME bus and card firmware version.\n");
                    return -1;
                }
            }

            /* Create a static string for the card description (needed by vxWorks) */
            char *Description = allocSNPrintf(40, "EVG-%d FOUT'%s' slot %d",
                                              info.board & MRF_BID_SERIES_MASK,
                                              id, slot);

             status = devRegisterAddress (
                Description,                           // Event Generator card description
                atVMEA24,                              // A24 Address space
                vmeAddress+EVG_REGMAP_SIZE,            // Physical address of register space
                EVG_REGMAP_SIZE*2,                     // Size of card's register space
                (volatile void **)(void *)&regCpuAddr2 // Local address of card's register map
            );

            if(status) {
                errlogPrintf("Failed to map VME address %08x for FCT mapping\n", vmeAddress);
                return -1;
            }
        }
        else {
            deviceInfo.series = series_230;
        }

        evgMrm* evg = new evgMrm(id, deviceInfo, regCpuAddr, regCpuAddr2, NULL);

        if(irqLevel > 0 && irqVector >= 0) {
            /*Configure the Interrupt level and vector on the EVG board*/
            CSRWrite8(csrCpuAddr + UCSR_DEFAULT_OFFSET + UCSR_IRQ_LEVEL, irqLevel&0x7);
            CSRWrite8(csrCpuAddr + UCSR_DEFAULT_OFFSET + UCSR_IRQ_VECTOR, irqVector&0xff);

            epicsPrintf("IRQ Level: %d\nIRQ Vector: %d\n",
                CSRRead8(csrCpuAddr + UCSR_DEFAULT_OFFSET + UCSR_IRQ_LEVEL),
                CSRRead8(csrCpuAddr + UCSR_DEFAULT_OFFSET + UCSR_IRQ_VECTOR)
            );


            epicsPrintf("csrCpuAddr : %p\nregCpuAddr : %p\nreCpuAddr2 : %p\n",csrCpuAddr, regCpuAddr, regCpuAddr2);

            /*Disable the interrupts and enable them at the end of iocInit via initHooks*/
            WRITE32(regCpuAddr, IrqFlag, READ32(regCpuAddr, IrqFlag));
            WRITE32(regCpuAddr, IrqEnable, 0);

            // VME IRQ level will be enabled later during iocInit()
            vme_level_mask |= 1 << ((irqLevel&0x7)-1);

            /*Connect Interrupt handler to vector*/
            if(devConnectInterruptVME(irqVector & 0xff, &evgMrm::isr_vme, evg)){
                errlogPrintf("ERROR:Failed to connect VME IRQ vector %d\n"
                                                         ,irqVector&0xff);
                delete evg;
                return -1;
            }
        }
    } catch(std::exception& e) {
        errlogPrintf("Error: %s\n",e.what());
        errlogFlush();
        return -1;
    }
    errlogFlush();
    return 0;

} //mrmEvgSetupVME
コード例 #2
0
epicsStatus
mrmEvgSetupPCI (
        const char* id,         // Card Identifier
        int b,       			// Bus number
        int d, 					// Device number
        int f,   				// Function number
        bool ignoreVersion)     // Ignore errors due to kernel module and firmware version checks
{
    deviceInfoT deviceInfo;

    deviceInfo.bus.busType = busType_pci;
    deviceInfo.bus.pci.bus = b;
    deviceInfo.bus.pci.device = d;
    deviceInfo.bus.pci.function = f;
    deviceInfo.series = series_unknown;

    try {
        if (mrf::Object::getObject(id)) {
            errlogPrintf("ID %s already in use\n", id);
            return -1;
        }

        if(checkUIOVersion(1) > 0) {    // check if kernel version is successfully read and is as expected or higher, and if it can be read at all.
            if(ignoreVersion){
                epicsPrintf("Ignoring kernel module error.\n");
            }
            else{
                return -1;
            }
        }

        /* Find PCI device from devLib2 */
        const epicsPCIDevice *cur = 0;
        if (devPCIFindBDF(mrmevgs, b, d, f, &cur, 0)) {
            errlogPrintf("PCI Device not found on %x:%x.%x\n", b, d, f);
            return -1;
        }

        epicsPrintf("Device %s  %x:%x.%x\n", id, cur->bus, cur->device, cur->function);
        epicsPrintf("Using IRQ %u\n", cur->irq);


        /* MMap BAR0(plx) and BAR2(EVG)*/
        volatile epicsUInt8 *BAR_plx, *BAR_evg; // base addressed for plx/evg bars

        if (devPCIToLocalAddr(cur, 0, (volatile void**) (void *) &BAR_plx, 0)
                || devPCIToLocalAddr(cur, 2, (volatile void**) (void *) &BAR_evg, 0)) {
            errlogPrintf("Failed to map BARs 0 and 2\n");
            return -1;
        }

        if (!BAR_plx || !BAR_evg) {
            errlogPrintf("BARs mapped to zero? (%08lx,%08lx)\n",
                    (unsigned long) BAR_plx, (unsigned long) BAR_evg);
            return -1;
        }

        //Set LE mode on PLX bridge
        //TODO: this limits cPCI EVG device support to LE architectures
        //			At this point in time we do not have any BE PCI systems at hand so this is left as
        //			unsported until we HW to test it on...

        epicsUInt32 plxCtrl = LE_READ32(BAR_plx,LAS0BRD);
        plxCtrl = plxCtrl & ~LAS0BRD_ENDIAN;
        LE_WRITE32(BAR_plx,LAS0BRD,plxCtrl);


        epicsUInt32 version = checkVersion(BAR_evg, 0x3);
        epicsPrintf("Firmware version: %08x\n", version);

        if(version == 0) {
            if(ignoreVersion) {
                epicsPrintf("Ignoring version error.\n");
            }
            else {
                return -1;
            }
        }

        evgMrm* evg = new evgMrm(id, deviceInfo, BAR_evg, 0, cur);

        evg->getSeqRamMgr()->getSeqRam(0)->disable();
        evg->getSeqRamMgr()->getSeqRam(1)->disable();


        /*Disable the interrupts and enable them at the end of iocInit via initHooks*/
        WRITE32(BAR_evg, IrqFlag, READ32(BAR_evg, IrqFlag));
        WRITE32(BAR_evg, IrqEnable, 0);

        /*
         * Enable active high interrupt1 through the PLX to the PCI bus.
         */
//		LE_WRITE16(BAR_plx, INTCSR,	INTCSR_INT1_Enable| INTCSR_INT1_Polarity| INTCSR_PCI_Enable);
        if(ignoreVersion){
            epicsPrintf("Not enabling interrupts.\n");
        }
        else {
            if(devPCIEnableInterrupt(cur)) {
                errlogPrintf("Failed to enable interrupt\n");
                return -1;
            }
        }

#ifdef __linux__
        evg->isrLinuxPvt = (void*) cur;
#endif

        /*Connect Interrupt handler to isr thread*/
        if(ignoreVersion){
            epicsPrintf("Not connecting interrupts.\n");
        }
        else {
            if (devPCIConnectInterrupt(cur, &evgMrm::isr_pci, (void*) evg, 0)) {//devConnectInterruptVME(irqVector & 0xff, &evgMrm::isr, evg)){
                errlogPrintf("ERROR:Failed to connect PCI interrupt\n");
                delete evg;
                return -1;
            } else {
                epicsPrintf("PCI interrupt connected!\n");
            }
        }
    } catch (std::exception& e) {
        errlogPrintf("Error: %s\n", e.what());
        errlogFlush();
        return -1;
    }

    return 0;
} //mrmEvgSetupPCI
コード例 #3
0
void UpdateManager::init() {
	updater = unique_ptr<Updater>(new Updater(this));

	checkVersion(false);
}
コード例 #4
0
ファイル: lua_misc.cpp プロジェクト: dbt1/neutrino-mp
int CLuaInstMisc::checkVersion_old(lua_State *L)
{
	MISC_FUNC_DEPRECATED(L, "checkVersion");
	return checkVersion(L);
}
コード例 #5
0
//--------------------------------------------------------------
// initialize OpenGL 3.3 graphics
BOOL mgWinGL33Support::initDisplay()
{
  mgDebug("------ try to create OpenGL 3.3 context, fullscreen=%s, multiSample=%s", 
    m_fullscreen?"true":"false", 
    m_multiSample?"true":"false");

  mgGLInit();

  // save the GL_EXTENSIONS from the base driver as backup
  const GLubyte* defaultExtensions = glGetString(GL_EXTENSIONS);

  PFNWGLCHOOSEPIXELFORMATARBPROC fnChoosePixelFormatARB = (PFNWGLCHOOSEPIXELFORMATARBPROC)wglGetProcAddress("wglChoosePixelFormatARB");
  PFNWGLCREATECONTEXTATTRIBSARBPROC fnCreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)wglGetProcAddress("wglCreateContextAttribsARB");
  PFNGLGETSTRINGIPROC fnGetStringi = (PFNGLGETSTRINGIPROC)wglGetProcAddress("glGetStringi");
  PFNWGLGETPIXELFORMATATTRIBIVARBPROC fnGetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC) wglGetProcAddress("wglGetPixelFormatAttribivARB");

  if (fnChoosePixelFormatARB == NULL || 
      fnCreateContextAttribsARB == NULL || 
      fnGetStringi == NULL)
  {
    mgDebug("GLCreate unable to locate OpenGL methods");
    termDisplay();
    return false;
  }

  int* formatAttribs;
  if (m_multiSample)
    formatAttribs = GL33_MULTISAMPLE_ATTRIBUTES;
  else formatAttribs = GL33_DEFAULT_ATTRIBUTES;
  
  float floatFormatAttribs[] = {
    0.0f
  };

  int formats[1];
  UINT formatCount;
  (*fnChoosePixelFormatARB) (m_dc, formatAttribs, floatFormatAttribs, 1, formats, &formatCount);
  if (formatCount < 1)
  {
    // fall back to default, not multisample
    (*fnChoosePixelFormatARB) (m_dc, GL33_DEFAULT_ATTRIBUTES, floatFormatAttribs, 1, formats, &formatCount);
    if (formatCount < 1)
    {
      mgDebug("OpenGL: No available pixel formats");
      termDisplay();
      return false;
    }
  }

  if (fnGetPixelFormatAttribivARB != NULL)
  {
    // HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues
    int attribs[] = {WGL_RED_BITS_ARB, WGL_GREEN_BITS_ARB, WGL_BLUE_BITS_ARB, WGL_ALPHA_BITS_ARB, WGL_DEPTH_BITS_ARB, WGL_SAMPLES_ARB};
    int values[6];
    (*fnGetPixelFormatAttribivARB) (m_dc, formats[0], 0, 6, attribs, values); 
    mgDebug("wglGetPixelFormatARB = R%dG%dB%dA%d, %d depth, %d multisample", values[0], values[1], values[2], values[3], values[4], values[5]);
  }

  PIXELFORMATDESCRIPTOR pfd;
  memset(&pfd, 0, sizeof(pfd));
  m_pixelFormat = formats[0];
  SetPixelFormat(m_dc, m_pixelFormat, &pfd);
  DescribePixelFormat(m_dc, m_pixelFormat, sizeof(pfd), &pfd);

  m_depthBits = 16;  // assumed, since that's what we requested
  if (pfd.cDepthBits != 0)
    m_depthBits = pfd.cDepthBits;
  mgDebug("stencil bits = %d", pfd.cStencilBits);

  m_glrc = (*fnCreateContextAttribsARB)(m_dc, NULL, GL33_CREATE_ATTRIBUTES);
  if (m_glrc == NULL)
  {
    mgDebug("OpenGL wglCreateContextAttribsARB returns NULL");
    termDisplay();
    return false;
  }

  if (!wglMakeCurrent(m_dc, m_glrc))
  {
    mgDebug("OpenGL: cannot make rc current.");
    termDisplay();
    return false;
  }

  // get the extension list again now that we have chosen driver
  const GLubyte* extensions = glGetString(GL_EXTENSIONS);
  checkError();  // clear error if can't return extensions

  // if no extensions, try building them with glGetStringi
  if (extensions == NULL)
  {
    mgDebug("glGetString(GL_EXTENSIONS) returns NULL");
    int listAlloc = 80;
    int listLen = 0;
    char* extList = new char[listAlloc];
    int i = 0;
    for (; ; i++)
    {
      const GLubyte* ext = (*fnGetStringi)(GL_EXTENSIONS, i);
      if (ext == NULL)
        break;
      int extLen = strlen((const char*) ext);

      // reallocate the list if we need more room
      if (listLen + extLen+1 > listAlloc)
      {
        listAlloc = listAlloc + extLen + 512;
        char* newList = new char[listAlloc];
        memcpy(newList, extList, listLen);
        delete extList;
        extList = newList;
      }

      strcpy(extList+listLen, (const char*) ext);
      listLen += extLen;
      extList[listLen++] = ' ';
    }
    extList[listLen] = '\0';

    mgDebug("glGetStringi returns %d extensions", i);
    checkError();  // clear error from requesting last extension

    // if there were no individual extensions, use default list
    if (listLen != 0)
      glExtensions = (GLubyte*) extList;
    else glExtensions = (GLubyte*) defaultExtensions;
  }

  GLenum err = glewInit();
  if (err != GLEW_OK)
  {
    mgDebug("glewInit failed.");
    termDisplay();
    return false;
  }

  mgString errorMsg;
  if (!checkVersion(303, 303, errorMsg))
  {
    mgDebug("%s", (const char*) errorMsg);
    termDisplay();
    return false;
  }

  if (mgPlatform->getMultiSample())
    glEnable(GL_MULTISAMPLE);

  if (m_swapImmediate)
    wglSwapIntervalEXT(0);

  // compile the overlay shader
  mgDebug("compile overlay shader:");
  const char* attrNames[] = {"vertPoint", "vertTexCoord0"};
  const DWORD attrIndexes[] = {0, 1};
  m_overlayShader = compileShaderPair(GL33_OVERLAY_VERTEX_SHADER, GL33_OVERLAY_FRAGMENT_SHADER,
    2, attrNames, attrIndexes);

  return true;
}
コード例 #6
0
// ---------------------------------------------------------------------
// Loads the symbol for the subcircuit from the schematic file and
// returns the number of painting elements.
int Subcircuit::loadSymbol(const QString& DocName)
{
  QFile file(DocName);
  if(!file.open(QIODevice::ReadOnly))
    return -1;

  QString Line;
  // *****************************************************************
  // To strongly speed up the file read operation the whole file is
  // read into the memory in one piece.
  Q3TextStream ReadWhole(&file);
  QString FileString = ReadWhole.read();
  file.close();
  Q3TextStream stream(&FileString, QIODevice::ReadOnly);


  // read header **************************
  do {
    if(stream.atEnd()) return -2;
    Line = stream.readLine();
    Line = Line.stripWhiteSpace();
  } while(Line.isEmpty());

  if(Line.left(16) != "<Qucs Schematic ")  // wrong file type ?
    return -3;

  Line = Line.mid(16, Line.length()-17);
  if(!checkVersion(Line)) // wrong version number ?
    return -4;

  // read content *************************
  while(!stream.atEnd()) {
    Line = stream.readLine();
    if(Line == "<Symbol>") break;
  }

  x1 = y1 = INT_MAX;
  x2 = y2 = INT_MIN;

  int z=0, Result;
  while(!stream.atEnd()) {
    Line = stream.readLine();
    if(Line == "</Symbol>") {
      x1 -= 4;   // enlarge component boundings a little
      x2 += 4;
      y1 -= 4;
      y2 += 4;
      return z;      // return number of ports
    }

    Line = Line.stripWhiteSpace();
    if(Line.at(0) != '<') return -5;
    if(Line.at(Line.length()-1) != '>') return -6;
    Line = Line.mid(1, Line.length()-2); // cut off start and end character
    Result = analyseLine(Line, 1);
    if(Result < 0) return -7;   // line format error
    z += Result;
  }

  return -8;   // field not closed
}
コード例 #7
0
void PackageDialog::extractPackage()
{
    QString s = QFileDialog::getOpenFileName(
                    lastDir.isEmpty() ? QString(".") : lastDir,
                    tr("Qucs Packages")+" (*.qucs);;"+
                    tr("Any File")+" (*)",
                    this, 0, tr("Enter a Package File Name"));

    if(s.isEmpty()) {
        reject();
        return;
    }

    QFileInfo Info(s);
    lastDir = Info.dirPath(true);  // remember last directory

    QFile PkgFile(s);
    if(!PkgFile.open(QIODevice::ReadOnly)) {
        if(Info.extension().isEmpty()) s += ".qucs";
        PkgFile.setName(s);
        if(!PkgFile.open(QIODevice::ReadOnly)) {
            MsgText->append(tr("ERROR: Cannot open package!"));
            ButtClose->setDisabled(false);
            return;
        }
    }
    QDataStream Stream(&PkgFile);

    QDir currDir = QucsHomeDir;
    QString Version;
    Q_UINT16 Checksum;
    Q_UINT32 Code, Length;

    // First read and check header.
    QByteArray Content = PkgFile.readAll();
    if(strncmp(Content.data(), "Qucs package ", 13) != 0) {
        MsgText->append(tr("ERROR: File contains wrong header!"));
        goto ErrorEnd;
    }

    Version = QString(Content.data()+13);
    if(!checkVersion(Version)) {
        MsgText->append(tr("ERROR: Wrong version number!"));
        goto ErrorEnd;
    }

    // checksum correct ?
    PkgFile.at(HEADER_LENGTH-2);
    Stream >> Checksum;
    *((Q_UINT16*)(Content.data()+HEADER_LENGTH-2)) = 0;
    if(Checksum != qChecksum(Content.data(), Content.size())) {
        MsgText->append(tr("ERROR: Checksum mismatch!"));
        goto ErrorEnd;
    }
    Content.resize(0);   // dispose memory


    // work on all files and directories in the package
    for(;;) {
        if(PkgFile.atEnd()) break;
        Stream >> Code >> Length;

        switch(Code) {
        case CODE_DIR:
            if(extractDirectory(PkgFile, Length, currDir) > 0)
                break;
            goto ErrorEnd;
        case CODE_DIR_END:
            MsgText->append(tr("Leave directory \"%1\"").arg(currDir.absPath()));
            currDir.cdUp();
            break;
        case CODE_FILE:
            if(extractFile(PkgFile, Length, currDir) > 0)
                break;
            goto ErrorEnd;
        case CODE_LIBRARY:
            if(extractLibrary(PkgFile, Length) > 0)
                break;
            goto ErrorEnd;
        default:
            MsgText->append(tr("ERROR: Package is corrupt!"));
            goto ErrorEnd;
        }
    }


    MsgText->append(" ");
    MsgText->append(tr("Successfully extracted package!"));
ErrorEnd:
    MsgText->append(" ");
    ButtClose->setDisabled(false);
    PkgFile.close();
}
コード例 #8
0
ファイル: opentxinterface.cpp プロジェクト: Dobraku/opentx
bool OpenTxEepromInterface::load(RadioData &radioData, const uint8_t *eeprom, int size)
{
  std::cout << "trying " << getName() << " import...";

  if (size != getEEpromSize()) {    
    if (size==4096) {
      int notnull=false;
      for (int i=2048; i<4096; i++) {
        if (eeprom[i]!=255) {
          notnull=true;
        }
      }
      if (notnull) {
        std::cout << " wrong size (" << size << ")\n";
        return false;
      }
      else {
        QMessageBox::warning(NULL, "companion", QObject::tr("Your radio probably uses a wrong firmware,\n eeprom size is 4096 but only the first 2048 are used"));
        size=2048;
      }
    } else {
      std::cout << " wrong size (" << size << ")\n";
      return false;
    }
  }

  if (!efile->EeFsOpen((uint8_t *)eeprom, size, board)) {
    std::cout << " wrong file system\n";
    return false;
  }

  efile->openRd(FILE_GENERAL);
  
  uint8_t version;
  if (efile->readRlc2(&version, 1) != 1) {
    std::cout << " no\n";
    return false;
  }

  std::cout << " version " << (unsigned int)version;

  if (!checkVersion(version)) {
    std::cout << " not open9x\n";
    return false;
  }

  if (!loadGeneral<OpenTxGeneralData>(radioData.generalSettings, version)) {
    std::cout << " ko\n";
    return false;
  }
  
  std::cout << " variant " << radioData.generalSettings.variant;
  for (int i=0; i<getMaxModels(); i++) {
    if (!loadModel(version, radioData.models[i], NULL, i, radioData.generalSettings.variant, radioData.generalSettings.stickMode+1)) {
      std::cout << " ko\n";
      return false;
    }
  }
  std::cout << " ok\n";
  return true;
}
コード例 #9
0
void MainWindow::startConnection() {
    Client *client = new Client(this);

    connect(client, SIGNAL(version_checked(QString, QString)), SLOT(checkVersion(QString, QString)));
    connect(client, SIGNAL(error_message(QString)), SLOT(networkError(QString)));
}
コード例 #10
0
ファイル: packs.cpp プロジェクト: yying/osquery
void Pack::initialize(const std::string& name,
                      const std::string& source,
                      const pt::ptree& tree) {
  name_ = name;
  source_ = source;
  // Check the shard limitation, shards falling below this value are included.
  if (tree.count("shard") > 0) {
    shard_ = tree.get<size_t>("shard", 0);
  }

  // Check for a platform restriction.
  platform_.clear();
  if (tree.count("platform") > 0) {
    platform_ = tree.get<std::string>("platform", "");
  }

  // Check for a version restriction.
  version_.clear();
  if (tree.count("version") > 0) {
    version_ = tree.get<std::string>("version", "");
  }

  // Apply the shard, platform, and version checking.
  // It is important to set each value such that the packs meta-table can report
  // each of the restrictions.
  if ((shard_ > 0 && shard_ < getMachineShard()) || !checkPlatform() ||
      !checkVersion()) {
    return;
  }

  discovery_queries_.clear();
  if (tree.count("discovery") > 0) {
    for (const auto& item : tree.get_child("discovery")) {
      discovery_queries_.push_back(item.second.get_value<std::string>());
    }
  }

  // Initialize a discovery cache at time 0.
  discovery_cache_ = std::make_pair<size_t, bool>(0, false);
  valid_ = true;

  // If the splay percent is less than 1 reset to a sane estimate.
  if (FLAGS_schedule_splay_percent <= 1) {
    FLAGS_schedule_splay_percent = 10;
  }

  schedule_.clear();
  if (tree.count("queries") == 0) {
    // This pack contained no queries.
    return;
  }

  // Iterate the queries (or schedule) and check platform/version/sanity.
  for (const auto& q : tree.get_child("queries")) {
    if (q.second.count("shard") > 0) {
      auto shard = q.second.get<size_t>("shard", 0);
      if (shard > 0 && shard < getMachineShard()) {
        continue;
      }
    }

    if (q.second.count("platform")) {
      if (!checkPlatform(q.second.get<std::string>("platform", ""))) {
        continue;
      }
    }

    if (q.second.count("version")) {
      if (!checkVersion(q.second.get<std::string>("version", ""))) {
        continue;
      }
    }

    ScheduledQuery query;
    query.query = q.second.get<std::string>("query", "");
    query.interval = q.second.get("interval", FLAGS_schedule_default_interval);
    if (query.interval <= 0 || query.query.empty() ||
        query.interval > kMaxQueryInterval) {
      // Invalid pack query.
      LOG(WARNING) << "Query has invalid interval: " << q.first << ": "
                   << query.interval;
      continue;
    }

    query.splayed_interval = restoreSplayedValue(q.first, query.interval);
    query.options["snapshot"] = q.second.get<bool>("snapshot", false);
    query.options["removed"] = q.second.get<bool>("removed", true);
    schedule_[q.first] = query;
  }
}
コード例 #11
0
void checkOpenSSL(std::string version)
{
    checkVersion("OpenSSL", openSSLMinimal, version);
}
コード例 #12
0
void checkBoost(std::string version)
{
    checkVersion("Boost", boostMinimal, version);
}
コード例 #13
0
ファイル: opentxinterface.cpp プロジェクト: Dobraku/opentx
bool OpenTxEepromInterface::loadBackup(RadioData &radioData, uint8_t *eeprom, int esize, int index)
{
  std::cout << "trying " << getName() << " backup import...";

  if (esize < 8 || memcmp(eeprom, "o9x", 3) != 0) {
    std::cout << " no\n";
    return false;
  }

  BoardEnum backupBoard = (BoardEnum)-1;
  switch (eeprom[3]) {
    case 0x33:
      backupBoard = BOARD_TARANIS;
      break;
    case 0x32:
      backupBoard = BOARD_SKY9X;
      break;
    case 0x31:
      backupBoard = BOARD_GRUVIN9X;
      break;
    default:
      std::cout << " unknown board\n";
      return false;
  }

  if (backupBoard != board) {
    std::cout << " not right board\n";
    return false;
  }

  uint8_t version = eeprom[4];
  uint8_t bcktype = eeprom[5];
  uint16_t size = ((uint16_t)eeprom[7] << 8) + eeprom[6];
  uint16_t variant = ((uint16_t)eeprom[9] << 8) + eeprom[8];

  std::cout << " version " << (unsigned int)version << " ";

  if (!checkVersion(version)) {
    std::cout << " not open9x\n";
    return false;
  }

  if (size > esize-8) {
    std::cout << " wrong size\n";
    return false;
  }

  if (bcktype=='M') {
    if (!loadModel(version, radioData.models[index], &eeprom[8], size, variant)) {
      std::cout << " ko\n";
      return false;
    }
  }
  else {
    std::cout << " backup type not supported\n";
    return false;
  }

  std::cout << " ok\n";
  return true;
}
コード例 #14
0
 /**
  * Creates a new JAVOLUTION OSGi bundle activator.
  *
  * @return the activator instance.
  */
 inline static JavolutionActivator newInstance() {
 	// Identifying information which can be retrieved using the Linux command 'what'
 	char ident[] = "@(#)JAVOLUTION Version: " JAVOLUTION_MAJOR_VERSION;
 	checkVersion(JAVOLUTION_MAJOR_VERSION, ident);
     return JavolutionActivator(new JavolutionActivator_API());
 }
コード例 #15
0
ファイル: packs.cpp プロジェクト: ravindrapro/osquery
bool Pack::checkVersion() { return checkVersion(version_); }
コード例 #16
0
ファイル: packs.cpp プロジェクト: noscripter/osquery
bool Pack::shouldPackExecute() {
  return checkVersion() && checkPlatform() && checkDiscovery();
}
コード例 #17
0
ファイル: dealer.c プロジェクト: Michael-Z/poker-2
/* run a match of numHands hands of the supplied game

   cards are dealt using rng, error conditions like timeouts
   are controlled and stored in errorInfo

   actions are read/sent to seat p on seatFD[ p ]

   if quiet is not zero, only print out errors, warnings, and final value   
   
   if logFile is not NULL, print out a single line for each completed
   match with the final state and all player values.  The values are
   printed in player, not seat order.

   if transactionFile is not NULL, a transaction log of actions made
   is written to the file, and if there is any input left to read on
   the stream when gameLoop is called, it will be processed to
   initialise the state

   returns >=0 if the match finished correctly, -1 on error */
static int gameLoop( const Game *game, char *seatName[ MAX_PLAYERS ],
		     const uint32_t numHands, const int quiet,
		     const int fixedSeats, rng_state_t *rng,
		     ErrorInfo *errorInfo, const int seatFD[ MAX_PLAYERS ],
		     ReadBuf *readBuf[ MAX_PLAYERS ],
		     FILE *logFile, FILE *transactionFile )
{
  uint32_t handId;
  uint8_t seat, p, player0Seat, currentP, currentSeat;
  struct timeval t, sendTime, recvTime;
  Action action;
  MatchState state;
  double value[ MAX_PLAYERS ], totalValue[ MAX_PLAYERS ];

  /* check version string for each player */
  for( seat = 0; seat < game->numPlayers; ++seat ) {

    if( checkVersion( seat, seatFD[ seat ], readBuf[ seat ] ) < 0 ) {
      /* error messages already handled in function */

      return -1;
    }
  }

  gettimeofday( &sendTime, NULL );
  if( !quiet ) {
    fprintf( stderr, "STARTED at %zu.%06zu\n",
	     sendTime.tv_sec, sendTime.tv_usec );
  }

  /* start at the first hand */
  handId = 0;
  if( checkErrorNewHand( game, errorInfo ) < 0 ) {

    fprintf( stderr, "ERROR: unexpected game\n" );
    return -1;
  }
  initState( game, handId, &state.state );
  dealCards( game, rng, &state.state );
  for( seat = 0; seat < game->numPlayers; ++seat ) {
    totalValue[ seat ] = 0.0;
  }

  /* seat 0 is player 0 in first game */
  player0Seat = 0;

  /* process the transaction file */
  if( transactionFile != NULL ) {

    if( processTransactionFile( game, fixedSeats, &handId, &player0Seat,
				rng, errorInfo, totalValue,
				&state, transactionFile ) < 0 ) {
      /* error messages already handled in function */

      return -1;
    }
  }

  if( handId >= numHands ) {
    goto finishedGameLoop;
  }

  /* play all the (remaining) hands */
  while( 1 ) {

    /* play the hand */
    while( !stateFinished( &state.state ) ) {

      /* find the current player */
      currentP = currentPlayer( game, &state.state );

      /* send state to each player */
      for( seat = 0; seat < game->numPlayers; ++seat ) {

	state.viewingPlayer = seatToPlayer( game, player0Seat, seat );
	if( sendPlayerMessage( game, &state, quiet, seat,
			       seatFD[ seat ], &t ) < 0 ) {
	  /* error messages already handled in function */

	  return -1;
	}

	/* remember the seat and send time if player is acting */
	if( state.viewingPlayer == currentP ) {

	  sendTime = t;
	}
      }

      /* get action from current player */
      state.viewingPlayer = currentP;
      currentSeat = playerToSeat( game, player0Seat, currentP );
      if( readPlayerResponse( game, &state, quiet, currentSeat, &sendTime,
			      errorInfo,
			      seatFD[ currentSeat ], readBuf[ currentSeat ],
			      &action, &recvTime ) < 0 ) {
	/* error messages already handled in function */

	return -1;
      }

      /* log the transaction */
      if( transactionFile != NULL ) {

	if( logTransaction( game, &state.state, &action,
			    &sendTime, &recvTime, transactionFile ) < 0 ) {
	  /* error messages already handled in function */

	  return -1;
	}
      }

      /* do the action */
      doAction( game, &action, &state.state );
    }

    /* get values */
    for( p = 0; p < game->numPlayers; ++p ) {

      value[ p ] = valueOfState( game, &state.state, p );
      totalValue[ playerToSeat( game, player0Seat, p ) ] += value[ p ];
    }

    /* add the game to the log */
    if( logFile != NULL ) {

      if( addToLogFile( game, &state.state, value, player0Seat,
			seatName, logFile ) < 0 ) {
	/* error messages already handled in function */

	return -1;
      }
    }

    /* send final state to each player */
    for( seat = 0; seat < game->numPlayers; ++seat ) {

      state.viewingPlayer = seatToPlayer( game, player0Seat, seat );
      if( sendPlayerMessage( game, &state, quiet, seat,
			     seatFD[ seat ], &t ) < 0 ) {
	/* error messages already handled in function */

	return -1;
      }
    }

    /* start a new hand */
    if( setUpNewHand( game, fixedSeats, &handId, &player0Seat,
		      rng, errorInfo, &state.state ) < 0 ) {
      /* error messages already handled in function */

      return -1;
    }
    if( handId >= numHands ) {
      break;
    }
  }

 finishedGameLoop:
  /* print out the final values */
  if( !quiet ) {
    gettimeofday( &t, NULL );
    fprintf( stderr, "FINISHED at %zu.%06zu\n",
	     sendTime.tv_sec, sendTime.tv_usec );
  }
  if( printFinalMessage( game, seatName, totalValue, logFile ) < 0 ) {
    /* error messages already handled in function */

    return -1;
  }

  return 0;
}