bool CloudWatcherController::getConstants(CloudWatcherConstants *cwc) {
  bool r = getFirmwareVersion(cwc->firmwareVersion);

  if (!r) {
    return false;
  }

  r = getSerialNumber(&(cwc->internalSerialNumber));

  if (!r) {
    return false;
  }

  if (cwc->firmwareVersion[0] >= '3') {
    r = getElectricalConstants();

    if (!r) {
      return false;
    }
  }

  cwc->zenerVoltage = zenerConstant;
  cwc->ldrMaxResistance = LDRMaxResistance;
  cwc->ldrPullUpResistance = LDRPullUpResistance;
  cwc->rainBetaFactor = rainBeta;
  cwc->rainResistanceAt25 = rainResAt25;
  cwc->rainPullUpResistance = rainPullUpResistance;
  cwc->ambientBetaFactor = ambBeta;
  cwc->ambientResistanceAt25 = ambResAt25;
  cwc->ambientPullUpResistance = ambPullUpResistance;

  return true;
}
Esempio n. 2
0
bool QikFlat::getStartupData()
{
    bool rc1 = getFirmwareVersion();
    bool rc2 = getBrightness();

    return (rc1 && rc2);
}
bool CloudWatcherController::getSerialNumber(int *serialNumber) {
  int f = getFirmwareVersion();

  if (!f) {
    return false;
  }

  if (firmwareVersion[0] >= '3') {
    sendCloudwatcherCommand("K!");

    char inputBuffer[BLOCK_SIZE * 2];

    int r = getCloudWatcherAnswer(inputBuffer, 2);

    if (!r) {
      return false;
    }

    int res = sscanf(inputBuffer, "!K%d", serialNumber);

    if (res != 1) {
      return false;
    }
  } else {
    *serialNumber = -1;
  }

  return true;
}
Esempio n. 4
0
 FirmwareInfo
 Interface::getFirmwareInfo(void)
 {
   FirmwareInfo info;
   getFirmwareName(info);
   getFirmwareVersion(info);
   return info;
 }
Esempio n. 5
0
void MidiController::sendFirmwareVersion(){
  char* version = getFirmwareVersion();
  uint8_t len = strlen(version);
  uint8_t buffer[len+1];
  buffer[0] = SYSEX_FIRMWARE_VERSION;
  memcpy(buffer+1, version, len);
  sendSysEx(buffer, sizeof(buffer));
}
Esempio n. 6
0
bool FlipFlat::getStartupData()
{
    bool rc1 = getFirmwareVersion();
    bool rc2 = getStatus();
    bool rc3 = getBrightness();

    return (rc1 && rc2 && rc3);
}
Esempio n. 7
0
bool Starbook::Connect()
{
    handle = curl_easy_init();
    bool rc = Telescope::Connect();
    if (rc) {
        getFirmwareVersion();
    }
    return rc;
}
Esempio n. 8
0
boolean MFRC522::digitalSelfTestPass() {
  int i;
  byte n;

  byte selfTestResultV1[] = {0x00, 0xC6, 0x37, 0xD5, 0x32, 0xB7, 0x57, 0x5C,
                          0xC2, 0xD8, 0x7C, 0x4D, 0xD9, 0x70, 0xC7, 0x73,
                          0x10, 0xE6, 0xD2, 0xAA, 0x5E, 0xA1, 0x3E, 0x5A,
                          0x14, 0xAF, 0x30, 0x61, 0xC9, 0x70, 0xDB, 0x2E,
                          0x64, 0x22, 0x72, 0xB5, 0xBD, 0x65, 0xF4, 0xEC,
                          0x22, 0xBC, 0xD3, 0x72, 0x35, 0xCD, 0xAA, 0x41,
                          0x1F, 0xA7, 0xF3, 0x53, 0x14, 0xDE, 0x7E, 0x02,
                          0xD9, 0x0F, 0xB5, 0x5E, 0x25, 0x1D, 0x29, 0x79};
  byte selfTestResultV2[] = {0x00, 0xEB, 0x66, 0xBA, 0x57, 0xBF, 0x23, 0x95,
                          0xD0, 0xE3, 0x0D, 0x3D, 0x27, 0x89, 0x5C, 0xDE,
                          0x9D, 0x3B, 0xA7, 0x00, 0x21, 0x5B, 0x89, 0x82,
                          0x51, 0x3A, 0xEB, 0x02, 0x0C, 0xA5, 0x00, 0x49,
                          0x7C, 0x84, 0x4D, 0xB3, 0xCC, 0xD2, 0x1B, 0x81,
                          0x5D, 0x48, 0x76, 0xD5, 0x71, 0x61, 0x21, 0xA9,
                          0x86, 0x96, 0x83, 0x38, 0xCF, 0x9D, 0x5B, 0x6D,
                          0xDC, 0x15, 0xBA, 0x3E, 0x7D, 0x95, 0x3B, 0x2F};
  byte *selfTestResult;
  switch(getFirmwareVersion()) {
    case 0x91 :
      selfTestResult = selfTestResultV1;
      break;
    case 0x92 :
      selfTestResult = selfTestResultV2;
      break;
    default:
      return false;
  }

  reset();
  writeToRegister(FIFODataReg, 0x00);
  writeToRegister(CommandReg, MFRC522_MEM);
  writeToRegister(AutoTestReg, 0x09);
  writeToRegister(FIFODataReg, 0x00);
  writeToRegister(CommandReg, MFRC522_CALCCRC);

  // Wait for the self test to complete.
  i = 0xFF;
  do {
    n = readFromRegister(DivIrqReg);
    i--;
  } while ((i != 0) && !(n & 0x04));

  for (i=0; i < 64; i++) {
    if (readFromRegister(FIFODataReg) != selfTestResult[i]) {
      Serial.println(i);
      return false;
    }
  }
  return true;
}
bool CloudWatcherController::getFirmwareVersion(char *version) {  // Fallo en el documento, devuelve "!V", no "!N"
  int r = getFirmwareVersion();

  if (!r) {
    return false;
  }

  strcpy(version, firmwareVersion);

  return true;
}
bool CloudWatcherController::getValues(int *internalSupplyVoltage, int *ambientTemperature, int *ldrValue, int *rainSensorTemperature) {
  sendCloudwatcherCommand("C!");

  int f = getFirmwareVersion();

  if (!f) {
    return false;
  }

  int zenerV;
  int ambTemp = -10000;
  int ldrRes;
  int rainSensTemp;

  if (firmwareVersion[0] >= '3') {
    char inputBuffer[BLOCK_SIZE * 4];

    int r = getCloudWatcherAnswer(inputBuffer, 4);

    if (!r) {
      return false;
    }

    int res = sscanf(inputBuffer, "!6         %d!4         %d!5         %d", &zenerV, &ldrRes, &rainSensTemp);

    if (res != 3) {
      return false;
    }
  } else {
    char inputBuffer[BLOCK_SIZE * 5];

    int r = getCloudWatcherAnswer(inputBuffer, 5);

    if (!r) {
      return false;
    }

    int res = sscanf(inputBuffer, "!6         %d!3         %d!4         %d!5         %d", &zenerV, &ambTemp, &ldrRes, &rainSensTemp);

    if (res != 3) {
      return false;
    }
  }

  *internalSupplyVoltage = zenerV;
  *ambientTemperature = ambTemp;
  *ldrValue = ldrRes;
  *rainSensorTemperature = rainSensTemp;

  return true;
}
Esempio n. 11
0
bool StarbookDriver::Connect()
{
    failed_res = 0;
    last_known_state = starbook::UNKNOWN;
    bool rc = Telescope::Connect();
    if (rc) {
        getFirmwareVersion();
        // TODO: resolve this in less hacky way https://github.com/indilib/indi/issues/810
        saveConfig(false, "DEVICE_ADDRESS");
    } else {
        LOG_ERROR("Connection failed");
    }
    return rc;
}
Esempio n. 12
0
bool emulate_tag_init()
{
	uint32_t versiondata;

	wake_up();

	versiondata = getFirmwareVersion();
    if(!versiondata)
    {
        return false;
    }

    return SAMConfig();
}
Esempio n. 13
0
void main(void)
{

#ifdef NFC_DEMO_DEBUG
  printf("Hello!\n");
#endif

  begin();

  versiondata = getFirmwareVersion();

  if (! versiondata)
  {

#ifdef NFC_DEMO_DEBUG
    printf("Didn't find PN53x board\n");
#endif
    while (1); // halt
  }

#ifdef NFC_DEMO_DEBUG
  // Got ok data, print it out!
  printf("Found chip PN5");
  printf("%d\n",(versiondata>>24 & 0xFF));
  printf("Firmware ver. ");
  printf("%d\n",((versiondata>>16) & 0xFF));
  printf(".");
  printf("%d\n",((versiondata>>8) & 0xFF));
  printf("Supports ");
  printf("%d\n",(versiondata & 0xFF));
#endif
  // configure board to read RFID tags and cards
  SAMConfig();
  printf("init is ok\n");
  while(1)
  {
	// Configure PN532 as Peer to Peer Initiator in active mode
	if(configurePeerAsInitiator(PN532_BAUDRATE_424K)) //if connection is error-free
	{
		//trans-receive data
		if(initiatorTxRx(DataOut,DataIn))
		{
			#ifdef NFC_DEMO_DEBUG
			printf("Data Sent and Received: %d\n",DataIn);
			#endif
		}
	}
  }
}
Esempio n. 14
0
void LiquidCrystal::begin(uint8_t cols, uint8_t lines, uint8_t dotsize) {
  _displayfunction = LCD_4BITMODE | LCD_1LINE | LCD_5x8DOTS;
  Wire.begin();
  delay(200);
  
  resetDisplay();
  if (lines > 1) {
    _displayfunction |= LCD_2LINE;
  }

  // for some 1 line displays you can select a 10 pixel high font
  if ((dotsize != 0) && (lines == 1)) {
    _displayfunction |= LCD_5x10DOTS;
  }

  // finally, set # lines, font size, etc.
  command(LCD_FUNCTIONSET | _displayfunction);  

  // turn the display on with no cursor or blinking default
  _displaycontrol = LCD_DISPLAYON | LCD_CURSOROFF | LCD_BLINKOFF;  
  display();

  // clear it off
  clear();
  home();

  // Initialize to default text direction (for romance languages)
  _displaymode = LCD_ENTRYLEFT | LCD_ENTRYSHIFTDECREMENT;
  // set the entry mode
  command(LCD_ENTRYMODESET | _displaymode);
  delay(50); // OLED needs some more time to initialize
  
  _firmware_version = getFirmwareVersion();
  
  if(_firmware_version >= 2)
  {
	  Wire.beginTransmission(_addr);
	  Wire.write(0xfd); // Set cols/lines
	  Wire.write(cols);
	  Wire.write(lines);
	  Wire.endTransmission();
  }
  
  delay(50);
}
Esempio n. 15
0
void omsMAXv::initialize(const char* portName, int numAxes, int cardNo, const char* initString, int prio,
                int stackSz, unsigned int vmeAddr, int intrVector, int level, epicsAddressType vmeAddrType, int paramCount)
{

    const char* functionName = "initialize";
    long status;
    void* probeAddr;

    Debug(32, "omsMAXv::initialize: start initialize\n" );

    controllerType = epicsStrDup("MAXv");

    // TODO check if cardNo has already been used
    this->cardNo = cardNo;
    if(cardNo < 0 || cardNo >= MAXv_NUM_CARDS){
        printf("invalid cardNo: %d", cardNo);
        return;
    }

    epicsUInt8 *startAddr;
    epicsUInt8 *endAddr;
    epicsUInt32 boardAddrSize = 0;

    if (vmeAddrType == atVMEA16)
        boardAddrSize = 0x1000;
    else if (vmeAddrType == atVMEA24)
        boardAddrSize = 0x10000;
    else if (vmeAddrType == atVMEA32)
        boardAddrSize = 0x1000000;

    // if vmeAddr == 1 Setup/Config is used and not Config2
    if (vmeAddr == 1)
        probeAddr = baseAddress + (cardNo * boardAddrSize);
    else
        probeAddr = (void*) vmeAddr;

    startAddr = (epicsUInt8 *) probeAddr;
    endAddr = startAddr + boardAddrSize;

    Debug(64, "motor_init: devNoResponseProbe() on addr %p\n", probeAddr);

    /* Scan memory space to assure card id */
    while (startAddr < endAddr) {
        status = devNoResponseProbe(vmeAddrType, (size_t) startAddr, 2);
        if (status != S_dev_addressOverlap) {
            errlogPrintf("%s:%s:%s: Card NOT found in specified address range! \n",
                                driverName, functionName, portName);
            enabled = false;
            return;
        }
        startAddr += (boardAddrSize / 10);
    }

    status = devRegisterAddress(controllerType, vmeAddrType,
                                (size_t) probeAddr, boardAddrSize,
                                (volatile void **) &pmotor);
    Debug(64, "motor_init: devRegisterAddress() status = %d\n", (int) status);

    if (status) {
        errlogPrintf("%s:%s:%s: Can't register address 0x%lx \n",
                        driverName, functionName, portName, (long unsigned int) probeAddr);
        return;
    }

    Debug(64, "motor_init: pmotor = %p\n", pmotor);

    int loopCount=15;
    while (loopCount && (pmotor->firmware_status.Bits.initializing == 1)){
        Debug(1, "MAXv port %s still initializing; status = 0x%x\n",
                portName, (unsigned int) pmotor->firmware_status.All);
        epicsThreadSleep(0.2);
        --loopCount;
    }

    Debug(64, "motor_init: check if card is ready\n");

    if (pmotor->firmware_status.Bits.running == 0)
        errlogPrintf("MAXv port %s is NOT running; status = 0x%x\n",
                portName, (unsigned int) pmotor->firmware_status.All);

    Debug(64, "motor_init: init card\n");

    FIRMWARE_STATUS fwStatus;
    fwStatus.All = pmotor->firmware_status.All;
    Debug(64, "motor_init: firmware status register: 0x%x\n", fwStatus.All);

    pmotor->IACK_vector = intrVector;

    pmotor->status1_flag.All = 0xFFFFFFFF;
    pmotor->status2_flag = 0xFFFFFFFF;
    /* Disable all interrupts */
    pmotor->status1_irq_enable.All = 0;
    pmotor->status2_irq_enable = 0;

    Debug(64, "motor_init: clear all interrupt\n");
    //sendOnly("IC");

    Debug(64, "motor_init: firmware version\n");

    /* get FirmwareVersion */
    if(getFirmwareVersion() != asynSuccess) {
        errlogPrintf("%s:%s:%s: unable to talk to controller card %d\n",
                        driverName, functionName, portName, cardNo);
        return;
    }

    if (fwMinor < 30 ){
        errlogPrintf("%s:%s:%s: This Controllers Firmware Version %d.%d is not supported, version 1.30 or higher is mandatory\n",
                        driverName, functionName, portName, fwMajor, fwMinor);
    }

    Debug(64, "motor_init: send init string\n");

    if( Init(initString, 1) != asynSuccess) {
        errlogPrintf("%s:%s:%s: unable to send initstring to controller card %d\n",
                        driverName, functionName, portName, cardNo);
        return;
    }

    useWatchdog = true;

    if (watchdogOK()) {
        Debug(64, "motor_init: enable interrupts ( vector=%d, level=%d) \n", intrVector, level);
        /* Enable interrupt-when-done if selected */
        if (intrVector) motorIsrSetup((unsigned int)intrVector, level);
    }
    else
        return;

    if (epicsAtExit(&omsMAXv::resetOnExit, this))
        errlogPrintf("%s:%s:%s: card %d, unable to register exit function\n",
                        driverName, functionName, portName, cardNo);

    return;
}
/**
   Like most memory stuff this won't work across DLL's in windows,
   it should work fine in linux or with static library files in windows.
**/
AREXPORT std::string ArRobotConfigPacketReader::buildString(void) const
{
  std::string ret;

  char line[32000];
  sprintf(line, "General information:\n");
  ret += line;
  sprintf(line, "Robot is type '%s' subtype '%s'\n",
	     getType(), getSubType());
  ret += line;
  sprintf(line, "serial number '%s' name '%s'\n", 
	     getSerialNumber(), getName());
  ret += line;
  sprintf(line, "firmware version '%s'\n",
	  getFirmwareVersion());
  ret += line;
  sprintf(line, "Intrinsic properties and unsettable maxes:\n");
  ret += line;
  sprintf(line, "TransVelTop %d TransAccelTop %d\n", 
	     getTransVelTop(), getTransAccelTop());
  ret += line;
  sprintf(line, "RotVelTop %d RotAccelTop %d\n", 
	     getRotVelTop(), getRotAccelTop());
  ret += line;
  if (myRobot->hasLatVel())
  {
    sprintf(line, "LatVelTop %d LatAccelTop %d\n", 
	    getLatVelTop(), getLatAccelTop());
    ret += line;
  }
  sprintf(line, "PWMMax %d ResetBaud %s\n", getPwmMax(),
	     ArUtil::convertBool(getResetBaud()));
  ret += line;
  sprintf(line, "Current values:\n");
  ret += line;
  sprintf(line, "TransVelMax %d TransAccel %d TransDecel %d\n", 
	     getTransVelMax(), getTransAccel(), getTransDecel());
  ret += line;  
  sprintf(line, "RotVelMax %d RotAccel %d RotDecel %d\n", 
	     getRotVelMax(), getRotAccel(), getRotDecel());
  ret += line;
  if (myRobot->hasLatVel())
  {
    sprintf(line, "LatVelMax %d LatAccel %d LatDecel %d\n", 
	    getLatVelMax(), getLatAccel(), getLatDecel());
    ret += line;  
  }
  sprintf(line, "Accessories:\n");
  ret += line;  
  sprintf(line, 
	  "Gripper %s FrontSonar %s RearSonar %s Charger %d GyroType %d\n", 
	  ArUtil::convertBool(getHasGripper()), 
	  ArUtil::convertBool(getFrontSonar()), 
	  ArUtil::convertBool(getRearSonar()), 
	  getHasCharger(),
	  getGyroType());
  ret += line;  
  sprintf(line, "FrontBumps %d RearBumps %d\n", 
	     getFrontBumps(), getRearBumps());
  ret += line;  
  sprintf(line, "Settings:\n");
  ret += line;  
  sprintf(line, "SipCycle %d SonarCycle %d HostBaud %d Aux1Baud %d\n", getSipCycleTime(), getSonarCycle(), getHostBaud(), getAux1Baud());
  ret += line;  
  sprintf(line, "StallVal %d StallCount %d RevCount %d Watchdog %d\n",
	     getStallVal(), getStallCount(), getRevCount(), getWatchdog());
  ret += line;  
  sprintf(line, "GyroRateLimit %d\n",
	  getGyroRateLimit());
  ret += line;  
  sprintf(line, "JoyVel %d JoyRVel %d NormalMotorPackets %s\n", getJoyVel(), getJoyRotVel(), ArUtil::convertBool(getNormalMPacs()));
  ret += line;  
  sprintf(line, "PID Settings:\n");
  ret += line;  
  sprintf(line, "Trans kp %d kv %d ki %d\n", getTransKP(), 
	     getTransKV(), getTransKI());
  ret += line;  
  sprintf(line, "Rot kp %d kv %d ki %d\n", getRotKP(), getRotKV(),
	     getRotKI());
  ret += line;  
  sprintf(line, "Other:\n");
  ret += line;  
  sprintf(line, "DriftFactor %d KinematicsDelay %d\n", getDriftFactor(),
	  getKinematicsDelay());
  ret += line;  
  sprintf(line, "Aux2Baud setting %d Aux3Baud setting %d\n", getAux2Baud(), getAux3Baud());
  ret += line;  
  sprintf(line, "PDBPort setting %d\n", getPDBPort());
  ret += line;  
  sprintf(line, "TicksMM %d GyroCW %d GyroCCW %d\n", getTicksMM(),
	  getGyroCW(), getGyroCCW());
  ret += line;  
  sprintf(line, "ShutdownVoltage %d PowerbotChargeTreshold %d\n", 
	  getShutdownVoltage(), getPowerbotChargeThreshold());
  ret += line;  

  char buf[128];
  int i, j;
  unsigned int value = getPowerBits();
  int bit;
  buf[0] = '\0';
  for (j = 0, bit = 1; j < 16; ++j, bit *= 2)
  {
    if (j == 8)
      sprintf(buf, "%s ", buf);
    if (value & bit)
      sprintf(buf, "%s%d", buf, 1);
    else
      sprintf(buf, "%s%d", buf, 0);
  }

  sprintf(line, "HighTempShutdown %d PowerBits %s\n",
	  getHighTemperatureShutdown(), buf);
  ret += line;  

  return ret;
}
Esempio n. 17
0
int main(void)
{
	uint32_t versiondata;
    uint32_t id;

#ifdef NFC_DEMO_DEBUG
    printf("Hello!\n");
#endif
begin();
        versiondata = getFirmwareVersion();
        if (! versiondata) 
        {
                #ifdef NFC_DEMO_DEBUG
                        printf("Didn't find PN53x board\n");
                #endif
                while (1); // halt
        }
        #ifdef NFC_DEMO_DEBUG
        // Got ok data, print it out!
        printf("Found chip PN5"); 
        printf("%x\n",((versiondata>>24) & 0xFF));
        printf("Firmware ver. "); 
        printf("%d",((versiondata>>16) & 0xFF));
        printf("."); 
        printf("%d\n",((versiondata>>8) & 0xFF));
        printf("Supports "); 
        printf("%x\n",(versiondata & 0xFF));
        #endif
        // configure board to read RFID tags and cards
        SAMConfig();
        
        while(1)
        {
                // look for MiFare type cards
                id = readPassiveTargetID(PN532_MIFARE_ISO14443A);
                if (id != 0) 
                {
                #ifdef NFC_DEMO_DEBUG
                        printf("Read card #%d\n",id); 
                        CURL *curl;
				  CURLcode res;
 
				  /* In windows, this will init the winsock stuff */ 
				  curl_global_init(CURL_GLOBAL_ALL);
 
				  /* get a curl handle */ 
				  curl = curl_easy_init();
				  if(curl) {
					/* First set the URL that is about to receive our POST. This URL can
					   just as well be a https:// URL if that is what should receive the
					   data. */ 
					curl_easy_setopt(curl, CURLOPT_URL, "http://203.42.134.77/api/rfid");
					/* Now specify the POST data */ 
					curl_easy_setopt(curl, CURLOPT_POSTFIELDS, "userID=123&rfid=2345123");
 
					/* Perform the request, res will get the return code */ 
					res = curl_easy_perform(curl);
					/* Check for errors */ 
					if(res != CURLE_OK)
					  fprintf(stderr, "curl_easy_perform() failed: %s\n",
							  curl_easy_strerror(res));
 
					/* always cleanup */ 
					curl_easy_cleanup(curl);
				  }
				  curl_global_cleanup();
                        
                #endif
                }
        }
  
  return 0;
}