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
+8 -3
View File
@@ -163,6 +163,8 @@ static bool bacnet_name_save(
char *str,
uint8_t length)
{
uint8_t buffer[NV_EEPROM_NAME_SIZE] = {0};
uint8_t i = 0;
if (bacnet_name_isvalid(encoding, length, str)) {
eeprom_bytes_write(
@@ -171,10 +173,13 @@ static bool bacnet_name_save(
eeprom_bytes_write(
NV_EEPROM_NAME_ENCODING(offset),
(uint8_t *)&encoding, 1);
for (i = 0; i < length; i++) {
buffer[i] = str[i];
}
eeprom_bytes_write(
NV_EEPROM_NAME_STRING(offset),
(uint8_t *)str,
length);
&buffer[0],
NV_EEPROM_NAME_SIZE);
return true;
}
@@ -274,7 +279,7 @@ void bacnet_name_init(
char *default_string)
{
(void)bacnet_name_save(offset, CHARACTER_UTF8,
default_string, strlen(default_string));
default_string, strlen(default_string));
}
void bacnet_name(