converted any C++ comments to C comments using script.
This commit is contained in:
@@ -323,7 +323,7 @@ int main(
|
|||||||
|
|
||||||
/* blink LEDs, Turn on or off outputs, etc */
|
/* blink LEDs, Turn on or off outputs, etc */
|
||||||
}
|
}
|
||||||
// Dummy return
|
/* Dummy return */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "arf.h"
|
#include "arf.h"
|
||||||
|
|
||||||
// Free is redefined as a macro, but Perl does not like that.
|
/* Free is redefined as a macro, but Perl does not like that. */
|
||||||
#undef free
|
#undef free
|
||||||
|
|
||||||
/* global variables used in this file */
|
/* global variables used in this file */
|
||||||
@@ -22,7 +22,7 @@ static bool isAtomicWriteFileHandlerRegistered = false;
|
|||||||
static bool isAtomicReadFileHandlerRegistered = false;
|
static bool isAtomicReadFileHandlerRegistered = false;
|
||||||
|
|
||||||
/****************************************/
|
/****************************************/
|
||||||
// Logging Support
|
/* Logging Support */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
#define MAX_ERROR_STRING 128
|
#define MAX_ERROR_STRING 128
|
||||||
#define NO_ERROR "No Error"
|
#define NO_ERROR "No Error"
|
||||||
@@ -59,7 +59,7 @@ static void __LogAnswer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**************************************/
|
/**************************************/
|
||||||
// error handlers
|
/* error handlers */
|
||||||
/*************************************/
|
/*************************************/
|
||||||
static void MyAbortHandler(
|
static void MyAbortHandler(
|
||||||
BACNET_ADDRESS * src,
|
BACNET_ADDRESS * src,
|
||||||
@@ -112,7 +112,7 @@ static void My_Error_Handler(
|
|||||||
/**********************************/
|
/**********************************/
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
// Decode the ReadProperty Ack and pass to perl
|
/* Decode the ReadProperty Ack and pass to perl */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
#define MAX_ACK_STRING 512
|
#define MAX_ACK_STRING 512
|
||||||
void rp_ack_extract_data(
|
void rp_ack_extract_data(
|
||||||
@@ -168,13 +168,13 @@ void rp_ack_extract_data(
|
|||||||
strncat(pAckString, "}", 1);
|
strncat(pAckString, "}", 1);
|
||||||
pAckString += 1;
|
pAckString += 1;
|
||||||
}
|
}
|
||||||
// Now let's call a Perl function to display the data
|
/* Now let's call a Perl function to display the data */
|
||||||
__LogAnswer(ackString, 0);
|
__LogAnswer(ackString, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************/
|
/*****************************************/
|
||||||
// Decode the ReadPropertyMultiple Ack and pass to perl
|
/* Decode the ReadPropertyMultiple Ack and pass to perl */
|
||||||
/****************************************/
|
/****************************************/
|
||||||
void rpm_ack_extract_data(
|
void rpm_ack_extract_data(
|
||||||
BACNET_READ_ACCESS_DATA * rpm_data)
|
BACNET_READ_ACCESS_DATA * rpm_data)
|
||||||
@@ -231,13 +231,13 @@ void rpm_ack_extract_data(
|
|||||||
}
|
}
|
||||||
listOfProperties = listOfProperties->next;
|
listOfProperties = listOfProperties->next;
|
||||||
|
|
||||||
// Add a separator between consecutive entries so that Perl can
|
/* Add a separator between consecutive entries so that Perl can */
|
||||||
// parse this out
|
/* parse this out */
|
||||||
strncat(pAckString, "QQQ", 3);
|
strncat(pAckString, "QQQ", 3);
|
||||||
pAckString += 3;
|
pAckString += 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now let's call a Perl function to display the data
|
/* Now let's call a Perl function to display the data */
|
||||||
__LogAnswer(ackString, 1);
|
__LogAnswer(ackString, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -432,7 +432,7 @@ static void Wait_For_Answer_Or_Timeout(
|
|||||||
unsigned timeout_ms,
|
unsigned timeout_ms,
|
||||||
waitAction action)
|
waitAction action)
|
||||||
{
|
{
|
||||||
// Wait for timeout, failure, or success
|
/* Wait for timeout, failure, or success */
|
||||||
time_t last_seconds = time(NULL);
|
time_t last_seconds = time(NULL);
|
||||||
time_t timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
|
time_t timeout_seconds = (apdu_timeout() / 1000) * apdu_retries();
|
||||||
time_t elapsed_seconds = 0;
|
time_t elapsed_seconds = 0;
|
||||||
@@ -443,7 +443,7 @@ static void Wait_For_Answer_Or_Timeout(
|
|||||||
while (true) {
|
while (true) {
|
||||||
time_t current_seconds = time(NULL);
|
time_t current_seconds = time(NULL);
|
||||||
|
|
||||||
// If error was detected then bail out
|
/* If error was detected then bail out */
|
||||||
if (Error_Detected) {
|
if (Error_Detected) {
|
||||||
LogError("Some other error occurred");
|
LogError("Some other error occurred");
|
||||||
break;
|
break;
|
||||||
@@ -466,7 +466,7 @@ static void Wait_For_Answer_Or_Timeout(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (action == waitAnswer) {
|
if (action == waitAnswer) {
|
||||||
// Response was received. Exit.
|
/* Response was received. Exit. */
|
||||||
if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
if (tsm_invoke_id_free(Request_Invoke_ID)) {
|
||||||
break;
|
break;
|
||||||
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
} else if (tsm_invoke_id_failed(Request_Invoke_ID)) {
|
||||||
@@ -484,7 +484,7 @@ static void Wait_For_Answer_Or_Timeout(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keep track of time
|
/* Keep track of time */
|
||||||
elapsed_seconds += (current_seconds - last_seconds);
|
elapsed_seconds += (current_seconds - last_seconds);
|
||||||
last_seconds = current_seconds;
|
last_seconds = current_seconds;
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ static void Wait_For_Answer_Or_Timeout(
|
|||||||
/****************************************************/
|
/****************************************************/
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
// This is the most fundamental setup needed to start communication
|
/* This is the most fundamental setup needed to start communication */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
void BacnetPrepareComm(
|
void BacnetPrepareComm(
|
||||||
)
|
)
|
||||||
@@ -508,16 +508,16 @@ void BacnetPrepareComm(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
// Try to bind to a device. If successful, return zero. If failure, return
|
/* Try to bind to a device. If successful, return zero. If failure, return */
|
||||||
// non-zero and log the error details
|
/* non-zero and log the error details */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
int BacnetBindToDevice(
|
int BacnetBindToDevice(
|
||||||
int deviceInstanceNumber)
|
int deviceInstanceNumber)
|
||||||
{
|
{
|
||||||
int isFailure = 0;
|
int isFailure = 0;
|
||||||
|
|
||||||
// Store the requested device instance number in the global variable for
|
/* Store the requested device instance number in the global variable for */
|
||||||
// reference in other communication routines
|
/* reference in other communication routines */
|
||||||
Target_Device_Object_Instance = deviceInstanceNumber;
|
Target_Device_Object_Instance = deviceInstanceNumber;
|
||||||
|
|
||||||
/* try to bind with the device */
|
/* try to bind with the device */
|
||||||
@@ -526,17 +526,17 @@ int BacnetBindToDevice(
|
|||||||
Send_WhoIs(Target_Device_Object_Instance,
|
Send_WhoIs(Target_Device_Object_Instance,
|
||||||
Target_Device_Object_Instance);
|
Target_Device_Object_Instance);
|
||||||
|
|
||||||
// Wait for timeout, failure, or success
|
/* Wait for timeout, failure, or success */
|
||||||
Wait_For_Answer_Or_Timeout(100, waitBind);
|
Wait_For_Answer_Or_Timeout(100, waitBind);
|
||||||
}
|
}
|
||||||
// Clean up after ourselves
|
/* Clean up after ourselves */
|
||||||
isFailure = Error_Detected;
|
isFailure = Error_Detected;
|
||||||
Error_Detected = false;
|
Error_Detected = false;
|
||||||
return isFailure;
|
return isFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
// This is the interface to ReadProperty
|
/* This is the interface to ReadProperty */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
int BacnetReadProperty(
|
int BacnetReadProperty(
|
||||||
int deviceInstanceNumber,
|
int deviceInstanceNumber,
|
||||||
@@ -554,10 +554,10 @@ int BacnetReadProperty(
|
|||||||
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROPERTY,
|
||||||
My_Error_Handler);
|
My_Error_Handler);
|
||||||
|
|
||||||
// indicate that handlers are now registered
|
/* indicate that handlers are now registered */
|
||||||
isReadPropertyHandlerRegistered = true;
|
isReadPropertyHandlerRegistered = true;
|
||||||
}
|
}
|
||||||
// Send the message out
|
/* Send the message out */
|
||||||
Request_Invoke_ID =
|
Request_Invoke_ID =
|
||||||
Send_Read_Property_Request(deviceInstanceNumber, objectType,
|
Send_Read_Property_Request(deviceInstanceNumber, objectType,
|
||||||
objectInstanceNumber, objectProperty, objectIndex);
|
objectInstanceNumber, objectProperty, objectIndex);
|
||||||
@@ -569,13 +569,13 @@ int BacnetReadProperty(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/************************************************/
|
/************************************************/
|
||||||
// This is the interface to ReadPropertyMultiple
|
/* This is the interface to ReadPropertyMultiple */
|
||||||
/************************************************/
|
/************************************************/
|
||||||
int BacnetReadPropertyMultiple(
|
int BacnetReadPropertyMultiple(
|
||||||
int deviceInstanceNumber,
|
int deviceInstanceNumber,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
// Get the variable argument list from the stack
|
/* Get the variable argument list from the stack */
|
||||||
Inline_Stack_Vars;
|
Inline_Stack_Vars;
|
||||||
int rpmIndex = 1;
|
int rpmIndex = 1;
|
||||||
BACNET_READ_ACCESS_DATA *rpm_object =
|
BACNET_READ_ACCESS_DATA *rpm_object =
|
||||||
@@ -587,12 +587,12 @@ int BacnetReadPropertyMultiple(
|
|||||||
while (rpmIndex < Inline_Stack_Items) {
|
while (rpmIndex < Inline_Stack_Items) {
|
||||||
SV *pSV = Inline_Stack_Item(rpmIndex++);
|
SV *pSV = Inline_Stack_Item(rpmIndex++);
|
||||||
|
|
||||||
// Make sure the argument is an Array Reference
|
/* Make sure the argument is an Array Reference */
|
||||||
if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
|
if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
|
||||||
LogError("Argument is not an Array reference");
|
LogError("Argument is not an Array reference");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Make sure we can access the memory
|
/* Make sure we can access the memory */
|
||||||
if (rpm_object) {
|
if (rpm_object) {
|
||||||
rpm_object->listOfProperties = NULL;
|
rpm_object->listOfProperties = NULL;
|
||||||
} else {
|
} else {
|
||||||
@@ -603,7 +603,7 @@ int BacnetReadPropertyMultiple(
|
|||||||
AV *pAV = (AV *) SvRV(pSV);
|
AV *pAV = (AV *) SvRV(pSV);
|
||||||
SV **ppSV;
|
SV **ppSV;
|
||||||
|
|
||||||
// The 0th argument is the object type
|
/* The 0th argument is the object type */
|
||||||
ppSV = av_fetch(pAV, 0, 0);
|
ppSV = av_fetch(pAV, 0, 0);
|
||||||
if (ppSV) {
|
if (ppSV) {
|
||||||
rpm_object->object_type = SvIV(*ppSV);
|
rpm_object->object_type = SvIV(*ppSV);
|
||||||
@@ -612,7 +612,7 @@ int BacnetReadPropertyMultiple(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 1st argument is the object instance
|
/* The 1st argument is the object instance */
|
||||||
ppSV = av_fetch(pAV, 1, 0);
|
ppSV = av_fetch(pAV, 1, 0);
|
||||||
if (ppSV) {
|
if (ppSV) {
|
||||||
rpm_object->object_instance = SvIV(*ppSV);
|
rpm_object->object_instance = SvIV(*ppSV);
|
||||||
@@ -621,7 +621,7 @@ int BacnetReadPropertyMultiple(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 2nd argument is the property type
|
/* The 2nd argument is the property type */
|
||||||
ppSV = av_fetch(pAV, 2, 0);
|
ppSV = av_fetch(pAV, 2, 0);
|
||||||
if (ppSV) {
|
if (ppSV) {
|
||||||
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
|
||||||
@@ -637,7 +637,7 @@ int BacnetReadPropertyMultiple(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The 3rd argument is the property index
|
/* The 3rd argument is the property index */
|
||||||
ppSV = av_fetch(pAV, 3, 0);
|
ppSV = av_fetch(pAV, 3, 0);
|
||||||
if (ppSV) {
|
if (ppSV) {
|
||||||
rpm_property->propertyArrayIndex = SvIV(*ppSV);
|
rpm_property->propertyArrayIndex = SvIV(*ppSV);
|
||||||
@@ -646,7 +646,7 @@ int BacnetReadPropertyMultiple(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Advance to the next RPM index
|
/* Advance to the next RPM index */
|
||||||
if (rpmIndex < Inline_Stack_Items) {
|
if (rpmIndex < Inline_Stack_Items) {
|
||||||
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
|
||||||
rpm_object = rpm_object->next;
|
rpm_object = rpm_object->next;
|
||||||
@@ -664,17 +664,17 @@ int BacnetReadPropertyMultiple(
|
|||||||
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
|
||||||
My_Error_Handler);
|
My_Error_Handler);
|
||||||
|
|
||||||
// indicate that handlers are now registered
|
/* indicate that handlers are now registered */
|
||||||
isReadPropertyMultipleHandlerRegistered = true;
|
isReadPropertyMultipleHandlerRegistered = true;
|
||||||
}
|
}
|
||||||
// Send the message out
|
/* Send the message out */
|
||||||
if (!Error_Detected) {
|
if (!Error_Detected) {
|
||||||
Request_Invoke_ID =
|
Request_Invoke_ID =
|
||||||
Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
|
Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
|
||||||
deviceInstanceNumber, Read_Access_Data);
|
deviceInstanceNumber, Read_Access_Data);
|
||||||
Wait_For_Answer_Or_Timeout(100, waitAnswer);
|
Wait_For_Answer_Or_Timeout(100, waitAnswer);
|
||||||
}
|
}
|
||||||
// Clean up allocated memory
|
/* Clean up allocated memory */
|
||||||
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
BACNET_READ_ACCESS_DATA *old_rpm_object;
|
||||||
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
BACNET_PROPERTY_REFERENCE *old_rpm_property;
|
||||||
|
|
||||||
@@ -692,14 +692,14 @@ int BacnetReadPropertyMultiple(
|
|||||||
free(old_rpm_object);
|
free(old_rpm_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process the return value
|
/* Process the return value */
|
||||||
int isFailure = Error_Detected;
|
int isFailure = Error_Detected;
|
||||||
Error_Detected = 0;
|
Error_Detected = 0;
|
||||||
return isFailure;
|
return isFailure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
// This is the interface to WriteProperty
|
/* This is the interface to WriteProperty */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
int BacnetWriteProperty(
|
int BacnetWriteProperty(
|
||||||
int deviceInstanceNumber,
|
int deviceInstanceNumber,
|
||||||
@@ -723,16 +723,16 @@ int BacnetWriteProperty(
|
|||||||
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
apdu_set_error_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||||
My_Error_Handler);
|
My_Error_Handler);
|
||||||
|
|
||||||
// indicate that handlers are now registered
|
/* indicate that handlers are now registered */
|
||||||
isWritePropertyHandlerRegistered = true;
|
isWritePropertyHandlerRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (objectIndex == -1) {
|
if (objectIndex == -1) {
|
||||||
objectIndex = BACNET_ARRAY_ALL;
|
objectIndex = BACNET_ARRAY_ALL;
|
||||||
}
|
}
|
||||||
// Loop for eary exit;
|
/* Loop for eary exit; */
|
||||||
do {
|
do {
|
||||||
// Handle the tag/value pair
|
/* Handle the tag/value pair */
|
||||||
uint8_t context_tag = 0;
|
uint8_t context_tag = 0;
|
||||||
BACNET_APPLICATION_TAG property_tag;
|
BACNET_APPLICATION_TAG property_tag;
|
||||||
BACNET_APPLICATION_DATA_VALUE propertyValue;
|
BACNET_APPLICATION_DATA_VALUE propertyValue;
|
||||||
@@ -760,19 +760,19 @@ int BacnetWriteProperty(
|
|||||||
}
|
}
|
||||||
propertyValue.next = NULL;
|
propertyValue.next = NULL;
|
||||||
|
|
||||||
// Send out the message
|
/* Send out the message */
|
||||||
Request_Invoke_ID =
|
Request_Invoke_ID =
|
||||||
Send_Write_Property_Request(deviceInstanceNumber, objectType,
|
Send_Write_Property_Request(deviceInstanceNumber, objectType,
|
||||||
objectInstanceNumber, objectProperty, &propertyValue,
|
objectInstanceNumber, objectProperty, &propertyValue,
|
||||||
objectPriority, objectIndex);
|
objectPriority, objectIndex);
|
||||||
Wait_For_Answer_Or_Timeout(100, waitAnswer);
|
Wait_For_Answer_Or_Timeout(100, waitAnswer);
|
||||||
|
|
||||||
// If we get here, then there were no explicit failures. However, there
|
/* If we get here, then there were no explicit failures. However, there */
|
||||||
// could have been implicit failures. Let's look at those also.
|
/* could have been implicit failures. Let's look at those also. */
|
||||||
isFailure = Error_Detected;
|
isFailure = Error_Detected;
|
||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
// Clean up after ourselves.
|
/* Clean up after ourselves. */
|
||||||
Error_Detected = false;
|
Error_Detected = false;
|
||||||
return isFailure;
|
return isFailure;
|
||||||
}
|
}
|
||||||
@@ -795,7 +795,7 @@ int BacnetAtomicWriteFile(
|
|||||||
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE,
|
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_WRITE_FILE,
|
||||||
My_Error_Handler);
|
My_Error_Handler);
|
||||||
|
|
||||||
// indicate that handlers are now registered
|
/* indicate that handlers are now registered */
|
||||||
isAtomicWriteFileHandlerRegistered = true;
|
isAtomicWriteFileHandlerRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -815,7 +815,7 @@ int BacnetAtomicWriteFile(
|
|||||||
}
|
}
|
||||||
octetstring_truncate(&fileData, blockNumBytes);
|
octetstring_truncate(&fileData, blockNumBytes);
|
||||||
|
|
||||||
// Send out the message and wait for answer
|
/* Send out the message and wait for answer */
|
||||||
if (!Error_Detected) {
|
if (!Error_Detected) {
|
||||||
Request_Invoke_ID =
|
Request_Invoke_ID =
|
||||||
Send_Atomic_Write_File_Stream(deviceInstanceNumber,
|
Send_Atomic_Write_File_Stream(deviceInstanceNumber,
|
||||||
@@ -880,9 +880,9 @@ int BacnetTimeSync(
|
|||||||
my_time.tm_mday = day;
|
my_time.tm_mday = day;
|
||||||
my_time.tm_mon = month - 1;
|
my_time.tm_mon = month - 1;
|
||||||
my_time.tm_year = year - 1900;
|
my_time.tm_year = year - 1900;
|
||||||
my_time.tm_wday = 0; // does not matter
|
my_time.tm_wday = 0; /* does not matter */
|
||||||
my_time.tm_yday = 0; // does not matter
|
my_time.tm_yday = 0; /* does not matter */
|
||||||
my_time.tm_isdst = 0; // does not matter
|
my_time.tm_isdst = 0; /* does not matter */
|
||||||
|
|
||||||
aTime = mktime(&my_time);
|
aTime = mktime(&my_time);
|
||||||
newTime = localtime(&aTime);
|
newTime = localtime(&aTime);
|
||||||
@@ -903,7 +903,7 @@ int BacnetTimeSync(
|
|||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 };
|
uint8_t Handler_Transmit_Buffer[MAX_PDU] = { 0 };
|
||||||
|
|
||||||
// Loop for eary exit
|
/* Loop for eary exit */
|
||||||
do {
|
do {
|
||||||
if (!dcc_communication_enabled()) {
|
if (!dcc_communication_enabled()) {
|
||||||
LogError("DCC communicaiton is not enabled");
|
LogError("DCC communicaiton is not enabled");
|
||||||
@@ -945,7 +945,7 @@ int BacnetTimeSync(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
// This is the interface to AtomicReadFile
|
/* This is the interface to AtomicReadFile */
|
||||||
/****************************************************/
|
/****************************************************/
|
||||||
int BacnetAtomicReadFile(
|
int BacnetAtomicReadFile(
|
||||||
int deviceInstanceNumber,
|
int deviceInstanceNumber,
|
||||||
@@ -962,10 +962,10 @@ int BacnetAtomicReadFile(
|
|||||||
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
|
apdu_set_error_handler(SERVICE_CONFIRMED_ATOMIC_READ_FILE,
|
||||||
My_Error_Handler);
|
My_Error_Handler);
|
||||||
|
|
||||||
// indicate that handlers are now registered
|
/* indicate that handlers are now registered */
|
||||||
isAtomicReadFileHandlerRegistered = true;
|
isAtomicReadFileHandlerRegistered = true;
|
||||||
}
|
}
|
||||||
// Send the message out
|
/* Send the message out */
|
||||||
Request_Invoke_ID =
|
Request_Invoke_ID =
|
||||||
Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber,
|
Send_Atomic_Read_File_Stream(deviceInstanceNumber, fileInstanceNumber,
|
||||||
startOffset, numBytes);
|
startOffset, numBytes);
|
||||||
|
|||||||
+15
-15
@@ -1048,7 +1048,7 @@ int bacapp_snprintf_value(
|
|||||||
octet_str++;
|
octet_str++;
|
||||||
}
|
}
|
||||||
if (i == len) {
|
if (i == len) {
|
||||||
// Everything went fine
|
/* Everything went fine */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1070,8 +1070,8 @@ int bacapp_snprintf_value(
|
|||||||
}
|
}
|
||||||
if ((i == len) && append_str(&p_str, &rem_str_len, "\"")
|
if ((i == len) && append_str(&p_str, &rem_str_len, "\"")
|
||||||
) {
|
) {
|
||||||
// Everything is fine. Indicate how many bytes were
|
/* Everything is fine. Indicate how many bytes were */
|
||||||
// written
|
/* written */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1092,8 +1092,8 @@ int bacapp_snprintf_value(
|
|||||||
}
|
}
|
||||||
if ((i == len) && append_str(&p_str, &rem_str_len, "}")
|
if ((i == len) && append_str(&p_str, &rem_str_len, "}")
|
||||||
) {
|
) {
|
||||||
// Everything is fine. Indicate how many bytes were
|
/* Everything is fine. Indicate how many bytes were */
|
||||||
// written
|
/* written */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1211,8 +1211,8 @@ int bacapp_snprintf_value(
|
|||||||
if (!append_str(&p_str, &rem_str_len, temp_str))
|
if (!append_str(&p_str, &rem_str_len, temp_str))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If we get here, then everything is OK. Indicate how many
|
/* If we get here, then everything is OK. Indicate how many */
|
||||||
// bytes were written.
|
/* bytes were written. */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_TIME:
|
case BACNET_APPLICATION_TAG_TIME:
|
||||||
@@ -1252,8 +1252,8 @@ int bacapp_snprintf_value(
|
|||||||
if (!append_str(&p_str, &rem_str_len, temp_str))
|
if (!append_str(&p_str, &rem_str_len, temp_str))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// If we get here, then everything is OK. Indicate how many
|
/* If we get here, then everything is OK. Indicate how many */
|
||||||
// bytes were written.
|
/* bytes were written. */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
@@ -1295,8 +1295,8 @@ int bacapp_snprintf_value(
|
|||||||
}
|
}
|
||||||
if (!append_str(&p_str, &rem_str_len, ")"))
|
if (!append_str(&p_str, &rem_str_len, ")"))
|
||||||
break;
|
break;
|
||||||
// If we get here, then everything is OK. Indicate how many
|
/* If we get here, then everything is OK. Indicate how many */
|
||||||
// bytes were written.
|
/* bytes were written. */
|
||||||
ret_val = str_len - rem_str_len;
|
ret_val = str_len - rem_str_len;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@@ -1307,7 +1307,7 @@ int bacapp_snprintf_value(
|
|||||||
|
|
||||||
return ret_val;
|
return ret_val;
|
||||||
}
|
}
|
||||||
#endif // BACAPP_SNPRINTF_ENABLED
|
#endif /* BACAPP_SNPRINTF_ENABLED */
|
||||||
|
|
||||||
#ifdef BACAPP_PRINT_ENABLED
|
#ifdef BACAPP_PRINT_ENABLED
|
||||||
/* Print the extracted value from the requested BACnet object property to the
|
/* Print the extracted value from the requested BACnet object property to the
|
||||||
@@ -1324,13 +1324,13 @@ bool bacapp_print_value(
|
|||||||
int status;
|
int status;
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
// Try to allocate memory for the output string. Give up if unable.
|
/* Try to allocate memory for the output string. Give up if unable. */
|
||||||
str = (char *) calloc(sizeof(char), str_len);
|
str = (char *) calloc(sizeof(char), str_len);
|
||||||
if (!str)
|
if (!str)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Try to extract the value into allocated memory. If unable, try again
|
/* Try to extract the value into allocated memory. If unable, try again */
|
||||||
// another time with a string that is twice as large.
|
/* another time with a string that is twice as large. */
|
||||||
status = bacapp_snprintf_value(str, str_len, object_value);
|
status = bacapp_snprintf_value(str, str_len, object_value);
|
||||||
if ((status < 0) || (status >= str_len)) {
|
if ((status < 0) || (status >= str_len)) {
|
||||||
free(str);
|
free(str);
|
||||||
|
|||||||
@@ -46,19 +46,19 @@ size_t memcopy(
|
|||||||
size_t len, /* amount of data to copy */
|
size_t len, /* amount of data to copy */
|
||||||
size_t max)
|
size_t max)
|
||||||
{ /* total size of destination */
|
{ /* total size of destination */
|
||||||
// size_t i;
|
/* size_t i; */
|
||||||
// size_t copy_len = 0;
|
/* size_t copy_len = 0; */
|
||||||
// char *s1, *s2;
|
/* char *s1, *s2; */
|
||||||
|
|
||||||
// s1 = dest;
|
/* s1 = dest; */
|
||||||
// s2 = src;
|
/* s2 = src; */
|
||||||
if (len <= (max - offset)) {
|
if (len <= (max - offset)) {
|
||||||
memcpy(&((char *) dest)[offset], src, len);
|
memcpy(&((char *) dest)[offset], src, len);
|
||||||
return (len);
|
return (len);
|
||||||
// for (i = 0; i < len; i++) {
|
/* for (i = 0; i < len; i++) { */
|
||||||
// s1[offset + i] = s2[i];
|
/* s1[offset + i] = s2[i]; */
|
||||||
// copy_len++;
|
/* copy_len++; */
|
||||||
// }
|
/* } */
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user