Ejemplo n.º 1
0
static int createCode(struct JsonNode *code) {
	int id = -1;
	int unit = -1;
	int state = -1;
	double itmp = -1;

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "down", &itmp) == 0)
		state=0;
	else if(json_find_number(code, "up", &itmp) == 0)
		state=1;

	if(id == -1 || unit == -1 || state == -1) {
		logprintf(LOG_ERR, "arctech_screen_old: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 31 || id < 0) {
		logprintf(LOG_ERR, "arctech_screen_old: invalid id range");
		return EXIT_FAILURE;
	} else if(unit > 15 || unit < 0) {
		logprintf(LOG_ERR, "arctech_screen_old: invalid unit range");
		return EXIT_FAILURE;
	} else {
		createMessage(id, unit, state);
		clearCode();
		createUnit(unit);
		createId(id);
		createState(state);
		createFooter();
		arctech_screen_old->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
static int createCode(struct JsonNode *code) {
	int systemcode = -1;
	int programcode = -1;
	int state = -1;
	double itmp = 0;

	if(json_find_number(code, "systemcode", &itmp) == 0)
		systemcode = (int)round(itmp);
	if(json_find_number(code, "programcode", &itmp) == 0)
		programcode = (int)round(itmp);
	if(json_find_number(code, "off", &itmp) == 0)
		state=0;
	else if(json_find_number(code, "on", &itmp) == 0)
		state=1;

	if(systemcode == -1 || programcode == -1 || state == -1) {
		logprintf(LOG_ERR, "rsl366: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(systemcode > 4 || systemcode < 0) {
		logprintf(LOG_ERR, "rsl366: invalid systemcode range");
		return EXIT_FAILURE;
	} else if(programcode > 4 || programcode < 0) {
		logprintf(LOG_ERR, "rsl366: invalid programcode range");
		return EXIT_FAILURE;
	} else {
		createMessage(systemcode, programcode, state);
		clearCode();
		createSystemCode(systemcode);
		createProgramCode(programcode);
		createState(state);
		createFooter();
		rsl366->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 3
0
static int createCode(struct JsonNode *code) {
	int systemcode = -1;
	int unitcode = -1;
	int state = -1;
	double itmp = -1;

	if(json_find_number(code, "systemcode", &itmp) == 0)
		systemcode = (int)round(itmp);
	if(json_find_number(code, "unitcode", &itmp) == 0)
		unitcode = (int)round(itmp);
	if(json_find_number(code, "off", &itmp) == 0)
		state=1;
	else if(json_find_number(code, "on", &itmp) == 0)
		state=0;

	if(systemcode == -1 || unitcode == -1 || state == -1) {
		logprintf(LOG_ERR, "pollin: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(systemcode > 31 || systemcode < 0) {
		logprintf(LOG_ERR, "pollin: invalid systemcode range");
		return EXIT_FAILURE;
	} else if(unitcode > 31 || unitcode < 0) {
		logprintf(LOG_ERR, "pollin: invalid unitcode range");
		return EXIT_FAILURE;
	} else {
		createMessage(systemcode, unitcode, state);
		clearCode();
		createSystemCode(systemcode);
		createUnitCode(unitcode);
		createState(state);
		createFooter();
		pollin->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 4
0
void FunctionExecutable::discardCode()
{
#if ENABLE(JIT)
    // These first two checks are to handle the rare case where
    // we are trying to evict code for a function during its
    // codegen.
    if (!m_jitCodeForCall && m_codeBlockForCall)
        return;
    if (!m_jitCodeForConstruct && m_codeBlockForConstruct)
        return;
#endif
    clearCode();
}
Ejemplo n.º 5
0
static int createCode(struct JsonNode *code) {
	int id = -1;
	int unit = -1;
	int state = -1;
	int all = 0;
	int learn = -1;
	double itmp = -1;

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "all", &itmp)	== 0)
		all = (int)round(itmp);
	if(json_find_number(code, "off", &itmp) == 0)
		state=0;
	else if(json_find_number(code, "on", &itmp) == 0)
		state=1;
	if(json_find_number(code, "learn", &itmp) == 0)
		learn = 1;

	if(all > 0 && learn > -1) {
		logprintf(LOG_ERR, "arctech_switch: all and learn cannot be combined");
		return EXIT_FAILURE;
	} else if(id == -1 || (unit == -1 && all == 0) || state == -1) {
		logprintf(LOG_ERR, "arctech_switch: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 67108863 || id < 1) {
		logprintf(LOG_ERR, "arctech_switch: invalid id range");
		return EXIT_FAILURE;
	} else if((unit > 15 || unit < 0) && all == 0) {
		logprintf(LOG_ERR, "arctech_switch: invalid unit range");
		return EXIT_FAILURE;
	} else {
		if(unit == -1 && all == 1) {
			unit = 0;
		}
		createMessage(id, unit, state, all, learn);
		createStart();
		clearCode();
		createId(id);
		createAll(all);
		createState(state);
		createUnit(unit);
		createFooter();
		arctech_switch->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 6
0
void loop() {   //Start our main Arduino Loop
 enableRFID();   //Enable the RFID card
 getRFIDTag();   //Reads the tag
 if(isCodeValid()) {  //Validates that the tag is good
   disableRFID();  //Puts the RFID reader in to low power mode
   sendCode();     //Sends the code read to the serial port
   delay(ITERATION_LENGTH);  //Debounce?
 } 
 else {
   disableRFID();  //Got a incomplete code.. 
   Serial.println("Got some noise");  
 }
 Serial.flush();
 clearCode();
} 
Ejemplo n.º 7
0
static int createCode(JsonNode *code) {
	int id = -1;
	int systemcode = -1;
	int unit = -1;
	int state = -1;
	double itmp = -1;

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "systemcode", &itmp) == 0)
		systemcode = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "off", &itmp) == 0)
		state=1;
	if(json_find_number(code, "on", &itmp) == 0)
		state=0;

	if(id == -1 || systemcode == -1 || unit == -1 || state == -1) {
		logprintf(LOG_ERR, "daycom: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 63 || id < 0) {
		logprintf(LOG_ERR, "daycom: invalid id range");
		return EXIT_FAILURE;
	} else if(systemcode > 16999 || systemcode < 0) {
		logprintf(LOG_ERR, "daycom: invalid systemcode range");
		return EXIT_FAILURE;
	} else if(unit > 7 || unit < 0) {
		logprintf(LOG_ERR, "daycom: invalid unit range");
		return EXIT_FAILURE;
	} else {
		createMessage(id, systemcode, unit, state);
		clearCode();
		createId(id);
		createSystemCode(systemcode);
		createState(state);
		createUnit(unit);
		createFooter();
		daycom->rawlen = RAW_LENGTH;
		state = 0;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 8
0
static int createCode(struct JsonNode *code) {
	int id = -1;
	int unit = -1;
	int state = -1;
	int all = 0;
	double itmp = -1;

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "all", &itmp) == 0)
		all = 1;
	if(json_find_number(code, "off", &itmp) == 0)
		state=0;
	if(json_find_number(code, "on", &itmp) == 0)
		state=1;

	if(id == -1 || (unit == -1 && all == 0) || (state == -1 && all == 1)) {
		logprintf(LOG_ERR, "beamish_switch: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 65535 || id < 1) {
		logprintf(LOG_ERR, "beamish_switch: invalid id range");
		return EXIT_FAILURE;
	} else if((unit > 4 || unit < 1) && all == 0) {
		logprintf(LOG_ERR, "beamish_switch: invalid unit range");
		return EXIT_FAILURE;
	} else {
		if(all == 1 && state == 1)
			unit = 5;
		if(all == 1 && state == 0)
			unit = 6;

		createMessage(id, unit, state, all);
		clearCode();
		createId(id);
		unit = map[unit];
		createUnit(unit);
		createFooter();
		beamish_switch->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 9
0
static int createCode(JsonNode *code) {
	double itmp = -1;
	int unit = -1, id = -1, learn = -1, state = -1, all = 0;

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "all", &itmp) == 0)
		all = (int)round(itmp);
	if(json_find_number(code, "learn", &itmp) == 0)
		learn = (int)round(itmp);
	if(json_find_number(code, "off", &itmp) == 0)
		state=0;
	else if(json_find_number(code, "on", &itmp) == 0)
		state=1;

	if(id==-1 || (unit==-1 && all==0) || state==-1) {
		logprintf(LOG_ERR, "quigg_gt7000: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 4095 || id < 0) {
		logprintf(LOG_ERR, "quigg_gt7000: invalid programm code id range");
		return EXIT_FAILURE;
	} else if((unit > 3 || unit < 0) && all == 0) {
		logprintf(LOG_ERR, "quigg_gt7000: invalid button code unit range");
		return EXIT_FAILURE;
	} else {
		if(unit == -1 && all == 1) {
			unit = 4;
		}
		quigg_gt7000->rawlen = RAW_LENGTH;
		createMessage(id, state, unit, all, learn);
		clearCode();
		createId(id);
		createUnit(unit);
		createState(state);
		createParity();
		createFooter();
	}
	return EXIT_SUCCESS;
}
Ejemplo n.º 10
0
/**
 * Blocking function, waits for and gets the RFID tag.
 */
boolean getRFIDTag() {
  byte next_byte;
  
  if(Serial.available() <= 0) return false;
  
  if((next_byte = Serial.read()) == START_BYTE) {      
    byte bytesread = 0; 
    while(bytesread < CODE_LEN) {
      if(Serial.available() > 0) { //wait for the next byte
          if((next_byte = Serial.read()) == STOP_BYTE) break;
          tag[bytesread++] = next_byte;
          tag[bytesread+1] = '\0';
      }
    }
    boolean codeValid = isCodeValid();
    if(isCodeValid()) return true;
    else {
      clearCode();
      return false;
    }
  } else return false;    
}
Ejemplo n.º 11
0
void FunctionExecutable::clearCodeIfNotCompiling()
{
    if (isCompiling())
        return;
    clearCode();
}
Ejemplo n.º 12
0
static int createCode(struct JsonNode *code) {
	int id = -1;
	int unit = -1;
	int state = -1;
	int all = 0;
	int dimlevel = -1;
	int learn = -1;
	int max = 15;
	int min = 0;
	double itmp = -1;

	if(json_find_number(code, "dimlevel-maximum", &itmp) == 0)
		max = (int)round(itmp);
	if(json_find_number(code, "dimlevel-minimum", &itmp) == 0)
		min = (int)round(itmp);

	if(json_find_number(code, "id", &itmp) == 0)
		id = (int)round(itmp);
	if(json_find_number(code, "unit", &itmp) == 0)
		unit = (int)round(itmp);
	if(json_find_number(code, "dimlevel", &itmp) == 0)
		dimlevel = (int)round(itmp);
	if(json_find_number(code, "all", &itmp) == 0)
		all = (int)round(itmp);
	if(json_find_number(code, "learn", &itmp) == 0)
		learn = 1;

	if(json_find_number(code, "off", &itmp) == 0)
		state=0;
	else if(json_find_number(code, "on", &itmp) == 0)
		state=1;

	if(all > 0 && learn > -1) {
		logprintf(LOG_ERR, "arctech_dimmer: all and learn cannot be combined");
		return EXIT_FAILURE;
	} else if(id == -1 || (unit == -1 && all == 0) || (dimlevel == -1 && state == -1)) {
		logprintf(LOG_ERR, "arctech_dimmer: insufficient number of arguments");
		return EXIT_FAILURE;
	} else if(id > 67108863 || id < 1) {
		logprintf(LOG_ERR, "arctech_dimmer: invalid id range");
		return EXIT_FAILURE;
	} else if((unit > 15 || unit < 0) && all == 0) {
		logprintf(LOG_ERR, "arctech_dimmer: invalid unit range");
		return EXIT_FAILURE;
	} else if(dimlevel != -1 && (dimlevel > max || dimlevel < min) ) {
		logprintf(LOG_ERR, "arctech_dimmer: invalid dimlevel range");
		return EXIT_FAILURE;
	} else if(dimlevel >= 0 && state == 0) {
		logprintf(LOG_ERR, "arctech_dimmer: dimlevel and off state cannot be combined");
		return EXIT_FAILURE;
	} else {
		if(unit == -1 && all == 1) {
			unit = 0;
		}
		if(dimlevel >= 0) {
			state = -1;
		}
		createMessage(id, unit, state, all, dimlevel, learn);
		createStart();
		clearCode();
		createId(id);
		createAll(all);
		createState(state);
		createUnit(unit);
		if(dimlevel > -1) {
			createDimlevel(dimlevel);
		}
		createFooter();
		arctech_dimmer->rawlen = RAW_LENGTH;
	}
	return EXIT_SUCCESS;
}