cfgWriteU8list don't support

All discussions related to the Loco Positioning system
Post Reply
justinleeyang
Expert
Posts: 186
Joined: Mon Dec 28, 2015 5:07 am

cfgWriteU8list don't support

Post by justinleeyang »

hi, arnaud:

cfgWriteU8list don't support, adjust the following code can support:

Code: Select all

bool cfgWriteU8list(ConfigField field, uint8_t list[], uint8_t length) {
    int pos = tlvFindType(&tlv, field);

    if (pos > -1) {
      //DEBUG_PRINTF("Witing the list is not supported!!\r\n");
      //tlv.data[pos+2] = value;
      // TODO: The list can vary in length, we need to take care of that :-(

      memcpy(&tlv.data[pos+2], list, length);
			
    } else {
      // Add new field at the end of the tlv
      tlv.data[cfgHeader->tlvSize] = field;
      tlv.data[cfgHeader->tlvSize+1] = length;
      memcpy(&tlv.data[cfgHeader->tlvSize+2], list, length);
      cfgHeader->tlvSize += 2 + length;
    }

    write_crc();
    eepromWrite(0, buffer, NUMBER_OF_BYTES_READ);
    //HAL_Delay(10);
		vTaskDelay(10);
    readData();
    return true;
}
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: cfgWriteU8list don't support

Post by arnaud »

Hi Justin,
Thanks for the code! This will add a new list as a duplicate at the end of the TLV. Can it be seen when reading the TLV?
justinleeyang
Expert
Posts: 186
Joined: Mon Dec 28, 2015 5:07 am

Re: cfgWriteU8list don't support

Post by justinleeyang »

hi, arnaud:

yeah, we can see the list type's value is adjusted, no duplicate.
Post Reply