Exemplo n.º 1
0
bool ContextClosest::parseCmdArgs(int argc, char **argv, int skipFirstArgs){
	_argc = argc;
	_argv = argv;
	_skipFirstArgs = skipFirstArgs;
	if (_argc < 2) {
		setShowHelp(true);
		return false;
	}

	setProgram(_programNames[argv[0]]);

	_argsProcessed.resize(_argc - _skipFirstArgs, false);

	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		if (strcmp(_argv[_i], "-c") == 0) {
			//bypass intersect's use of the -c option, because -c
			//means writeCount for intersect, but means columns for map.
			if (!ContextBase::handle_c()) return false;
		}
        else if (strcmp(_argv[_i], "-d") == 0) {
           if (!handle_d()) return false;
        }
        else if (strcmp(_argv[_i], "-D") == 0) {
        	if (!handle_D()) return false;
        }
        else if (strcmp(_argv[_i], "-io") == 0) {
        	if (!handle_io()) return false;
        }
        else if (strcmp(_argv[_i], "-iu") == 0) {
        	if (!handle_iu()) return false;
        }
        else if (strcmp(_argv[_i], "-id") == 0) {
        	if (!handle_id()) return false;
        }
        else if (strcmp(_argv[_i], "-N") == 0) {
        	if (!handle_N()) return false;
        }
        else if (strcmp(_argv[_i], "-t") == 0) {
        	if (!handle_t()) return false;
        }
        else if (strcmp(_argv[_i], "-mdb") == 0) {
        	if (!handle_mdb()) return false;
        }

	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
Exemplo n.º 2
0
bool ContextSubtract::parseCmdArgs(int argc, char **argv, int skipFirstArgs) {
	for (_i=_skipFirstArgs; _i < argc; _i++) {
		if (isUsed(_i - _skipFirstArgs)) {
			continue;
		}
		if (strcmp(_argv[_i], "-f") == 0) {
			if (!handle_f()) return false;
		}
		if (strcmp(_argv[_i], "-A") == 0) {
			if (!handle_A()) return false;
		}
		if (strcmp(_argv[_i], "-N") == 0) {
			if (!handle_N()) return false;
		}
	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}
void ANDRUINO_NRF::receive_nrf() {


  network.update();                                      // Pump the network regularly
  while ( network.available() )  {                      // Is there anything ready for us?

    RF24NetworkHeader header;                            // If so, take a look at it
    network.peek(header);

    IF_SERIAL_DEBUG_NRF(printf_P(PSTR("---------------------------------\n\r")));
    IF_SERIAL_DEBUG_NRF(printf_P(PSTR("-->--RECEIVED--FROM--NODE: 0%o\n\r"), header.from_node));
    IF_SERIAL_DEBUG_NRF(printf_P(PSTR("---------------------------------\n\r")));


    //check if the received node is already inthe table (index_node>=0) or is not present (index_node = -1)
    short index_node =  search_nodeFlash(header.from_node);


    switch (header.type) {                             // Dispatch the message to the correct handler.
      //T and N has to be at the beginning, don't move them!
      case 'T': handle_T(header); break;
      case 'N': handle_N(header); break;
      case 'Y': handle_SYSTEM(header, index_node); break;
      case 'D': handle_DIGITAL(header, index_node, 0); break;  //DIGITAL PIN status
      case 'A': handle_ANALOG(header, index_node, 0); break;   //ANALOG PIN status

      case 'a': handle_ANALOG(header, index_node, 1); break;   //ANALOG PIN position
      case '1': handle_DIGITAL(header, index_node, 1); break;  //DIGITAL PIN mode (INPUT, OUTPUT)
      case 'd': handle_DIGITAL(header, index_node, 2); break;  //DIGITAL PIN position

      case 'V': handle_VARIABLE(header, index_node,0); break;   //VARIABLES PIN status      
      
      //     case 'R': send_active_nodes(header); break;              //send active node


      case 'S': /*This is a sleep payload, do nothing*/ break;

      default:
        IF_SERIAL_DEBUG_NRF(printf_P(PSTR("*** WARNING *** Unknown message type %c\n\r"), header.type));
        network.read(header, 0, 0);
        break;
    };
  }
}