Updated atmega project.

This commit is contained in:
skarg
2008-01-07 23:01:44 +00:00
parent a8e679f8d7
commit e79bd532af
4 changed files with 49 additions and 29 deletions
+3 -3
View File
@@ -806,9 +806,9 @@ typedef enum {
BACNET_APPLICATION_TAG_DATE = 10,
BACNET_APPLICATION_TAG_TIME = 11,
BACNET_APPLICATION_TAG_OBJECT_ID = 12,
BACNET_APPLICATION_TAG_RESERVED1 = 13,
BACNET_APPLICATION_TAG_RESERVED2 = 14,
BACNET_APPLICATION_TAG_RESERVED3 = 15,
BACNET_APPLICATION_TAG_RESERVE1 = 13,
BACNET_APPLICATION_TAG_RESERVE2 = 14,
BACNET_APPLICATION_TAG_RESERVE3 = 15,
MAX_BACNET_APPLICATION_TAG = 16
} BACNET_APPLICATION_TAG;
+3 -3
View File
@@ -105,12 +105,12 @@ extern "C" {
bool characterstring_init(
BACNET_CHARACTER_STRING * char_string,
uint8_t encoding,
char *value,
const char *value,
size_t length);
/* used for ANSI C-Strings */
bool characterstring_init_ansi(
BACNET_CHARACTER_STRING * char_string,
char *value);
const char *value);
bool characterstring_copy(
BACNET_CHARACTER_STRING * dest,
BACNET_CHARACTER_STRING * src);
@@ -124,7 +124,7 @@ extern "C" {
/* returns false if the string exceeds capacity */
bool characterstring_append(
BACNET_CHARACTER_STRING * char_string,
char *value,
const char *value,
size_t length);
/* This function sets a new length without changing the value.
If length exceeds capacity, no modification happens and
+15 -2
View File
@@ -101,6 +101,19 @@ MISRA C
Extra Options
Use command line options (not enabled)
Hopefully you find it useful!
Note: The BACnet Stack at Sourceforge source code has to be built
with lots of different compilers. The IAR compiler has particularly
strong (pedantic) source checking and generates several warnings when
compiling the source code. Unfortunately not all warnings can be
fixed by modifying the source code. Some warnings have therefore been
disabled in the project file.
Compiler Diagnostics:
(Pe550) I initilize all local variables as a best practice.
Linker Diagnostics:
(w31) The supplied standard libraries expect char parameters to
be unsigned (in functions such as strncpy(), etc.). It may
be possible to recompile the libraries with signed plain char's.
Steve Karg
Hopefully you find this code useful!
Steve Karg <skarg@users.sourceforge.net>
+28 -21
View File
@@ -59,13 +59,15 @@ void bitstring_set_bit(
if (byte_number < MAX_BITSTRING_BYTES) {
/* set max bits used */
if (bit_string->bits_used < (bit_number + 1))
if (bit_string->bits_used < (bit_number + 1)) {
bit_string->bits_used = bit_number + 1;
}
bit_mask = bit_mask << (bit_number - (byte_number * 8));
if (value)
if (value) {
bit_string->value[byte_number] |= bit_mask;
else
} else {
bit_string->value[byte_number] &= (~(bit_mask));
}
}
}
@@ -79,8 +81,9 @@ bool bitstring_bit(
if (bit_number < (MAX_BITSTRING_BYTES * 8)) {
bit_mask = bit_mask << (bit_number - (byte_number * 8));
if (bit_string->value[byte_number] & bit_mask)
if (bit_string->value[byte_number] & bit_mask) {
value = true;
}
}
return value;
@@ -113,13 +116,13 @@ int bitstring_bytes_used(
uint8_t bitstring_octet(
BACNET_BIT_STRING * bit_string,
uint8_t index)
uint8_t octet_index)
{
uint8_t octet = 0;
if (bit_string) {
if (index < MAX_BITSTRING_BYTES) {
octet = bit_string->value[index];
if (octet_index < MAX_BITSTRING_BYTES) {
octet = bit_string->value[octet_index];
}
}
@@ -163,10 +166,11 @@ bool bitstring_set_bits_used(
uint8_t bitstring_bits_capacity(
BACNET_BIT_STRING * bit_string)
{
if (bit_string)
if (bit_string) {
return (sizeof(bit_string->value) * 8);
else
} else {
return 0;
}
}
bool bitstring_copy(
@@ -193,7 +197,7 @@ bool bitstring_copy(
bool characterstring_init(
BACNET_CHARACTER_STRING * char_string,
uint8_t encoding,
char *value,
const char *value,
size_t length)
{
bool status = false; /* return value */
@@ -210,8 +214,9 @@ bool characterstring_init(
if (i < length) {
char_string->value[char_string->length] = value[i];
char_string->length++;
} else
} else {
char_string->value[i] = 0;
}
}
} else {
for (i = 0; i < MAX_CHARACTER_STRING_BYTES; i++) {
@@ -227,7 +232,7 @@ bool characterstring_init(
bool characterstring_init_ansi(
BACNET_CHARACTER_STRING * char_string,
char *value)
const char *value)
{
return characterstring_init(char_string, CHARACTER_ANSI_X34, value,
value ? strlen(value) : 0);
@@ -252,19 +257,20 @@ bool characterstring_same(
if (src && dest) {
if ((src->length == dest->length) && (src->encoding == dest->encoding)) {
same_status = true;
for (i = 0; i < src->length; i++) {
for (i = 0; (i < src->length) && same_status; i++) {
if (src->value[i] != dest->value[i]) {
same_status = false;
break;
}
}
}
} else if (src) {
if (src->length == 0)
if (src->length == 0) {
same_status = true;
}
} else if (dest) {
if (dest->length == 0)
if (dest->length == 0) {
same_status = true;
}
}
return same_status;
@@ -281,21 +287,22 @@ bool characterstring_ansi_same(
if ((dest->length == strlen(src)) &&
(dest->encoding == CHARACTER_ANSI_X34)) {
same_status = true;
for (i = 0; i < dest->length; i++) {
for (i = 0; (i < dest->length) && same_status; i++) {
if (src[i] != dest->value[i]) {
same_status = false;
break;
}
}
}
}
/* NULL matches an empty string in our world */
else if (src) {
if (strlen(src) == 0)
if (strlen(src) == 0) {
same_status = true;
}
} else if (dest) {
if (dest->length == 0)
if (dest->length == 0) {
same_status = true;
}
}
return same_status;
@@ -304,7 +311,7 @@ bool characterstring_ansi_same(
/* returns false if the string exceeds capacity */
bool characterstring_append(
BACNET_CHARACTER_STRING * char_string,
char *value,
const char *value,
size_t length)
{
size_t i; /* counter */