Esempio n. 1
0
int zwCmdProcessCenter()
{
    while ( 1 )
    {
        sleep ( 1 );
        ZwCommand* cmdTmp = cloneZwCmd ( gzwCmdList );

        if ( cmdTmp != NULL )
            if ( TCMRET_SUCCESS != deleteZwCmdFromListBySeqID ( &gzwCmdList,
                    cmdTmp->sequenceID ) )
            {
                tcmLog_error ( "CPC Delete eventtype %d from queue failed",
                               cmdTmp->sequenceID );
            }
            else
            {
                tcmLog_debug ( "CPC Delete eventtype %d message from queue ok",
                               cmdTmp->sequenceID );
            }

        if ( cmdTmp != NULL )
        {
            if ( TCMRET_SUCCESS != handleCmd ( cmdTmp ) )
            {
                tcmLog_error ( "CPC Handle CMD %d failed", cmdTmp->sequenceID );
            }
            else
            {
                tcmLog_notice ( "CPC Handle CMD %d ok", cmdTmp->sequenceID );
            }

        }
        freeZwCmd ( cmdTmp );
    }
}
Esempio n. 2
0
void CSI::serialEventHandler() {

	  while (cmdPort->available()) {
	    // get the new byte:
	    char inChar = (char)cmdPort->read();

	    if(cmd[0] != START_OF_FRAME && inChar != START_OF_FRAME){
	      return;
	    }

	    // add it to the cmd:
	    cmd[cmdIndex++] = inChar;
		
	    if(debug){
	    	 debugPort->print(inChar);
	     }

	    // if the incoming character is a newline, set a flag
	    // so the main loop can do something about it:
	    if (inChar == END_OF_FRAME || cmdIndex >= CMD_BYTE_LIMIT) {

			if(passthrough){
				for(int i=0; i<=cmdIndex; i++){
					modem->print(cmd[i]);	
				}
				//cmdIndex=0;
				//cmd[0] = ' ';
			}
			handleCmd(cmd);
	    }
	  }
}
Esempio n. 3
0
void CSI::modemEventHandler() {

	  while (modem->available()) {
	    // get the new byte:
	    char inChar = (char)modem->read();

	    if(cmdModem[0] != START_OF_FRAME && inChar != START_OF_FRAME){
	      return;
	    }

	    if(inChar == START_OF_FRAME){
	    	// Start or restart cmd
	    	cmdIndexModem = 0;
	    }
		cmdPort->print("m:");
	    cmdPort->println(inChar);
	    // add it to the cmd:
	    cmdModem[cmdIndexModem++] = inChar;

	    // if the incoming character is a ,
	    // then process the command
	    if (inChar == END_OF_FRAME || cmdIndexModem >= CMD_BYTE_LIMIT) {
			handleCmd(cmdModem);
	    }
	  }
}
const char* CommandProcessor::handleCommand(const char* pCmdStr)
{
    if(strlen(pCmdStr) >= MAX_CMD_LENGTH) {
        mOutputStr = CMD_LEN_ERR_STR;
    }
    else {
        // Copy command to str object, upper-case it and process it
        mInputStr = pCmdStr;
        handleCmd(mInputStr, mOutputStr);
    }

    return mOutputStr();
}
void ClientAJAKumoTCP::parseIncoming(uint8_t *buffer, uint8_t len) {
    if(buffer[0] == 0x01 && buffer[len-1] == 0x04) {
        uint16_t checksum = calculateChecksum(buffer, len-3);
        if(checksum == (buffer[len-3]<<8) | buffer[len-2]) {
            if(buffer[3] == 'E' && buffer[4] == 'R') {
                if(buffer[6] == '0' && buffer[7] == '0') {
                    if(_serialOutput > 1) {
                        Serial << "OK\n";
                    }
                } else {
                    if(_serialOutput > 1) {
                        Serial << "Received error response from AJA KUMO\n";
                    }
                }
            } else {
                char cmd[3];
                char parameter[11];
                char data[21];

                memset(cmd, 0, 3);
                memset(parameter, 0, 11);
                memset(data, 0, 21);

                cmd[0] = buffer[4];
                cmd[1] = buffer[3];

                uint8_t i = 5;
                uint8_t pos = 0;
                while(i++ < len-3) {
                    if(buffer[i] == 0x09 || pos++ == 10) {
                        strncpy(parameter, (char*)(buffer+i-pos), pos);
                        break;
                    }
                }


                strncpy(data, (char*)(buffer+i), len-i-4 > 20 ? 20 : len-i-4);

                handleCmd(cmd, parameter, data);
            }
        } else {
            if(_serialOutput > 1) {
                Serial << "Checksum mismatch!\n";
            }
        }
    } else {
        if(_serialOutput > 1)
            Serial << "ERROR: Malformed packet\n";
    }
}
Esempio n. 6
0
void main(void)
{
    
    leda_setup();
    sei();
    
    printf("LEDA");
    sendEndLine();
    
    for(;;)
    {
        enterSleep();
        
        while(usart_isData())
        handleCmd();
        
    } // End of forever loop.
    
} // End of main().
void PixelFlutTCPSource::handleClient(ClientInfo* client)
{
	size_t lastNlIdx = 0;
	size_t lastValidNlIdx = 0;

	do
	{
		size_t nlIdx = client->dataBuffer.find('\n', lastNlIdx + 1);

		if(nlIdx != std::string::npos)
		{
			char outCmd[OUT_CMD_MAX_LEN];

			size_t offset = 0;
			if(lastValidNlIdx > 0)
			{
				offset = lastValidNlIdx + 1;
			}

			const char* cmdStr = client->dataBuffer.c_str() + offset;
			int cmdStrLen = nlIdx - lastNlIdx + 1;

			int rc = handleCmd(cmdStr, cmdStrLen, outCmd, OUT_CMD_MAX_LEN);

			if(rc > 0)
			{
				send(client->clientSocket, outCmd, rc, 0);
			}
			//else if(rc < 0)
			//{
			//	LOG("Invalid cmd: %s", cmdStr);
			//}

			lastValidNlIdx = nlIdx;
		}

		lastNlIdx = nlIdx;

	}while(lastNlIdx != std::string::npos);

	if(lastValidNlIdx > 0)
		client->dataBuffer.erase(0, lastValidNlIdx + 1);
}
Esempio n. 8
0
void ROTankWire::Receive(int bytes) {
    //!!DONT PUT SERIAL.PRINTS IN HERE IT WILL SCREW UP WIRE COMM!!

    _wireRequest = "";
    _cmd = "";
    _cmdData = "";
    if(bytes == _wireReqLength) {
        while (Wire.available() > 0) {
            char c = Wire.read();
            _wireRequest.concat(c);
        }
        //Serial.print("Wire Request: ");
        //Serial.println(_wireRequest);
        _wireRequest.trim();
        if(_wireRequest.startsWith("/")) {
            _cmd = _wireRequest;
            Serial.print(F("cmd: "));
            Serial.println(_cmd);
        }
        else {
            _cmdData = _wireRequest;
            Serial.print(F("cmdData: "));
            Serial.println(_cmdData);
            String var = SplitString(_cmdData, '=', 0);
            String val = SplitString(_cmdData, '=', 1);

            if(val == "-") { // means null value sent in, so do nothing with cmd.
                //Transmit("-");
                return;
            }

            handleCmd(var, val);
        }
    }
    else {
        Serial.print(F("Unexpected number of bytes received: "));
        Serial.println(bytes);
    }
}
Esempio n. 9
0
void packetReceived(uint8_t* data, uint8_t len) {
	ee_magic = MAGIC16;
	handleCmd(data, len);
	ee_magic = 0;
}
Esempio n. 10
0
void loop()
{
    handleCmd();
}