Adding peripheral cfg by modifying the A2B Analyzer SDK sample application

Document created by Rajesh Alwar on Jun 14, 2019
Version 1Show Document
  • View in full screen mode

1. Ensure that you have slave plugins disabled.

//#define APP_LINK_STATIC_SLAVE_PLUGINS
#undef APP_LINK_STATIC_SLAVE_PLUGINS

2. Create the bin file using the A2B Analyzer Application (don't forget to export the periphcfg file as *.bin):

 

3. Add the following section of code that adds the periphPkg as exported file instead of A2B_NULL:

FILE* fp = (FILE*) A2B_NULL;
#define EEPROM "eepromforWGZ.bin"
a2b_Char* eepromPath = EEPROM;
a2b_UInt32 eepromLen;
a2b_Byte *eeprom;
a2b_UInt32 nRead;

/* Open the file */
fp = fopen(eepromPath, "rb");
if (fp == A2B_NULL) {
// handle error
}

/* Seek to the end */
if (fseek(fp, 0, SEEK_END) != 0) {
// handle error
}

/* Get the length of the file */
eepromLen = ftell(fp);
/*
if (eepromLen < 0) {
// handle error
}
*/

/* Seek back to the beginning */
if (fseek(fp, 0, SEEK_SET) != 0) {
// handle error
}

/* Allocate a buffer and read in the config */
eeprom = (a2b_Byte*)malloc(eepromLen);
nRead = fread(eeprom, 1, eepromLen, fp);
if ( eepromLen != nRead ) {
// handle error
}

/* Abandon the eeprom if anything failed */
/*
if (!ok) {
if (eeprom != NULL) {
free(eeprom);
eeprom = NULL;
}
eepromLen = 0;
}
*/

/* Close the file pointer */
if (fp != NULL) {
fclose(fp);
}

/* Attach the BDD information to the message */
discReq = (a2b_NetDiscovery*)a2b_msgGetPayload(msg);
discReq->req.bdd = &stackDcb->bdd;
discReq->req.periphPkg = eeprom;
discReq->req.pkgLen = eepromLen;

a2b_msgSetUserData(msg, (a2b_Handle)stackDcb, A2B_NULL);
status = a2b_msgRtrSendRequest(msg, A2B_NODEADDR_MASTER,
app_onDiscoveryComplete);
if ( A2B_FAILED(status) )
{
rc = APP_RC_FAILURE;
}
/* The message router adds it's own reference to the
* submitted message.
*/
a2b_msgUnref(msg);

 

4. Compile again and now the peripheral cfg should work with your SDK as well.

 

Adding the anlzr-app.c file for reference.

Attachments

    Outcomes