Пример #1
0
/**
 * Reads the entire 16KB ROM.
 */
void CUXInterface::onReadROMImageRequested()
{
    if (m_initComplete && c14cux_isConnected(&m_cuxinfo))
    {
        if (m_romImage == 0)
        {
            m_romImage = new QByteArray(16384, 0x00);
        }

        if (c14cux_dumpROM(&m_cuxinfo, (uint8_t*)m_romImage->data()))
        {
            if (!m_readCanceled)
            {
                emit romImageReady();
            }
        }
        else
        {
            if (!m_readCanceled)
            {
                emit romImageReadFailed();
            }
        }

        m_readCanceled = false;
    }
    else
    {
        emit notConnected();
    }
}
Пример #2
0
/**
 * Responds to a signal requesting that the idle air control valve be moved.
 * @param direction Direction of travel for the idle air control valve;
 *  0 to open and 1 to close
 * @param steps Number of steps to move the valve in the specified direction
 */
void CUXInterface::onIdleAirControlMovementRequest(int direction, int steps)
{
    if (m_initComplete && c14cux_isConnected(&m_cuxinfo))
    {
        c14cux_driveIdleAirControlMotor(&m_cuxinfo, (uint8_t)direction, (uint8_t)steps);
    }
    else
    {
        emit notConnected();
    }
}
Пример #3
0
/**
 * Clears the block of fault codes.
 */
void CUXInterface::onFaultCodesClearRequested()
{
    if (m_initComplete && c14cux_isConnected(&m_cuxinfo))
    {
        if (c14cux_clearFaultCodes(&m_cuxinfo) &&
            c14cux_getFaultCodes(&m_cuxinfo, &m_faultCodes))
        {
            emit faultCodesClearSuccess(m_faultCodes);
        }
        else
        {
            emit faultCodesClearFailure();
        }
    }
    else
    {
        emit notConnected();
    }
}
Пример #4
0
/**
 * Reads fault codes from the 14CUX and stores in a member structure.
 */
void CUXInterface::onFaultCodesRequested()
{
    if (m_initComplete && c14cux_isConnected(&m_cuxinfo))
    {
        memset(&m_faultCodes, 0, sizeof(m_faultCodes));

        if (c14cux_getFaultCodes(&m_cuxinfo, &m_faultCodes))
        {
            emit faultCodesReady();
        }
        else
        {
            emit faultCodesReadFailed();
        }
    }
    else
    {
        emit notConnected();
    }
}
Пример #5
0
int interface() {
    pthread_t pth;

    pthread_create(&pth, NULL, (void*)clearGlobalStructs, NULL);
    pthread_join(pth, NULL);

    connect("ibetres"); // conecta automaticamente no banco padrão

    while(1){
        if (!connected.conn_active) {
            printf(">");
        } else {
            printf("%s=# ", connected.db_name);
        }

        pthread_create(&pth, NULL, (void*)yyparse, &GLOBAL_PARSER);
        pthread_join(pth, NULL);

        if (GLOBAL_PARSER.noerror) {
            if (GLOBAL_PARSER.mode != 0) {
                if (!connected.conn_active) {
                    notConnected();
                } else {
                    switch(GLOBAL_PARSER.mode) {
                        case OP_INSERT:
                            if (GLOBAL_DATA.N > 0) {
                                insert(&GLOBAL_DATA);
                            }
                            else
                                printf("WARNING: Nothing to be inserted. Command ignored.\n");
                            break;
                        case OP_SELECT_ALL:

			

			    if (GLOBAL_DATA.imprimeTudo == 1 && GLOBAL_WHERE.where == 1) {

				
				 whereSemProj(&GLOBAL_DATA, &GLOBAL_WHERE, GLOBAL_DATA.objName);

				 GLOBAL_WHERE.where = 0;
				 GLOBAL_DATA.imprimeTudo = 0;
				 

			    }
			    else if (GLOBAL_DATA.imprimeTudo == 1 && GLOBAL_WHERE.where == 0) {

				
				 imprimeAll(GLOBAL_DATA.objName);
				 GLOBAL_DATA.imprimeTudo = 0;
				 				
			
			    }
			    else if (GLOBAL_DATA.imprimeTudo == 0 && GLOBAL_WHERE.where == 1) {

				
				 whereComProj(&GLOBAL_DATA, &GLOBAL_WHERE, GLOBAL_DATA.objName, GLOBAL_PARSER.col_count);
				 GLOBAL_DATA.imprimeTudo = 0;
				 GLOBAL_WHERE.where = 0;
				 				
			
			    }
			    else {

				 
			    	 selecionar(&GLOBAL_DATA, GLOBAL_PARSER.col_count);
				

			    }
                           
                            break;
                        case OP_CREATE_TABLE:
                            createTable(&GLOBAL_DATA);
                            break;
                        case OP_CREATE_DATABASE:
                            createDB(GLOBAL_DATA.objName);
                            break;
                        case OP_DROP_TABLE:
                            excluirTabela(GLOBAL_DATA.objName);
                            break;
                        case OP_DROP_DATABASE:
                            dropDatabase(GLOBAL_DATA.objName);
		 	    break;
                        default: break;
                    }

                }
            }
        } else {
            GLOBAL_PARSER.consoleFlag = 1;
            switch(GLOBAL_PARSER.mode) {
                case OP_CREATE_DATABASE:
                case OP_DROP_DATABASE:
                case OP_CREATE_TABLE:
                case OP_DROP_TABLE:
                case OP_SELECT_ALL:
                case OP_INSERT:
                    if (GLOBAL_PARSER.step == 1) {
                        GLOBAL_PARSER.consoleFlag = 0;
                        printf("Expected object name.\n");
                    }
                break;

                default: break;
            }

            if (GLOBAL_PARSER.mode == OP_CREATE_TABLE) {
                if (GLOBAL_PARSER.step == 2) {
                    printf("Column not specified correctly.\n");
                    GLOBAL_PARSER.consoleFlag = 0;
                }
            } else if (GLOBAL_PARSER.mode == OP_INSERT) {
                if (GLOBAL_PARSER.step == 2) {
                    printf("Expected token \"VALUES\" after object name.\n");
                    GLOBAL_PARSER.consoleFlag = 0;
                }
            }

            printf("ERROR: syntax error.\n");
            GLOBAL_PARSER.noerror = 1;
        }

        if (GLOBAL_PARSER.mode != 0) {
            pthread_create(&pth, NULL, (void*)clearGlobalStructs, NULL);
            pthread_join(pth, NULL);
        }
    }
    return 0;
}
Пример #6
0
int interface() {
    pthread_t pth;

    pthread_create(&pth, NULL, (void*)clearGlobalStructs, NULL);
    pthread_join(pth, NULL);

    connect("uffsdb"); // conecta automaticamente no banco padrão

    while(1){
        if (!connected.conn_active) {
            printf(">");
        } else {
            printf("%s=# ", connected.db_name);
        }

        pthread_create(&pth, NULL, (void*)yyparse, &GLOBAL_PARSER);
        pthread_join(pth, NULL);

        if (GLOBAL_PARSER.noerror) {
            if (GLOBAL_PARSER.mode != 0) {
                if (!connected.conn_active) {
                    notConnected();
                } else {
                    switch(GLOBAL_PARSER.mode) {
                        case OP_INSERT:
                            if (GLOBAL_DATA.N > 0) {
                                insert(&GLOBAL_DATA);
                            }
                            else
                                printf("WARNING: Nothing to be inserted. Command ignored.\n");
                            break;
                        case OP_SELECT_ALL:
                            pulpfic(select_attributes, GLOBAL_DATA.objName, token_list);
                            /*w_token *jujuba;
                            for(jujuba=token_list;jujuba;jujuba=jujuba->next){
                                printf("jujuba = %s\n",(char*)jujuba->valor);
                            }*/
                            break;
                        case OP_CREATE_TABLE:
                            createTable(&GLOBAL_DATA);
                            break;
                        case OP_CREATE_DATABASE:
                            createDB(GLOBAL_DATA.objName);
                            break;
                        case OP_DROP_TABLE:
                            excluirTabela(GLOBAL_DATA.objName);
                            break;
                        case OP_DROP_DATABASE:
                            dropDatabase(GLOBAL_DATA.objName);
                            break;
                        default: break;
                    }

                }
            }
        } else {
            GLOBAL_PARSER.consoleFlag = 1;
            switch(GLOBAL_PARSER.mode) {
                case OP_CREATE_DATABASE:
                case OP_DROP_DATABASE:
                case OP_CREATE_TABLE:
                case OP_DROP_TABLE:
                case OP_SELECT_ALL:
                case OP_INSERT:
                    if (GLOBAL_PARSER.step == 1) {
                        GLOBAL_PARSER.consoleFlag = 0;
                        printf("Expected object name.\n");
                    }
                break;

                default: break;
            }

            if (GLOBAL_PARSER.mode == OP_CREATE_TABLE) {
                if (GLOBAL_PARSER.step == 2) {
                    printf("Column not specified correctly.\n");
                    GLOBAL_PARSER.consoleFlag = 0;
                }
            } else if (GLOBAL_PARSER.mode == OP_INSERT) {
                if (GLOBAL_PARSER.step == 2) {
                    printf("Expected token \"VALUES\" after object name.\n");
                    GLOBAL_PARSER.consoleFlag = 0;
                }
            }

            printf("ERROR: syntax error.\n");
            GLOBAL_PARSER.noerror = 1;
        }

        if (GLOBAL_PARSER.mode != 0) {
            pthread_create(&pth, NULL, (void*)clearGlobalStructs, NULL);
            pthread_join(pth, NULL);
        }
    }
    return 0;
}
Пример #7
0
/* Menue driven mode */
void mainMenue(void)
{
    char chrUserSelection = 0;

    printHeadline();
    printMenu();
    printf("\n\r");
    printf(" * Note: Please report bugs/feedback to: [email protected]\r\n");

    while(chrUserSelection != 'X')
    {
        chrUserSelection = userMenueButton("LVDRP?XONCMST32GHE","\r\n>>> ","^invalid selection\n\r");

        if(connected)
            ttyClearBuffer(configfilePortValue);		/* Clear serial line buffer */

        switch(chrUserSelection)
        {
        case 'D':
            if(connected)
                chipcardLabDebug();
            else
                notConnected();
            break;

        case 'R':
            if(connected)
                script();
            else
                notConnected();
            break;

        case '3':
            if(connected)
                threeWhireCardTerminal();
            else
                notConnected();
            break;

        case '2':
            if(connected)
                i2cCardTerminal();
            else
                notConnected();
            break;

        case 'V':
            if(connected)
                chipcardLabVersion();
            else
                notConnected();
            break;

        case 'H':
            if(connected)
                chipcardLabPluginCheck();
            else
                notConnected();
            break;

        case 'G':
            if(connected)
            {
                if(chipcardLabPluginCheck() == 0)
                {
                    printf(" * Executing plugin...\r\n");
                    plugin();
                }
            }
            else
                notConnected();
            break;

        case 'O':
            if(connected)
                logicanalyser();
            else
                notConnected();
            break;

        case 'N':
            if(connected)
                txSniff();
            else
                notConnected();
            break;

        case 'M':
            if(connected)
                txTerminal();
            else
                notConnected();
            break;

        case '?':
            printMenu();
            break;

        case 'L':
            if(connected)
                printf("Already connected!");
            else
                connectChipcardLab(1);
            break;

        case 'S':
            if(connected)
                alreadyConnected();
            else
                openSeasonLogger();
            break;

        case 'C':
            if(connected)
                alreadyConnected();
            else
                dumpData(DUMP_SOURCE_FILE);
            break;

        case 'T':
            if(connected)
                alreadyConnected();
            else
                openSerprogTerminal();
            break;

        case 'E':
            if(connected)
                alreadyConnected();
            else
                openPhoenixTerminal();
            break;

        case 'P':
            if(connected)
                alreadyConnected();
            else
                modifyPortConfig();
            break;

        case 'X':
            printf("Exiting...\n\r");
            break;
        }
    }
}
Пример #8
0
void serialPort::retry(){
    emit notConnected();
    this->run();
}