Esempio n. 1
0
static bool expbrdScan(void)
{
  uint8_t i = 0;
  bool status = false;

  if (owScan(&nBoards))
  {
    DEBUG_PRINT("Found %d memories.\n", nBoards);
  }
  else
  {
    DEBUG_PRINT("Scan [FAILED].\n");
  }

  for (i = 0; i < nBoards; i++)
  {
    if (owRead(i, EXPBRD_OW_ADDR, sizeof(ExpbrdData), (uint8_t *)&expbrdData[i]))
    {
      if (expbrdIsValid(&expbrdData[i]))
      {
        DEBUG_PRINT("Info board %i:\n", i);
        expbrdPrintData(&expbrdData[i]);
        status = true;
      }
    }
    else
    {
      DEBUG_PRINT("Reading board nr:%d [FAILED].\n", i);
    }
  }

  return status;
}
Esempio n. 2
0
void memInit(void)
{
  if(isInit)
    return;

  if (owScan(&nbrOwMems))
    isInit = true;
  else
    isInit = false;
  
  //Start the mem task
  xTaskCreate(memTask, MEM_TASK_NAME,
              MEM_TASK_STACKSIZE, NULL, MEM_TASK_PRI, NULL);
}
Esempio n. 3
0
static void enumerateDecks(void)
{
  uint8_t nDecks = 0;
  bool noError = true;

  owInit();

  if (owScan(&nDecks))
  {
    DECK_INFO_DBG_PRINT("Found %d deck memor%s.\n", nDecks, nDecks>1?"ies":"y");
  } else {
    DEBUG_PRINT("Error scanning for deck memories, "
                "no deck drivers will be initialised\n");
    nDecks = 0;
  }

#ifndef IGNORE_OW_DECKS
  for (int i = 0; i < nDecks; i++)
  {
    DECK_INFO_DBG_PRINT("Enumerating deck %i\n", i);
    if (owRead(i, 0, sizeof(deckInfos[0].raw), (uint8_t *)&deckInfos[i]))
    {
      if (infoDecode(&deckInfos[i]))
      {
        deckInfos[i].driver = findDriver(&deckInfos[i]);
        printDeckInfo(&deckInfos[i]);
      } else {
#ifdef DEBUG
        DEBUG_PRINT("Deck %i has corrupt OW memory. "
                    "Ignoring the deck in DEBUG mode.\n", i);
        deckInfos[i].driver = &dummyDriver;
#else
        DEBUG_PRINT("Deck %i has corrupt OW memory. "
                    "No driver will be initialized!\n", i);
        noError = false;
#endif
      }
    }
    else
    {
      DEBUG_PRINT("Reading deck nr:%d [FAILED]. "
                  "No driver will be initialized!\n", i);
      noError = false;
    }
  }
#else
  DEBUG_PRINT("Ignoring all OW decks because of compile flag.\n");
  nDecks = 0;
#endif

  // Add build-forced driver
  if (strlen(deck_force) > 0) {
    DEBUG_PRINT("DECK_FORCE=%s found\n", deck_force);
  	//split deck_force into multiple, separated by colons, if available 
    char delim[] = ":"; 

    char temp_deck_force[strlen(deck_force)]; 
    strcpy(temp_deck_force, deck_force); 
    char * token = strtok(temp_deck_force, delim); 
 
    while (token) { 
      deck_force = token; 

      const DeckDriver *driver = deckFindDriverByName(deck_force);
      if (!driver) {
        DEBUG_PRINT("WARNING: compile-time forced driver %s not found\n", deck_force);
      } else if (driver->init || driver->test) {
        if (nDecks <= DECK_MAX_COUNT)
        {
          nDecks++;
          deckInfos[nDecks - 1].driver = driver;
          DEBUG_PRINT("compile-time forced driver %s added\n", deck_force);
        } else {
          DEBUG_PRINT("WARNING: No room for compile-time forced driver\n");
        }
      }
      token = strtok(NULL, delim); 
	}
  }

  if (noError) {
    count = nDecks;
  }

  return;
}
Esempio n. 4
0
bool owTest()
{
  uint8_t nOwMem = 0;
  uint8_t nOwIter = 0;
  OwSerialNum sn;

  if (owScan(&nOwMem))
  {
    DEBUG_PRINT("Found %d.\n", nOwMem);
  }
  else
  {
    DEBUG_PRINT("Scan [FAILED].\n");
  }

  for (nOwIter = 0; nOwIter < nOwMem; nOwIter++)
  {
    if (owGetinfo(nOwIter, &sn))
    {
      DEBUG_PRINT("Serial 0x%X %X %X %X %X %X %X %X.\n",
                  sn.type, sn.id[0], sn.id[1], sn.id[2],
                  sn.id[3], sn.id[4], sn.id[5], sn.crc);
    }
    else
    {
      DEBUG_PRINT("Mem:%d Getinfo [FAILED].\n", nOwIter);
    }
  }

#ifdef OW_READ_TEST
  {
    static uint8_t testbuf[129];

    if (owRead(0, 0, OW_MAX_SIZE, testbuf))
    {
      for (nOwIter = 0; nOwIter < OW_MAX_SIZE; nOwIter++)
      {
        consolePrintf("%X ", testbuf[nOwIter]);
        testbuf[nOwIter] = nOwIter;
      }
      consolePrintf("\n");
    }
  }
#endif
#ifdef OW_WRITE_TEST
  if (owWrite(0, 0, sizeof(bqData), bqData))
  {
    DEBUG_PRINT("Write [OK].\n");
  }
  else
  {
    DEBUG_PRINT("Write [FAIL].\n");
  }
//  if (owWrite(1, 0, sizeof(dummyData2), dummyData2))
//  {
//    DEBUG_PRINT("Write [OK].\n");
//  }
//  else
//  {
//    DEBUG_PRINT("Write [FAIL].\n");
//  }
#endif

  return true;
}
static bool expbrdScan(void)
{
  uint8_t i = 0;
  bool status = false;
#if 1
  if (owScan(&nBoards))
  {
    DEBUG_PRINT("Found %d memories.\n", nBoards);
  }
  else
  {
    DEBUG_PRINT("Scan [FAILED].\n");
  }


#if 0
  expbrdData[0].header = EXPBRD_ID;
  expbrdData[0].vid    = EXPBRD_VID_BITCRAZE;
  expbrdData[0].pid    = EXPBRD_PID_LEDRING;
  expbrdData[0].crc = crcSlow( (uint8_t *)&expbrdData[0], sizeof(ExpbrdData) - 1);

  status = owWrite(0, EXPBRD_OW_ADDR, sizeof(ExpbrdData), (uint8_t *)&expbrdData[0]);

  if( status == true )
  {
	  DEBUG_PRINT("owWrite LED Ring OK\n");
  }
  else
  {
	  DEBUG_PRINT("owWrite LED Ring Fail\n");
  }
#endif



  for (i = 0; i < nBoards; i++)
  {
    if (owRead(i, EXPBRD_OW_ADDR, sizeof(ExpbrdData), (uint8_t *)&expbrdData[i]))
    {
      if (expbrdIsValid(&expbrdData[i]))
      {
        DEBUG_PRINT("Info board %i:\n", i);
        expbrdPrintData(&expbrdData[i]);
        status = true;
      }
    }
    else
    {
      DEBUG_PRINT("Reading board nr:%d [FAILED].\n", i);
    }
  }
#endif
  /*
  nBoards = 1;
  expbrdData[0].header = EXPBRD_ID;
  expbrdData[0].vid    = EXPBRD_VID_BITCRAZE;
  expbrdData[0].pid    = EXPBRD_PID_LEDRING;
  expbrdData[0].crc = crcSlow( (uint8_t *)&expbrdData[0], sizeof(ExpbrdData) - 1);
  */

  owScan(&nBoards);

  return status;
}