Corrected BACnet name in BDK port to clear end of string when new string is smaller than old string.

This commit is contained in:
skarg
2012-01-11 22:18:56 +00:00
parent 0fcd5132c2
commit 79f5caf850
+7 -2
View File
@@ -163,6 +163,8 @@ static bool bacnet_name_save(
char *str, char *str,
uint8_t length) uint8_t length)
{ {
uint8_t buffer[NV_EEPROM_NAME_SIZE] = {0};
uint8_t i = 0;
if (bacnet_name_isvalid(encoding, length, str)) { if (bacnet_name_isvalid(encoding, length, str)) {
eeprom_bytes_write( eeprom_bytes_write(
@@ -171,10 +173,13 @@ static bool bacnet_name_save(
eeprom_bytes_write( eeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset), NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *)&encoding, 1); (uint8_t *)&encoding, 1);
for (i = 0; i < length; i++) {
buffer[i] = str[i];
}
eeprom_bytes_write( eeprom_bytes_write(
NV_EEPROM_NAME_STRING(offset), NV_EEPROM_NAME_STRING(offset),
(uint8_t *)str, &buffer[0],
length); NV_EEPROM_NAME_SIZE);
return true; return true;
} }