Exemple #1
0
QByteArray U2Bits::allocateBits(int nBits) {
    int nBytes = getNumberOfBytes(nBits);
#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
        return QByteArray(nBytes, Qt::Uninitialized);
#else
        return QByteArray(nBytes, char(0));
#endif
}
Exemple #2
0
// checkID - checks the ID of the cape to ensure connection to DMCC
// Parameters: fd - session from DMCC start
//             version - version number
// Returns: 0 - if the ID has a compatible version number
//          -1 - if an error occurs
//          Software version number - otherwise
int checkID(int fd, int version) 
{
    // Get ID from cape
    char *ID = getNumberOfBytes(fd, 16, 0xe0);
    if (ID == NULL) {
        printf("Error: No ID found for DMCC cape\n");
        free(ID);
        return -1;
    } 

    // Check ID is DMCC cape
    if (strncmp(ID, "DMCC Mk.", 7) != 0) {
        free(ID);
        printf("Error: Cape specified is not a DMCC cape\n");
        printf("ID: %s\n", ID);
        return -1;
    }

    // Get the software version number as an integer to 
    //      check if board version is the same
    int v = ((int)(ID[8] - 0x30) * 10) + (int)(ID[9] - 0x30);
    if (v != version) {
        printf("Error: Board and board base software are not the same\n");
        free(ID);
        return -1;
    }

    // Check that the version number is compatible
    char pV[2];
    pV[0] = ID[8];
    pV[1] = ID[9];
    // Software is compatible with versions listed in Compatible_Versions array
    int i = 0;
    while(Compatible_Versions[i] != NULL) {
        if (strncmp(pV, Compatible_Versions[i], 2) == 0) {
            free(ID);
            return 0;
        }
        i++;
    }
    
    // Get the software version number as an integer
    free(ID);
    return v;
}