indented using indent.sh script.
This commit is contained in:
@@ -181,8 +181,7 @@ void handler_atomic_read_file(
|
||||
error = true;
|
||||
} else if (bacfile_read_stream_data(&data)) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"ARF: fileStartRecord %d, %u RecordCount.\n",
|
||||
fprintf(stderr, "ARF: fileStartRecord %d, %u RecordCount.\n",
|
||||
data.type.record.fileStartRecord,
|
||||
data.type.record.RecordCount);
|
||||
#endif
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
/** @file h_cov.c Handles Change of Value (COV) services. */
|
||||
|
||||
typedef struct BACnet_COV_Address{
|
||||
typedef struct BACnet_COV_Address {
|
||||
bool valid:1;
|
||||
BACNET_ADDRESS dest;
|
||||
} BACNET_COV_ADDRESS;
|
||||
@@ -106,7 +106,8 @@ static BACNET_ADDRESS *cov_address_get(
|
||||
* Removes the address from the list of COV addresses, if it is not
|
||||
* used by other COV subscriptions
|
||||
*/
|
||||
static void cov_address_remove_unused(void)
|
||||
static void cov_address_remove_unused(
|
||||
void)
|
||||
{
|
||||
unsigned index = 0;
|
||||
unsigned cov_index = 0;
|
||||
@@ -137,7 +138,7 @@ static void cov_address_remove_unused(void)
|
||||
* @return index number 0..N, or -1 if unable to add
|
||||
*/
|
||||
static int cov_address_add(
|
||||
BACNET_ADDRESS *dest)
|
||||
BACNET_ADDRESS * dest)
|
||||
{
|
||||
int index = -1;
|
||||
unsigned i = 0;
|
||||
@@ -475,8 +476,8 @@ static bool cov_send_request(
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, false, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest,
|
||||
&my_address, &npdu_data);
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], dest, &my_address,
|
||||
&npdu_data);
|
||||
/* load the COV data structure for outgoing message */
|
||||
cov_data.subscriberProcessIdentifier =
|
||||
cov_subscription->subscriberProcessIdentifier;
|
||||
@@ -504,13 +505,12 @@ static bool cov_send_request(
|
||||
}
|
||||
pdu_len += len;
|
||||
if (cov_subscription->flag.issueConfirmedNotifications) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id,
|
||||
dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
(uint16_t) pdu_len);
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
|
||||
}
|
||||
bytes_sent =
|
||||
datalink_send_pdu(dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
datalink_send_pdu(dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
if (bytes_sent > 0) {
|
||||
status = true;
|
||||
#if PRINT_ENABLED
|
||||
|
||||
@@ -87,7 +87,7 @@ void npdu_handler(
|
||||
routing information cause they are not for us */
|
||||
if ((dest.net == BACNET_BROADCAST_NETWORK) &&
|
||||
((pdu[apdu_offset] & 0xF0) ==
|
||||
PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
|
||||
PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
|
||||
/* hack for 5.4.5.1 - IDLE */
|
||||
/* ConfirmedBroadcastReceived */
|
||||
/* then enter IDLE - ignore the PDU */
|
||||
|
||||
@@ -111,8 +111,8 @@ void handler_who_has(
|
||||
|
||||
|
||||
#ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */
|
||||
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
|
||||
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
|
||||
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
|
||||
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
|
||||
|
||||
/** Handler for Who-Has requests in the virtual routing setup,
|
||||
* with broadcast I-Have response.
|
||||
|
||||
@@ -114,10 +114,10 @@ void handler_who_is_unicast(
|
||||
|
||||
|
||||
#ifdef BAC_ROUTING /* was for BAC_ROUTING - delete in 2/2012 if still unused */
|
||||
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
|
||||
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
|
||||
|
||||
|
||||
/* EKH: I restored this to BAC_ROUTING (from DEPRECATED) because I found that the server demo with the built-in
|
||||
virtual Router did not insert the SADRs of the virtual devices on the virtual network without it */
|
||||
|
||||
|
||||
/** Local function to check Who-Is requests against our Device IDs.
|
||||
* Will check the gateway (root Device) and all virtual routed
|
||||
* Devices against the range and respond for each that matches.
|
||||
|
||||
@@ -45,86 +45,89 @@
|
||||
|
||||
/** @file s_awfs.c Send part of an Atomic Write File Stream request. */
|
||||
|
||||
uint8_t Send_Atomic_Write_File_Stream (uint32_t device_id,
|
||||
uint32_t file_instance,
|
||||
int fileStartPosition,
|
||||
BACNET_OCTET_STRING * fileData) {
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
unsigned max_apdu = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool status = false;
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
BACNET_ATOMIC_WRITE_FILE_DATA data;
|
||||
uint8_t Send_Atomic_Write_File_Stream(
|
||||
uint32_t device_id,
|
||||
uint32_t file_instance,
|
||||
int fileStartPosition,
|
||||
BACNET_OCTET_STRING * fileData)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
unsigned max_apdu = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool status = false;
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
BACNET_ATOMIC_WRITE_FILE_DATA data;
|
||||
|
||||
/* if we are forbidden to send, don't send! */
|
||||
if (!dcc_communication_enabled ())
|
||||
return 0;
|
||||
/* if we are forbidden to send, don't send! */
|
||||
if (!dcc_communication_enabled())
|
||||
return 0;
|
||||
|
||||
/* is the device bound? */
|
||||
status = address_get_by_device (device_id, &max_apdu, &dest);
|
||||
/* is there a tsm available? */
|
||||
if (status)
|
||||
invoke_id = tsm_next_free_invokeID ();
|
||||
if (invoke_id) {
|
||||
/* load the data for the encoding */
|
||||
data.object_type = OBJECT_FILE;
|
||||
data.object_instance = file_instance;
|
||||
data.access = FILE_STREAM_ACCESS;
|
||||
data.type.stream.fileStartPosition = fileStartPosition;
|
||||
status = octetstring_copy (&data.fileData[0], fileData);
|
||||
if (status) {
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address (&my_address);
|
||||
npdu_encode_npdu_data (&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu (&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||
&npdu_data);
|
||||
/* encode the APDU portion of the packet */
|
||||
len =
|
||||
awf_encode_apdu (&Handler_Transmit_Buffer[pdu_len], invoke_id, &data);
|
||||
pdu_len += len;
|
||||
/* will the APDU fit the target device?
|
||||
note: if there is a bottleneck router in between
|
||||
us and the destination, we won't know unless
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len <= max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction (invoke_id, &dest,
|
||||
&npdu_data,
|
||||
&Handler_Transmit_Buffer
|
||||
[0], (uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu (&dest, &npdu_data, &Handler_Transmit_Buffer[0],
|
||||
pdu_len);
|
||||
/* is the device bound? */
|
||||
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||
/* is there a tsm available? */
|
||||
if (status)
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
if (invoke_id) {
|
||||
/* load the data for the encoding */
|
||||
data.object_type = OBJECT_FILE;
|
||||
data.object_instance = file_instance;
|
||||
data.access = FILE_STREAM_ACCESS;
|
||||
data.type.stream.fileStartPosition = fileStartPosition;
|
||||
status = octetstring_copy(&data.fileData[0], fileData);
|
||||
if (status) {
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest,
|
||||
&my_address, &npdu_data);
|
||||
/* encode the APDU portion of the packet */
|
||||
len =
|
||||
awf_encode_apdu(&Handler_Transmit_Buffer[pdu_len], invoke_id,
|
||||
&data);
|
||||
pdu_len += len;
|
||||
/* will the APDU fit the target device?
|
||||
note: if there is a bottleneck router in between
|
||||
us and the destination, we won't know unless
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len <= max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &Handler_Transmit_Buffer[0],
|
||||
(uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf (stderr, "Failed to Send AtomicWriteFile Request (%s)!\n",
|
||||
strerror (errno));
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr,
|
||||
"Failed to Send AtomicWriteFile Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
} else {
|
||||
tsm_free_invoke_id (invoke_id);
|
||||
invoke_id = 0;
|
||||
} else {
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
#if PRINT_ENABLED
|
||||
fprintf (stderr,
|
||||
"Failed to Send AtomicWriteFile Request "
|
||||
"(payload [%d] exceeds destination maximum APDU [%u])!\n",
|
||||
pdu_len, max_apdu);
|
||||
fprintf(stderr,
|
||||
"Failed to Send AtomicWriteFile Request "
|
||||
"(payload [%d] exceeds destination maximum APDU [%u])!\n",
|
||||
pdu_len, max_apdu);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
tsm_free_invoke_id (invoke_id);
|
||||
invoke_id = 0;
|
||||
}
|
||||
} else {
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
#if PRINT_ENABLED
|
||||
fprintf (stderr,
|
||||
"Failed to Send AtomicWriteFile Request "
|
||||
"(payload [%d] exceeds octet string capacity)!\n", pdu_len);
|
||||
fprintf(stderr,
|
||||
"Failed to Send AtomicWriteFile Request "
|
||||
"(payload [%d] exceeds octet string capacity)!\n", pdu_len);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
return invoke_id;
|
||||
}
|
||||
|
||||
+120
-119
@@ -1,119 +1,120 @@
|
||||
/**
|
||||
* @file
|
||||
* @author Daniel Blazevic <daniel.blazevic@gmail.com>
|
||||
* @date 2013
|
||||
* @brief Send Write Property Multiple request
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2013 Daniel Blazevic <daniel.blazevic@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "txbuf.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "address.h"
|
||||
#include "tsm.h"
|
||||
#include "npdu.h"
|
||||
#include "apdu.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "dcc.h"
|
||||
#include "wpm.h"
|
||||
/* some demo stuff needed */
|
||||
#include "handlers.h"
|
||||
#include "sbuf.h"
|
||||
#include "client.h"
|
||||
|
||||
/** @file s_wpm.c Send Write Property Multiple request. */
|
||||
|
||||
/** Sends a Write Property Multiple request.
|
||||
* @param device_id [in] ID of the destination device
|
||||
* @param write_access_data [in] Ptr to structure with the linked list of
|
||||
* objects and properties to be written.
|
||||
* @return invoke id of outgoing message, or 0 if device is not bound or no tsm available
|
||||
*/
|
||||
uint8_t Send_Write_Property_Multiple_Request_Data(
|
||||
uint32_t device_id,
|
||||
BACNET_WRITE_ACCESS_DATA * write_access_data)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
unsigned max_apdu = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool status = false;
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
/* is the device bound? */
|
||||
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||
/* is there a tsm available? */
|
||||
if (status)
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
if (invoke_id) {
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||
&npdu_data);
|
||||
|
||||
len = wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
|
||||
invoke_id, write_access_data);
|
||||
|
||||
pdu_len += len;
|
||||
|
||||
/* will it fit in the sender?
|
||||
note: if there is a bottleneck router in between
|
||||
us and the destination, we won't know unless
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
} else {
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Failed to Send WriteProperty Request "
|
||||
"(exceeds destination maximum APDU)!\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
}
|
||||
/**
|
||||
* @file
|
||||
* @author Daniel Blazevic <daniel.blazevic@gmail.com>
|
||||
* @date 2013
|
||||
* @brief Send Write Property Multiple request
|
||||
*
|
||||
* @section LICENSE
|
||||
*
|
||||
* Copyright (C) 2013 Daniel Blazevic <daniel.blazevic@gmail.com>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining
|
||||
* a copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, sublicense, and/or sell copies of the Software, and to
|
||||
* permit persons to whom the Software is furnished to do so, subject to
|
||||
* the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include "config.h"
|
||||
#include "txbuf.h"
|
||||
#include "bacdef.h"
|
||||
#include "bacdcode.h"
|
||||
#include "address.h"
|
||||
#include "tsm.h"
|
||||
#include "npdu.h"
|
||||
#include "apdu.h"
|
||||
#include "device.h"
|
||||
#include "datalink.h"
|
||||
#include "dcc.h"
|
||||
#include "wpm.h"
|
||||
/* some demo stuff needed */
|
||||
#include "handlers.h"
|
||||
#include "sbuf.h"
|
||||
#include "client.h"
|
||||
|
||||
/** @file s_wpm.c Send Write Property Multiple request. */
|
||||
|
||||
/** Sends a Write Property Multiple request.
|
||||
* @param device_id [in] ID of the destination device
|
||||
* @param write_access_data [in] Ptr to structure with the linked list of
|
||||
* objects and properties to be written.
|
||||
* @return invoke id of outgoing message, or 0 if device is not bound or no tsm available
|
||||
*/
|
||||
uint8_t Send_Write_Property_Multiple_Request_Data(
|
||||
uint32_t device_id,
|
||||
BACNET_WRITE_ACCESS_DATA * write_access_data)
|
||||
{
|
||||
BACNET_ADDRESS dest;
|
||||
BACNET_ADDRESS my_address;
|
||||
unsigned max_apdu = 0;
|
||||
uint8_t invoke_id = 0;
|
||||
bool status = false;
|
||||
int len = 0;
|
||||
int pdu_len = 0;
|
||||
int bytes_sent = 0;
|
||||
BACNET_NPDU_DATA npdu_data;
|
||||
|
||||
/* is the device bound? */
|
||||
status = address_get_by_device(device_id, &max_apdu, &dest);
|
||||
/* is there a tsm available? */
|
||||
if (status)
|
||||
invoke_id = tsm_next_free_invokeID();
|
||||
if (invoke_id) {
|
||||
/* encode the NPDU portion of the packet */
|
||||
datalink_get_my_address(&my_address);
|
||||
npdu_encode_npdu_data(&npdu_data, true, MESSAGE_PRIORITY_NORMAL);
|
||||
pdu_len =
|
||||
npdu_encode_pdu(&Handler_Transmit_Buffer[0], &dest, &my_address,
|
||||
&npdu_data);
|
||||
|
||||
len =
|
||||
wpm_encode_apdu(&Handler_Transmit_Buffer[pdu_len], max_apdu,
|
||||
invoke_id, write_access_data);
|
||||
|
||||
pdu_len += len;
|
||||
|
||||
/* will it fit in the sender?
|
||||
note: if there is a bottleneck router in between
|
||||
us and the destination, we won't know unless
|
||||
we have a way to check for that and update the
|
||||
max_apdu in the address binding table. */
|
||||
if ((unsigned) pdu_len < max_apdu) {
|
||||
tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
|
||||
&npdu_data, &Handler_Transmit_Buffer[0], (uint16_t) pdu_len);
|
||||
bytes_sent =
|
||||
datalink_send_pdu(&dest, &npdu_data,
|
||||
&Handler_Transmit_Buffer[0], pdu_len);
|
||||
#if PRINT_ENABLED
|
||||
if (bytes_sent <= 0)
|
||||
fprintf(stderr, "Failed to Send WriteProperty Request (%s)!\n",
|
||||
strerror(errno));
|
||||
#endif
|
||||
} else {
|
||||
tsm_free_invoke_id(invoke_id);
|
||||
invoke_id = 0;
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr,
|
||||
"Failed to Send WriteProperty Request "
|
||||
"(exceeds destination maximum APDU)!\n");
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
return invoke_id;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ static uint32_t timeval_diff_ms(
|
||||
|
||||
static void mstp_monitor_i_am(
|
||||
uint8_t mac,
|
||||
uint8_t *pdu,
|
||||
uint8_t * pdu,
|
||||
uint16_t pdu_len)
|
||||
{
|
||||
BACNET_ADDRESS src = { 0 };
|
||||
@@ -150,10 +150,9 @@ static void mstp_monitor_i_am(
|
||||
if (pdu[0] == BACNET_PROTOCOL_VERSION) {
|
||||
MSTP_Fill_BACnet_Address(&src, mac);
|
||||
apdu_offset = npdu_decode(&pdu[0], &dest, &src, &npdu_data);
|
||||
if ((!npdu_data.network_layer_message) &&
|
||||
(apdu_offset > 0) && (apdu_offset < pdu_len) &&
|
||||
((dest.net == 0) || (dest.net == BACNET_BROADCAST_NETWORK)) &&
|
||||
(src.net == 0)) {
|
||||
if ((!npdu_data.network_layer_message) && (apdu_offset > 0) &&
|
||||
(apdu_offset < pdu_len) && ((dest.net == 0) ||
|
||||
(dest.net == BACNET_BROADCAST_NETWORK)) && (src.net == 0)) {
|
||||
apdu_len = pdu_len - apdu_offset;
|
||||
apdu = &pdu[apdu_offset];
|
||||
pdu_type = apdu[0] & 0xF0;
|
||||
@@ -162,8 +161,9 @@ static void mstp_monitor_i_am(
|
||||
service_choice = apdu[1];
|
||||
service_request = &apdu[2];
|
||||
if (service_choice == SERVICE_UNCONFIRMED_I_AM) {
|
||||
len = iam_decode_service_request(service_request,
|
||||
&device_id, NULL, NULL, NULL);
|
||||
len =
|
||||
iam_decode_service_request(service_request, &device_id,
|
||||
NULL, NULL, NULL);
|
||||
if (len != -1) {
|
||||
MSTP_Statistics[mac].device_id = device_id;
|
||||
}
|
||||
@@ -272,11 +272,10 @@ static void packet_statistics(
|
||||
}
|
||||
}
|
||||
if ((mstp_port->ReceivedValidFrame) ||
|
||||
(mstp_port->ReceivedValidFrameNotForUs)){
|
||||
(mstp_port->ReceivedValidFrameNotForUs)) {
|
||||
if ((mstp_port->DataLength <= mstp_port->InputBufferSize) &&
|
||||
(mstp_port->DataLength > 0)) {
|
||||
mstp_monitor_i_am(src,
|
||||
&mstp_port->InputBuffer[0],
|
||||
mstp_monitor_i_am(src, &mstp_port->InputBuffer[0],
|
||||
mstp_port->DataLength);
|
||||
}
|
||||
}
|
||||
@@ -754,8 +753,8 @@ static bool read_received_packet(
|
||||
mstp_port->HeaderCRCActual = header[7];
|
||||
mstp_port->HeaderCRC = 0xFF;
|
||||
for (i = 2; i < 8; i++) {
|
||||
mstp_port->HeaderCRC = CRC_Calc_Header(header[i],
|
||||
mstp_port->HeaderCRC);
|
||||
mstp_port->HeaderCRC =
|
||||
CRC_Calc_Header(header[i], mstp_port->HeaderCRC);
|
||||
}
|
||||
if (mstp_port->HeaderCRC != 0x55) {
|
||||
mstp_port->ReceivedInvalidFrame = true;
|
||||
@@ -792,11 +791,9 @@ static bool read_received_packet(
|
||||
mstp_port->DataCRC);
|
||||
}
|
||||
mstp_port->DataCRC =
|
||||
CRC_Calc_Data(mstp_port->DataCRCActualMSB,
|
||||
mstp_port->DataCRC);
|
||||
CRC_Calc_Data(mstp_port->DataCRCActualMSB, mstp_port->DataCRC);
|
||||
mstp_port->DataCRC =
|
||||
CRC_Calc_Data(mstp_port->DataCRCActualLSB,
|
||||
mstp_port->DataCRC);
|
||||
CRC_Calc_Data(mstp_port->DataCRCActualLSB, mstp_port->DataCRC);
|
||||
if (mstp_port->DataCRC == 0xF0B8) {
|
||||
mstp_port->ReceivedValidFrame = true;
|
||||
mstp_port->ReceivedValidFrameNotForUs = true;
|
||||
@@ -851,13 +848,14 @@ static BOOL WINAPI CtrlCHandler(
|
||||
* Returns: none
|
||||
* Notes: none
|
||||
**************************************************************************/
|
||||
static void print_com_ports(void)
|
||||
static void print_com_ports(
|
||||
void)
|
||||
{
|
||||
unsigned i = 0;
|
||||
|
||||
printf("List of available COM ports:\r\n");
|
||||
/* try to open all 255 COM ports */
|
||||
for (i=1; i<256; i++) {
|
||||
for (i = 1; i < 256; i++) {
|
||||
if (RS485_Interface_Valid(i)) {
|
||||
printf("COM%u\r\n", i);
|
||||
}
|
||||
@@ -964,10 +962,10 @@ int main(
|
||||
if (argc > 1) {
|
||||
RS485_Set_Interface(argv[1]);
|
||||
} else {
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32)
|
||||
print_com_ports();
|
||||
return 0;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
if (argc > 2) {
|
||||
my_baud = strtol(argv[2], NULL, 0);
|
||||
|
||||
@@ -124,5 +124,4 @@ extern "C" {
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -123,7 +123,8 @@ extern "C" {
|
||||
uint16_t Analog_Value_Units(
|
||||
uint32_t instance);
|
||||
bool Analog_Value_Units_Set(
|
||||
uint32_t instance, uint16_t unit);
|
||||
uint32_t instance,
|
||||
uint16_t unit);
|
||||
|
||||
bool Analog_Value_Out_Of_Service(
|
||||
uint32_t instance);
|
||||
|
||||
@@ -282,7 +282,7 @@ int bacfile_read_property(
|
||||
case PROP_FILE_ACCESS_METHOD:
|
||||
apdu_len =
|
||||
encode_application_enumerated(&apdu[0],
|
||||
FILE_RECORD_AND_STREAM_ACCESS);
|
||||
FILE_RECORD_AND_STREAM_ACCESS);
|
||||
break;
|
||||
default:
|
||||
rpdata->error_class = ERROR_CLASS_PROPERTY;
|
||||
@@ -551,7 +551,8 @@ bool bacfile_write_record_data(
|
||||
}
|
||||
for (i = 0; i < data->type.record.returnedRecordCount; i++) {
|
||||
if (fwrite(octetstring_value(&data->fileData[i]),
|
||||
octetstring_length(&data->fileData[i]), 1, pFile) != 1) {
|
||||
octetstring_length(&data->fileData[i]), 1,
|
||||
pFile) != 1) {
|
||||
/* do something if it fails? */
|
||||
}
|
||||
}
|
||||
@@ -598,7 +599,7 @@ bool bacfile_read_ack_record_data(
|
||||
FILE *pFile = NULL;
|
||||
char *pFilename = NULL;
|
||||
uint32_t i = 0;
|
||||
char dummy_data[MAX_OCTET_STRING_BYTES] = {0};
|
||||
char dummy_data[MAX_OCTET_STRING_BYTES] = { 0 };
|
||||
char *pData = NULL;
|
||||
|
||||
pFilename = bacfile_name(instance);
|
||||
@@ -616,10 +617,11 @@ bool bacfile_read_ack_record_data(
|
||||
}
|
||||
for (i = 0; i < data->type.record.RecordCount; i++) {
|
||||
if (fwrite(octetstring_value(&data->fileData[i]),
|
||||
octetstring_length(&data->fileData[i]), 1, pFile) != 1) {
|
||||
octetstring_length(&data->fileData[i]), 1,
|
||||
pFile) != 1) {
|
||||
#if PRINT_ENABLED
|
||||
fprintf(stderr, "Failed to write to %s (%lu)!\n", pFilename,
|
||||
(unsigned long) instance);
|
||||
fprintf(stderr, "Failed to write to %s (%lu)!\n",
|
||||
pFilename, (unsigned long) instance);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,4 +138,3 @@ extern "C" {
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1173,7 +1173,7 @@ int Device_Read_Property_Local(
|
||||
uint8_t *apdu = NULL;
|
||||
struct object_functions *pObject = NULL;
|
||||
bool found = false;
|
||||
uint16_t apdu_max =0;
|
||||
uint16_t apdu_max = 0;
|
||||
|
||||
if ((rpdata == NULL) || (rpdata->application_data == NULL) ||
|
||||
(rpdata->application_data_len == 0)) {
|
||||
@@ -1818,8 +1818,8 @@ void Device_Init(
|
||||
struct uci_context *ctx;
|
||||
fprintf(stderr, "Device_Init\n");
|
||||
ctx = ucix_init("bacnet_dev");
|
||||
if(!ctx)
|
||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||
if (!ctx)
|
||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||
uciname = ucix_get_option(ctx, "bacnet_dev", "0", "Name");
|
||||
if (uciname != 0) {
|
||||
characterstring_init_ansi(&My_Object_Name, uciname);
|
||||
|
||||
@@ -440,15 +440,11 @@ extern "C" {
|
||||
* - The interface between the implemented Objects and the BAC-stack services,
|
||||
* specifically the handlers, which are mediated through function calls to
|
||||
* the Device object.
|
||||
*/
|
||||
|
||||
/** @defgroup ObjHelpers Object Helper Functions
|
||||
*//** @defgroup ObjHelpers Object Helper Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the function templates for the helper functions that
|
||||
* provide common object support.
|
||||
*/
|
||||
|
||||
/** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
*//** @defgroup ObjIntf Handler-to-Object Interface Functions
|
||||
* @ingroup ObjFrmwk
|
||||
* This section describes the fairly limited set of functions that link the
|
||||
* BAC-stack handlers to the BACnet Object instances. All of these calls are
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <time.h> /* for time */
|
||||
#include <ctype.h> /* for tupper */
|
||||
#include <ctype.h> /* for tupper */
|
||||
#if defined(WIN32) || defined(__BORLANDC__)
|
||||
#include <conio.h>
|
||||
#endif
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <time.h> /* for time */
|
||||
#include <errno.h>
|
||||
#include <ctype.h> /* for toupper */
|
||||
#include <ctype.h> /* for toupper */
|
||||
#include "bactext.h"
|
||||
#include "iam.h"
|
||||
#include "address.h"
|
||||
|
||||
@@ -130,7 +130,7 @@ static void AtomicReadFileAckHandler(
|
||||
/* is there anything to do with this? data.stream.requestedOctetCount */
|
||||
(void) fseek(pFile, data.type.stream.fileStartPosition,
|
||||
SEEK_SET);
|
||||
octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */
|
||||
octets_written = fwrite(octetstring_value(&data.fileData[0]), 1, /* unit to write in bytes - in our case, an octet is one byte */
|
||||
octetstring_length(&data.fileData[0]), pFile);
|
||||
if (octets_written != octetstring_length(&data.fileData[0])) {
|
||||
fprintf(stderr, "Unable to write data to file \"%s\".\n",
|
||||
|
||||
@@ -166,8 +166,8 @@ int main(
|
||||
struct uci_context *ctx;
|
||||
|
||||
ctx = ucix_init("bacnet_dev");
|
||||
if(!ctx)
|
||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||
if (!ctx)
|
||||
fprintf(stderr, "Failed to load config file bacnet_dev\n");
|
||||
uciId = ucix_get_option_int(ctx, "bacnet_dev", "0", "Id", 0);
|
||||
printf("ID: %i", uciId);
|
||||
if (uciId != 0) {
|
||||
|
||||
Reference in New Issue
Block a user