Changed all the C++ comments to C comments using comment.sh script.

This commit is contained in:
skarg
2006-02-19 01:32:09 +00:00
parent c80d26a894
commit dee63d45bc
76 changed files with 1856 additions and 1856 deletions
+12 -12
View File
@@ -23,7 +23,7 @@
*
*********************************************************************/
// Analog Input Objects customize for your use
/* Analog Input Objects customize for your use */
#include <stdbool.h>
#include <stdint.h>
@@ -31,13 +31,13 @@
#include "bacdef.h"
#include "bacdcode.h"
#include "bacenum.h"
#include "config.h" // the custom stuff
#include "config.h" /* the custom stuff */
#define MAX_ANALOG_INPUTS 7
// we simply have 0-n object instances. Yours might be
// more complex, and then you need validate that the
// given instance exists
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need validate that the */
/* given instance exists */
bool Analog_Input_Valid_Instance(uint32_t object_instance)
{
if (object_instance < MAX_ANALOG_INPUTS)
@@ -46,16 +46,16 @@ bool Analog_Input_Valid_Instance(uint32_t object_instance)
return false;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then count how many you have
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then count how many you have */
unsigned Analog_Input_Count(void)
{
return MAX_ANALOG_INPUTS;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then you need to return the instance
// that correlates to the correct index
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need to return the instance */
/* that correlates to the correct index */
uint32_t Analog_Input_Index_To_Instance(unsigned index)
{
return index;
@@ -81,7 +81,7 @@ int Analog_Input_Encode_Property_APDU(uint8_t * apdu,
int32_t array_index,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
int apdu_len = 0; // return value
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
float value = 3.14;
@@ -149,7 +149,7 @@ void testAnalogInput(Test * pTest)
BACNET_ERROR_CODE error_code;
// FIXME: we should do a lot more testing here...
/* FIXME: we should do a lot more testing here... */
len = Analog_Input_Encode_Property_APDU(&apdu[0],
instance,
PROP_OBJECT_IDENTIFIER,
+37 -37
View File
@@ -23,7 +23,7 @@
*
*********************************************************************/
// Analog Output Objects - customize for your use
/* Analog Output Objects - customize for your use */
#include <stdbool.h>
#include <stdint.h>
@@ -31,28 +31,28 @@
#include "bacdef.h"
#include "bacdcode.h"
#include "bacenum.h"
#include "config.h" // the custom stuff
#include "config.h" /* the custom stuff */
#include "wp.h"
#define MAX_ANALOG_OUTPUTS 4
// we choose to have a NULL level in our system represented by
// a particular value. When the priorities are not in use, they
// will be relinquished (i.e. set to the NULL level).
/* we choose to have a NULL level in our system represented by */
/* a particular value. When the priorities are not in use, they */
/* will be relinquished (i.e. set to the NULL level). */
#define AO_LEVEL_NULL 255
// When all the priorities are level null, the present value returns
// the Relinquish Default value
/* When all the priorities are level null, the present value returns */
/* the Relinquish Default value */
#define AO_RELINQUISH_DEFAULT 0
// Here is our Priority Array. They are supposed to be Real, but
// we don't have that kind of memory, so we will use a single byte
// and load a Real for returning the value when asked.
/* Here is our Priority Array. They are supposed to be Real, but */
/* we don't have that kind of memory, so we will use a single byte */
/* and load a Real for returning the value when asked. */
static uint8_t
Analog_Output_Level[MAX_ANALOG_OUTPUTS][BACNET_MAX_PRIORITY];
// Writable out-of-service allows others to play with our Present Value
// without changing the physical output
/* Writable out-of-service allows others to play with our Present Value */
/* without changing the physical output */
static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS];
// we need to have our arrays initialized before answering any calls
/* we need to have our arrays initialized before answering any calls */
static bool Analog_Ouput_Initialized = false;
void Analog_Output_Init(void)
@@ -62,7 +62,7 @@ void Analog_Output_Init(void)
if (!Analog_Ouput_Initialized) {
Analog_Ouput_Initialized = true;
// initialize all the analog output priority arrays to NULL
/* initialize all the analog output priority arrays to NULL */
for (i = 0; i < MAX_ANALOG_OUTPUTS; i++) {
for (j = 0; j < BACNET_MAX_PRIORITY; j++) {
Analog_Output_Level[i][j] = AO_LEVEL_NULL;
@@ -73,9 +73,9 @@ void Analog_Output_Init(void)
return;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then you need validate that the
// given instance exists
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need validate that the */
/* given instance exists */
bool Analog_Output_Valid_Instance(uint32_t object_instance)
{
Analog_Output_Init();
@@ -85,26 +85,26 @@ bool Analog_Output_Valid_Instance(uint32_t object_instance)
return false;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then count how many you have
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then count how many you have */
unsigned Analog_Output_Count(void)
{
Analog_Output_Init();
return MAX_ANALOG_OUTPUTS;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then you need to return the instance
// that correlates to the correct index
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need to return the instance */
/* that correlates to the correct index */
uint32_t Analog_Output_Index_To_Instance(unsigned index)
{
Analog_Output_Init();
return index;
}
// we simply have 0-n object instances. Yours might be
// more complex, and then you need to return the index
// that correlates to the correct instance number
/* we simply have 0-n object instances. Yours might be */
/* more complex, and then you need to return the index */
/* that correlates to the correct instance number */
unsigned Analog_Output_Instance_To_Index(uint32_t object_instance)
{
unsigned index = MAX_ANALOG_OUTPUTS;
@@ -157,7 +157,7 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
int len = 0;
int apdu_len = 0; // return value
int apdu_len = 0; /* return value */
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
float real_value = 1.414;
@@ -202,24 +202,24 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
apdu_len = encode_tagged_enumerated(&apdu[0], UNITS_PERCENT);
break;
case PROP_PRIORITY_ARRAY:
// Array element zero is the number of elements in the array
/* Array element zero is the number of elements in the array */
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
apdu_len =
encode_tagged_unsigned(&apdu[0], BACNET_MAX_PRIORITY);
// if no index was specified, then try to encode the entire list
// into one packet.
/* if no index was specified, then try to encode the entire list */
/* into one packet. */
else if (array_index == BACNET_ARRAY_ALL) {
object_index =
Analog_Output_Instance_To_Index(object_instance);
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
// FIXME: check if we have room before adding it to APDU
/* FIXME: check if we have room before adding it to APDU */
if (Analog_Output_Level[object_index][i] == AO_LEVEL_NULL)
len = encode_tagged_null(&apdu[apdu_len]);
else {
real_value = Analog_Output_Level[object_index][i];
len = encode_tagged_real(&apdu[apdu_len], real_value);
}
// add it if we have room
/* add it if we have room */
if ((apdu_len + len) < MAX_APDU)
apdu_len += len;
else {
@@ -263,11 +263,11 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
return apdu_len;
}
// returns true if successful
/* returns true if successful */
bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
bool status = false; // return value
bool status = false; /* return value */
unsigned int object_index = 0;
unsigned int priority = 0;
uint8_t level = AO_LEVEL_NULL;
@@ -278,7 +278,7 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
return false;
}
// decode the some of the request
/* decode the some of the request */
switch (wp_data->object_property) {
case PROP_PRESENT_VALUE:
if (wp_data->value.tag == BACNET_APPLICATION_TAG_REAL) {
@@ -293,9 +293,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
object_instance);
priority--;
Analog_Output_Level[object_index][priority] = level;
// if Out of Service is TRUE, then don't set the
// physical output. This comment may apply to the
// main loop (i.e. check out of service before changing output)
/* if Out of Service is TRUE, then don't set the */
/* physical output. This comment may apply to the */
/* main loop (i.e. check out of service before changing output) */
status = true;
} else if (priority == 6) {
*error_class = ERROR_CLASS_PROPERTY;
+26 -26
View File
@@ -48,7 +48,7 @@ static BACNET_FILE_LISTING BACnet_File_Listing[] = {
{0, "test.log"},
{1, "script.txt"},
{2, "bacenum.h"},
{0, NULL} // last file indication
{0, NULL} /* last file indication */
};
char *bacfile_name(uint32_t instance)
@@ -56,7 +56,7 @@ char *bacfile_name(uint32_t instance)
uint32_t index = 0;
char *filename = NULL;
// linear search for file instance match
/* linear search for file instance match */
while (BACnet_File_Listing[index].filename) {
if (BACnet_File_Listing[index].instance == instance) {
filename = BACnet_File_Listing[index].filename;
@@ -77,7 +77,7 @@ uint32_t bacfile_count(void)
{
uint32_t index = 0;
// linear search for file instance match
/* linear search for file instance match */
while (BACnet_File_Listing[index].filename) {
index++;
}
@@ -90,7 +90,7 @@ uint32_t bacfile_index_to_instance(unsigned find_index)
uint32_t instance = BACNET_MAX_INSTANCE + 1;
uint32_t index = 0;
// bounds checking...
/* bounds checking... */
while (BACnet_File_Listing[index].filename) {
if (index == find_index) {
instance = BACnet_File_Listing[index].instance;
@@ -141,7 +141,7 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
int32_t array_index,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
int apdu_len = 0; // return value
int apdu_len = 0; /* return value */
char text_string[32] = { "" };
BACNET_CHARACTER_STRING char_string;
@@ -173,18 +173,18 @@ int bacfile_encode_property_apdu(uint8_t * apdu,
bacfile_file_size(object_instance));
break;
case PROP_MODIFICATION_DATE:
// FIXME: get the actual value
/* FIXME: get the actual value */
apdu_len = encode_tagged_date(&apdu[0],
2005, 12, 25, 7 /* sunday */ );
// FIXME: get the actual value
/* FIXME: get the actual value */
apdu_len += encode_tagged_time(&apdu[apdu_len], 12, 0, 0, 0);
break;
case PROP_ARCHIVE:
// FIXME: get the actual value: note it may be inverse...
/* FIXME: get the actual value: note it may be inverse... */
apdu_len = encode_tagged_boolean(&apdu[0], true);
break;
case PROP_READ_ONLY:
// FIXME: get the actual value
/* FIXME: get the actual value */
apdu_len = encode_tagged_boolean(&apdu[0], true);
break;
case PROP_FILE_ACCESS_METHOD:
@@ -205,7 +205,7 @@ uint32_t bacfile_instance(char *filename)
uint32_t index = 0;
uint32_t instance = BACNET_MAX_INSTANCE + 1;
// linear search for filename match
/* linear search for filename match */
while (BACnet_File_Listing[index].filename) {
if (strcmp(BACnet_File_Listing[index].filename, filename) == 0) {
instance = BACnet_File_Listing[index].instance;
@@ -218,37 +218,37 @@ uint32_t bacfile_instance(char *filename)
}
#if TSM_ENABLED
// this is one way to match up the invoke ID with
// the file ID from the AtomicReadFile request.
// Another way would be to store the
// invokeID and file instance in a list or table
// when the request was sent
/* this is one way to match up the invoke ID with */
/* the file ID from the AtomicReadFile request. */
/* Another way would be to store the */
/* invokeID and file instance in a list or table */
/* when the request was sent */
uint32_t bacfile_instance_from_tsm(uint8_t invokeID)
{
BACNET_NPDU_DATA npdu_data = { 0 }; // dummy for getting npdu length
BACNET_NPDU_DATA npdu_data = { 0 }; /* dummy for getting npdu length */
BACNET_CONFIRMED_SERVICE_DATA service_data = { 0 };
uint8_t service_choice = 0;
uint8_t *service_request = NULL;
uint16_t service_request_len = 0;
BACNET_ADDRESS dest; // where the original packet was destined
uint8_t pdu[MAX_PDU] = { 0 }; // original sent packet
uint16_t pdu_len = 0; // original packet length
uint16_t len = 0; // apdu header length
BACNET_ADDRESS dest; /* where the original packet was destined */
uint8_t pdu[MAX_PDU] = { 0 }; /* original sent packet */
uint16_t pdu_len = 0; /* original packet length */
uint16_t len = 0; /* apdu header length */
BACNET_ATOMIC_READ_FILE_DATA data = { 0 };
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; // return value
uint32_t object_instance = BACNET_MAX_INSTANCE + 1; /* return value */
bool found = false;
int apdu_offset = 0;
found = tsm_get_transaction_pdu(invokeID, &dest, &pdu[0], &pdu_len);
if (found) {
apdu_offset = npdu_decode(&pdu[0], // data to decode
NULL, // destination address - get the DNET/DLEN/DADR if in there
NULL, // source address - get the SNET/SLEN/SADR if in there
&npdu_data); // amount of data to decode
apdu_offset = npdu_decode(&pdu[0], /* data to decode */
NULL, /* destination address - get the DNET/DLEN/DADR if in there */
NULL, /* source address - get the SNET/SLEN/SADR if in there */
&npdu_data); /* amount of data to decode */
if (!npdu_data.network_layer_message &&
((pdu[apdu_offset] & 0xF0) ==
PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
len = apdu_decode_confirmed_service_request(&pdu[apdu_offset], // APDU data
len = apdu_decode_confirmed_service_request(&pdu[apdu_offset], /* APDU data */
pdu_len - apdu_offset,
&service_data,
&service_choice, &service_request, &service_request_len);
+7 -7
View File
@@ -51,18 +51,18 @@ extern "C" {
uint32_t bacfile_index_to_instance(unsigned find_index);
uint32_t bacfile_instance(char *filename);
#if TSM_ENABLED
// this is one way to match up the invoke ID with
// the file ID from the AtomicReadFile request.
// Another way would be to store the
// invokeID and file instance in a list or table
// when the request was sent
/* this is one way to match up the invoke ID with */
/* the file ID from the AtomicReadFile request. */
/* Another way would be to store the */
/* invokeID and file instance in a list or table */
/* when the request was sent */
uint32_t bacfile_instance_from_tsm(uint8_t invokeID);
#endif
// AtomicReadFile ACK helper
/* AtomicReadFile ACK helper */
bool bacfile_read_data(BACNET_ATOMIC_READ_FILE_DATA * data);
// handling for read property service
/* handling for read property service */
int bacfile_encode_property_apdu(uint8_t * apdu,
uint32_t object_instance,
BACNET_PROPERTY_ID property,
+44 -44
View File
@@ -107,7 +107,7 @@ bool Device_Set_Object_Instance_Number(uint32_t object_id)
bool Device_Valid_Object_Instance_Number(uint32_t object_id)
{
// BACnet allows for a wildcard instance number
/* BACnet allows for a wildcard instance number */
return ((Object_Instance_Number == object_id) ||
(object_id == BACNET_MAX_INSTANCE));
}
@@ -137,7 +137,7 @@ BACNET_DEVICE_STATUS Device_System_Status(void)
void Device_Set_System_Status(BACNET_DEVICE_STATUS status)
{
// FIXME: bounds check?
/* FIXME: bounds check? */
System_Status = status;
}
@@ -285,7 +285,7 @@ uint16_t Device_APDU_Timeout(void)
return APDU_Timeout;
}
// in milliseconds
/* in milliseconds */
void Device_Set_APDU_Timeout(uint16_t timeout)
{
APDU_Timeout = timeout;
@@ -311,8 +311,8 @@ void Device_Set_Database_Revision(uint8_t revision)
Database_Revision = revision;
}
// Since many network clients depend on the object list
// for discovery, it must be consistent!
/* Since many network clients depend on the object list */
/* for discovery, it must be consistent! */
unsigned Device_Object_List_Count(void)
{
unsigned count = 1;
@@ -339,7 +339,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
}
if (!status) {
// array index starts at 1, and 1 for the device object
/* array index starts at 1, and 1 for the device object */
object_index = array_index - 2;
if (object_index < Analog_Input_Count()) {
*object_type = OBJECT_ANALOG_INPUT;
@@ -426,14 +426,14 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance)
return name;
}
// return the length of the apdu encoded or -1 for error
/* return the length of the apdu encoded or -1 for error */
int Device_Encode_Property_APDU(uint8_t * apdu,
BACNET_PROPERTY_ID property,
int32_t array_index,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
int apdu_len = 0; // return value
int len = 0; // apdu len intermediate value
int apdu_len = 0; /* return value */
int len = 0; /* apdu len intermediate value */
BACNET_BIT_STRING bit_string;
BACNET_CHARACTER_STRING char_string;
unsigned i = 0;
@@ -480,31 +480,31 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
Application_Software_Version);
apdu_len = encode_tagged_character_string(&apdu[0], &char_string);
break;
// if you support time
//case PROP_LOCAL_TIME:
//t = time(NULL);
//my_tm = localtime(&t);
//apdu_len =
// encode_tagged_time(&apdu[0], my_tm->tm_hour, my_tm->tm_min,
// my_tm->tm_sec, 0);
//break;
// if you support date
//case PROP_LOCAL_DATE:
//t = time(NULL);
//my_tm = localtime(&t);
// month 1=Jan
// day = day of month
// wday 1=Monday...7=Sunday
//apdu_len = encode_tagged_date(&apdu[0],
// my_tm->tm_year+1900,
// my_tm->tm_mon + 1,
// my_tm->tm_mday, ((my_tm->tm_wday == 0) ? 7 : my_tm->tm_wday));
//break;
/* if you support time */
/*case PROP_LOCAL_TIME: */
/*t = time(NULL); */
/*my_tm = localtime(&t); */
/*apdu_len = */
/* encode_tagged_time(&apdu[0], my_tm->tm_hour, my_tm->tm_min, */
/* my_tm->tm_sec, 0); */
/*break; */
/* if you support date */
/*case PROP_LOCAL_DATE: */
/*t = time(NULL); */
/*my_tm = localtime(&t); */
/* month 1=Jan */
/* day = day of month */
/* wday 1=Monday...7=Sunday */
/*apdu_len = encode_tagged_date(&apdu[0], */
/* my_tm->tm_year+1900, */
/* my_tm->tm_mon + 1, */
/* my_tm->tm_mday, ((my_tm->tm_wday == 0) ? 7 : my_tm->tm_wday)); */
/*break; */
case PROP_PROTOCOL_VERSION:
apdu_len =
encode_tagged_unsigned(&apdu[0], Device_Protocol_Version());
break;
// BACnet Legacy Support
/* BACnet Legacy Support */
case PROP_PROTOCOL_CONFORMANCE_CLASS:
apdu_len = encode_tagged_unsigned(&apdu[0], 1);
break;
@@ -523,7 +523,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
not a list of objects that this device can access */
bitstring_init(&bit_string);
for (i = 0; i < MAX_ASHRAE_OBJECT_TYPE; i++) {
// initialize all the object types to not-supported
/* initialize all the object types to not-supported */
bitstring_set_bit(&bit_string, (uint8_t) i, false);
}
/* FIXME: indicate the objects that YOU support */
@@ -537,13 +537,13 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
break;
case PROP_OBJECT_LIST:
count = Device_Object_List_Count();
// Array element zero is the number of objects in the list
/* Array element zero is the number of objects in the list */
if (array_index == BACNET_ARRAY_LENGTH_INDEX)
apdu_len = encode_tagged_unsigned(&apdu[0], count);
// if no index was specified, then try to encode the entire list
// into one packet. Note that more than likely you will have
// to return an error if the number of encoded objects exceeds
// your maximum APDU size.
/* if no index was specified, then try to encode the entire list */
/* into one packet. Note that more than likely you will have */
/* to return an error if the number of encoded objects exceeds */
/* your maximum APDU size. */
else if (array_index == BACNET_ARRAY_ALL) {
for (i = 1; i <= count; i++) {
if (Device_Object_List_Identifier(i, &object_type,
@@ -552,8 +552,8 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
encode_tagged_object_id(&apdu[apdu_len],
object_type, instance);
apdu_len += len;
// assume next one is the same size as this one
// can we all fit into the APDU?
/* assume next one is the same size as this one */
/* can we all fit into the APDU? */
if ((apdu_len + len) >= MAX_APDU) {
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_NO_SPACE_FOR_OBJECT;
@@ -561,7 +561,7 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
break;
}
} else {
// error: internal error?
/* error: internal error? */
*error_class = ERROR_CLASS_SERVICES;
*error_code = ERROR_CODE_OTHER;
apdu_len = -1;
@@ -609,21 +609,21 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
return apdu_len;
}
// we can send an I-Am when our device ID changes
/* we can send an I-Am when our device ID changes */
extern bool I_Am_Request;
// returns true if successful
/* returns true if successful */
bool Device_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
{
bool status = false; // return value
bool status = false; /* return value */
if (!Device_Valid_Object_Instance_Number(wp_data->object_instance)) {
*error_class = ERROR_CLASS_OBJECT;
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
return false;
}
// decode the some of the request
/* decode the some of the request */
switch (wp_data->object_property) {
case PROP_OBJECT_IDENTIFIER:
if (wp_data->value.tag == BACNET_APPLICATION_TAG_OBJECT_ID) {
@@ -765,7 +765,7 @@ void testDevice(Test * pTest)
}
#ifdef TEST_DEVICE
// stubs to dependencies to keep unit test simple
/* stubs to dependencies to keep unit test simple */
unsigned Analog_Input_Count(void)
{
return 0;
+1 -1
View File
@@ -76,7 +76,7 @@ extern "C" {
const char *Device_Location(void);
bool Device_Set_Location(const char *name, size_t length);
// some stack-centric constant values - no set methods
/* some stack-centric constant values - no set methods */
uint8_t Device_Protocol_Version(void);
uint8_t Device_Protocol_Revision(void);
uint16_t Device_Max_APDU_Length_Accepted(void);