indented.

This commit is contained in:
skarg
2006-08-13 00:57:17 +00:00
parent 5bb205dc03
commit a30d497669
41 changed files with 574 additions and 573 deletions
+1 -2
View File
@@ -272,8 +272,7 @@ uint16_t apdu_decode_confirmed_service_request(uint8_t * apdu, /* APDU data */
return len; return len;
} }
void apdu_handler(BACNET_ADDRESS * src, void apdu_handler(BACNET_ADDRESS * src, uint8_t * apdu, /* APDU data */
uint8_t * apdu, /* APDU data */
uint16_t apdu_len) uint16_t apdu_len)
{ {
BACNET_CONFIRMED_SERVICE_DATA service_data = { 0 }; BACNET_CONFIRMED_SERVICE_DATA service_data = { 0 };
+5 -8
View File
@@ -48,8 +48,7 @@ int bacapp_encode_application_data(uint8_t * apdu,
{ {
int apdu_len = 0; /* total length of the apdu, return value */ int apdu_len = 0; /* total length of the apdu, return value */
if (value && apdu) if (value && apdu) {
{
switch (value->tag) { switch (value->tag) {
case BACNET_APPLICATION_TAG_NULL: case BACNET_APPLICATION_TAG_NULL:
apdu[0] = value->tag; apdu[0] = value->tag;
@@ -68,20 +67,17 @@ int bacapp_encode_application_data(uint8_t * apdu,
value->type.Signed_Int); value->type.Signed_Int);
break; break;
case BACNET_APPLICATION_TAG_REAL: case BACNET_APPLICATION_TAG_REAL:
apdu_len = encode_tagged_real(&apdu[0], apdu_len = encode_tagged_real(&apdu[0], value->type.Real);
value->type.Real);
break; break;
case BACNET_APPLICATION_TAG_ENUMERATED: case BACNET_APPLICATION_TAG_ENUMERATED:
apdu_len = encode_tagged_enumerated(&apdu[0], apdu_len = encode_tagged_enumerated(&apdu[0],
value->type.Enumerated); value->type.Enumerated);
break; break;
case BACNET_APPLICATION_TAG_DATE: case BACNET_APPLICATION_TAG_DATE:
apdu_len = encode_tagged_date(&apdu[0], apdu_len = encode_tagged_date(&apdu[0], &value->type.Date);
&value->type.Date);
break; break;
case BACNET_APPLICATION_TAG_TIME: case BACNET_APPLICATION_TAG_TIME:
apdu_len = encode_tagged_time(&apdu[0], apdu_len = encode_tagged_time(&apdu[0], &value->type.Time);
&value->type.Time);
break; break;
case BACNET_APPLICATION_TAG_OBJECT_ID: case BACNET_APPLICATION_TAG_OBJECT_ID:
apdu_len = encode_tagged_object_id(&apdu[0], apdu_len = encode_tagged_object_id(&apdu[0],
@@ -491,6 +487,7 @@ bool bacapp_same_time(BACNET_TIME * time1, BACNET_TIME * time2)
return status; return status;
} }
/* generic - can be used by other unit tests /* generic - can be used by other unit tests
returns true if matching or same, false if different */ returns true if matching or same, false if different */
bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE * value, bool bacapp_same_value(BACNET_APPLICATION_DATA_VALUE * value,
-2
View File
@@ -77,7 +77,5 @@ extern "C" {
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif /* __cplusplus */ #endif /* __cplusplus */
#endif /* BACTEXT_PRINT_ENABLED */ #endif /* BACTEXT_PRINT_ENABLED */
#endif #endif
+7 -4
View File
@@ -76,7 +76,8 @@ void handler_atomic_read_file(uint8_t * service_request,
if (data.type.stream.requestedOctetCount < if (data.type.stream.requestedOctetCount <
octetstring_capacity(&data.fileData)) { octetstring_capacity(&data.fileData)) {
if (bacfile_read_data(&data)) { if (bacfile_read_data(&data)) {
pdu_len = arf_ack_encode_apdu(&Handler_Transmit_Buffer[0], pdu_len =
arf_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data); service_data->invoke_id, &data);
} else { } else {
error = true; error = true;
@@ -91,9 +92,11 @@ void handler_atomic_read_file(uint8_t * service_request,
#endif #endif
} }
} else { } else {
pdu_len = bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len], pdu_len =
service_data->invoke_id, SERVICE_CONFIRMED_ATOMIC_READ_FILE, bacerror_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
ERROR_CLASS_SERVICES, ERROR_CODE_INVALID_FILE_ACCESS_METHOD); service_data->invoke_id,
SERVICE_CONFIRMED_ATOMIC_READ_FILE, ERROR_CLASS_SERVICES,
ERROR_CODE_INVALID_FILE_ACCESS_METHOD);
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Record Access Requested. Sending Error!\n"); fprintf(stderr, "Record Access Requested. Sending Error!\n");
#endif #endif
+1 -2
View File
@@ -76,8 +76,7 @@ void handler_atomic_read_file_ack(uint8_t * service_request,
data.type.stream.fileStartPosition, SEEK_SET); data.type.stream.fileStartPosition, SEEK_SET);
if (fwrite(octetstring_value(&data.fileData), if (fwrite(octetstring_value(&data.fileData),
octetstring_length(&data.fileData), 1, octetstring_length(&data.fileData), 1,
pFile) != 1) pFile) != 1) {
{
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Failed to write to %s (%u)!\n", fprintf(stderr, "Failed to write to %s (%u)!\n",
pFilename, instance); pFilename, instance);
+5 -4
View File
@@ -99,7 +99,8 @@ void handler_read_property(uint8_t * service_request,
data.application_data = &Temp_Buf[0]; data.application_data = &Temp_Buf[0];
data.application_data_len = len; data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */ /* FIXME: probably need a length limitation sent with encode */
pdu_len = rp_ack_encode_apdu(&Handler_Transmit_Buffer[0], pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data); service_data->invoke_id, &data);
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, fprintf(stderr,
@@ -168,7 +169,8 @@ void handler_read_property(uint8_t * service_request,
data.application_data = &Temp_Buf[0]; data.application_data = &Temp_Buf[0];
data.application_data_len = len; data.application_data_len = len;
/* FIXME: probably need a length limitation sent with encode */ /* FIXME: probably need a length limitation sent with encode */
pdu_len = rp_ack_encode_apdu(&Handler_Transmit_Buffer[0], pdu_len =
rp_ack_encode_apdu(&Handler_Transmit_Buffer[0],
service_data->invoke_id, &data); service_data->invoke_id, &data);
#if PRINT_ENABLED #if PRINT_ENABLED
fprintf(stderr, "Sending Read Property Ack for BO!\n"); fprintf(stderr, "Sending Read Property Ack for BO!\n");
@@ -338,8 +340,7 @@ void handler_read_property(uint8_t * service_request,
} }
if (send) { if (send) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(src, &npdu_data, bytes_sent = datalink_send_pdu(src, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno)); fprintf(stderr, "Failed to send PDU (%s)!\n", strerror(errno));
+6 -4
View File
@@ -74,10 +74,12 @@ uint8_t Send_Atomic_Read_File_Stream(uint32_t device_id,
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
+6 -5
View File
@@ -75,10 +75,12 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len <= max_apdu) { if ((unsigned) pdu_len <= max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
@@ -108,4 +110,3 @@ uint8_t Send_Atomic_Write_File_Stream(uint32_t device_id,
return invoke_id; return invoke_id;
} }
+6 -4
View File
@@ -73,10 +73,12 @@ uint8_t Send_Device_Communication_Control_Request(uint32_t device_id, uint16_t t
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
+1 -2
View File
@@ -67,8 +67,7 @@ void Send_I_Have(uint32_t device_id,
pdu_len = ihave_encode_apdu(&Handler_Transmit_Buffer[0], &data); pdu_len = ihave_encode_apdu(&Handler_Transmit_Buffer[0], &data);
/* send the data */ /* send the data */
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
bytes_sent = datalink_send_pdu(&dest, &npdu_data, bytes_sent = datalink_send_pdu(&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
&Handler_Transmit_Buffer[0], pdu_len); /* number of bytes of data */
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
fprintf(stderr, "Failed to Send I-Have Reply (%s)!\n", fprintf(stderr, "Failed to Send I-Have Reply (%s)!\n",
+6 -4
View File
@@ -73,10 +73,12 @@ uint8_t Send_Reinitialize_Device_Request(uint32_t device_id,
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
+6 -4
View File
@@ -79,10 +79,12 @@ uint8_t Send_Read_Property_Request(uint32_t device_id, /* destination device */
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
+1 -2
View File
@@ -62,8 +62,7 @@ void Send_WhoHas_Name(int32_t low_limit,
data.high_limit = high_limit; data.high_limit = high_limit;
data.object_name = true; data.object_name = true;
characterstring_init_ansi(&data.object.name, object_name); characterstring_init_ansi(&data.object.name, object_name);
pdu_len = whohas_encode_apdu(&Handler_Transmit_Buffer[0], pdu_len = whohas_encode_apdu(&Handler_Transmit_Buffer[0], &data);
&data);
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
/* send the data */ /* send the data */
bytes_sent = datalink_send_pdu(&dest, &npdu_data, bytes_sent = datalink_send_pdu(&dest, &npdu_data,
+6 -4
View File
@@ -83,10 +83,12 @@ uint8_t Send_Write_Property_Request(uint32_t device_id, /* destination device */
we have a way to check for that and update the we have a way to check for that and update the
max_apdu in the address binding table. */ max_apdu in the address binding table. */
if ((unsigned) pdu_len < max_apdu) { if ((unsigned) pdu_len < max_apdu) {
npdu_encode_confirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_confirmed_apdu(&npdu_data,
tsm_set_confirmed_unsegmented_transaction(invoke_id, MESSAGE_PRIORITY_NORMAL);
&dest, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len); tsm_set_confirmed_unsegmented_transaction(invoke_id, &dest,
bytes_sent = datalink_send_pdu(&dest, &npdu_data, &npdu_data, &Handler_Transmit_Buffer[0], pdu_len);
bytes_sent =
datalink_send_pdu(&dest, &npdu_data,
&Handler_Transmit_Buffer[0], pdu_len); &Handler_Transmit_Buffer[0], pdu_len);
#if PRINT_ENABLED #if PRINT_ENABLED
if (bytes_sent <= 0) if (bytes_sent <= 0)
+6 -6
View File
@@ -312,12 +312,12 @@ uint32_t bacfile_instance_from_tsm(uint8_t invokeID)
found = tsm_get_transaction_pdu(invokeID, &dest, &npdu_data, &apdu[0], found = tsm_get_transaction_pdu(invokeID, &dest, &npdu_data, &apdu[0],
&apdu_len); &apdu_len);
if (found) { if (found) {
if (!npdu_data.network_layer_message && npdu_data.confirmed_message && if (!npdu_data.network_layer_message && npdu_data.confirmed_message
(apdu[0] == PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) { && (apdu[0] == PDU_TYPE_CONFIRMED_SERVICE_REQUEST)) {
len = apdu_decode_confirmed_service_request(&apdu[0], len =
apdu_len - apdu_offset, apdu_decode_confirmed_service_request(&apdu[0],
&service_data, apdu_len - apdu_offset, &service_data, &service_choice,
&service_choice, &service_request, &service_request_len); &service_request, &service_request_len);
if (service_choice == SERVICE_CONFIRMED_ATOMIC_READ_FILE) { if (service_choice == SERVICE_CONFIRMED_ATOMIC_READ_FILE) {
len = arf_decode_service_request(service_request, len = arf_decode_service_request(service_request,
service_request_len, &data); service_request_len, &data);
+2 -1
View File
@@ -239,7 +239,8 @@ int main(int argc, char *argv[])
timeout_seconds = (Device_APDU_Timeout() / 1000) * timeout_seconds = (Device_APDU_Timeout() / 1000) *
Device_Number_Of_APDU_Retries(); Device_Number_Of_APDU_Retries();
/* try to bind with the device */ /* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance,Target_Device_Object_Instance); Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
/* loop forever */ /* loop forever */
for (;;) { for (;;) {
/* increment timer - exit if timed out */ /* increment timer - exit if timed out */
+2 -1
View File
@@ -195,7 +195,8 @@ int main(int argc, char *argv[])
timeout_seconds = (Device_APDU_Timeout() / 1000) * timeout_seconds = (Device_APDU_Timeout() / 1000) *
Device_Number_Of_APDU_Retries(); Device_Number_Of_APDU_Retries();
/* try to bind with the device */ /* try to bind with the device */
Send_WhoIs(Target_Device_Object_Instance,Target_Device_Object_Instance); Send_WhoIs(Target_Device_Object_Instance,
Target_Device_Object_Instance);
/* loop forever */ /* loop forever */
for (;;) { for (;;) {
/* increment timer - exit if timed out */ /* increment timer - exit if timed out */
+1 -2
View File
@@ -44,8 +44,7 @@
#define MAX_HEADER (2+1+1+1+2+1+2+1) #define MAX_HEADER (2+1+1+1+2+1+2+1)
#define MAX_MPDU (MAX_HEADER+MAX_PDU) #define MAX_MPDU (MAX_HEADER+MAX_PDU)
typedef struct dlmstp_packet typedef struct dlmstp_packet {
{
bool ready; /* true if ready to be sent or received */ bool ready; /* true if ready to be sent or received */
bool data_expecting_reply; bool data_expecting_reply;
BACNET_ADDRESS address; /* src or dest address */ BACNET_ADDRESS address; /* src or dest address */
+1 -2
View File
@@ -151,8 +151,7 @@ int iam_send(uint8_t * buffer)
/* encode the NPDU portion of the packet */ /* encode the NPDU portion of the packet */
npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL); npdu_encode_unconfirmed_apdu(&npdu_data, MESSAGE_PRIORITY_NORMAL);
/* send data */ /* send data */
bytes_sent = datalink_send_pdu(&dest, &npdu_data, bytes_sent = datalink_send_pdu(&dest, &npdu_data, &buffer[0], pdu_len);
&buffer[0], pdu_len);
return bytes_sent; return bytes_sent;
} }
+3 -6
View File
@@ -57,8 +57,7 @@ void npdu_copy_data(BACNET_NPDU_DATA * dest, BACNET_NPDU_DATA * src)
int npdu_encode_pdu(uint8_t * npdu, int npdu_encode_pdu(uint8_t * npdu,
BACNET_ADDRESS * dest, BACNET_ADDRESS * dest,
BACNET_ADDRESS * src, BACNET_ADDRESS * src, BACNET_NPDU_DATA * npdu_data)
BACNET_NPDU_DATA * npdu_data)
{ {
int len = 0; /* return value - number of octets loaded in this function */ int len = 0; /* return value - number of octets loaded in this function */
int i = 0; /* counter */ int i = 0; /* counter */
@@ -158,8 +157,7 @@ int npdu_encode_pdu(uint8_t * npdu,
void npdu_encode_confirmed_apdu(BACNET_NPDU_DATA * npdu_data, void npdu_encode_confirmed_apdu(BACNET_NPDU_DATA * npdu_data,
BACNET_MESSAGE_PRIORITY priority) BACNET_MESSAGE_PRIORITY priority)
{ {
if (npdu_data) if (npdu_data) {
{
npdu_data->confirmed_message = true; npdu_data->confirmed_message = true;
npdu_data->protocol_version = BACNET_PROTOCOL_VERSION; npdu_data->protocol_version = BACNET_PROTOCOL_VERSION;
npdu_data->network_layer_message = false; /* false if APDU */ npdu_data->network_layer_message = false; /* false if APDU */
@@ -173,8 +171,7 @@ void npdu_encode_confirmed_apdu(BACNET_NPDU_DATA * npdu_data,
void npdu_encode_unconfirmed_apdu(BACNET_NPDU_DATA * npdu_data, void npdu_encode_unconfirmed_apdu(BACNET_NPDU_DATA * npdu_data,
BACNET_MESSAGE_PRIORITY priority) BACNET_MESSAGE_PRIORITY priority)
{ {
if (npdu_data) if (npdu_data) {
{
npdu_data->confirmed_message = false; npdu_data->confirmed_message = false;
npdu_data->protocol_version = BACNET_PROTOCOL_VERSION; npdu_data->protocol_version = BACNET_PROTOCOL_VERSION;
npdu_data->network_layer_message = false; /* false if APDU */ npdu_data->network_layer_message = false; /* false if APDU */
+7 -9
View File
@@ -64,12 +64,12 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
bool status; bool status;
int bytes_sent = 0; int bytes_sent = 0;
if (Transmit_Buffer.ready == false) if (Transmit_Buffer.ready == false) {
{
/* FIXME: how do we get data_expecting_reply? */ /* FIXME: how do we get data_expecting_reply? */
Transmit_Buffer.data_expecting_reply = false; Transmit_Buffer.data_expecting_reply = false;
Receive_Buffer.pdu_len = 0; Receive_Buffer.pdu_len = 0;
memmove(&Transmit_Buffer.address,dest,sizeof(Transmit_Buffer.address)); memmove(&Transmit_Buffer.address, dest,
sizeof(Transmit_Buffer.address));
Transmit_Buffer.pdu_len = pdu_len; Transmit_Buffer.pdu_len = pdu_len;
/* FIXME: copy the whole PDU or just the pdu_len? */ /* FIXME: copy the whole PDU or just the pdu_len? */
memmove(Transmit_Buffer.pdu, pdu, sizeof(Transmit_Buffer.pdu)); memmove(Transmit_Buffer.pdu, pdu, sizeof(Transmit_Buffer.pdu));
@@ -83,14 +83,13 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
/* function for MS/TP to use to get a packet to transmit /* function for MS/TP to use to get a packet to transmit
returns the number of bytes in the packet, or zero if none. */ returns the number of bytes in the packet, or zero if none. */
int dlmstp_get_transmit_pdu(BACNET_ADDRESS * dest, /* destination address */ int dlmstp_get_transmit_pdu(BACNET_ADDRESS * dest, /* destination address */
uint8_t * pdu) /* any data to be sent - may be null */ uint8_t * pdu)
{ { /* any data to be sent - may be null */
bool status; bool status;
DLMSTP_PACKET *packet; DLMSTP_PACKET *packet;
unsigned pdu_len = 0; unsigned pdu_len = 0;
if (Transmit_Buffer.ready) if (Transmit_Buffer.ready) {
{
memmove(dest, &packet->address, sizeof(packet->address)); memmove(dest, &packet->address, sizeof(packet->address));
pdu_len = packet->pdu_len; pdu_len = packet->pdu_len;
memmove(pdu, packet->pdu, sizeof(packet.pdu)); memmove(pdu, packet->pdu, sizeof(packet.pdu));
@@ -130,8 +129,7 @@ uint16_t dlmstp_receive(BACNET_ADDRESS * src, /* source address */
(void) timeout; (void) timeout;
/* see if there is a packet available */ /* see if there is a packet available */
if (!Ringbuf_Empty(&Receive_Buffer)) if (!Ringbuf_Empty(&Receive_Buffer)) {
{
packet = (char *) Ringbuf_Pop_Front(&Receive_Buffer); packet = (char *) Ringbuf_Pop_Front(&Receive_Buffer);
memmove(src, &packet->address, sizeof(packet->address)); memmove(src, &packet->address, sizeof(packet->address));
pdu_len = packet->pdu_len; pdu_len = packet->pdu_len;
+1
View File
@@ -52,6 +52,7 @@
static uint8_t Temp_Buf[MAX_APDU]; static uint8_t Temp_Buf[MAX_APDU];
/* buffer used for receiving */ /* buffer used for receiving */
static uint8_t Rx_Buf[MAX_MPDU] = { 0 }; static uint8_t Rx_Buf[MAX_MPDU] = { 0 };
/* address where message came from */ /* address where message came from */
static BACNET_ADDRESS src; static BACNET_ADDRESS src;
/* address used to send */ /* address used to send */
+1 -2
View File
@@ -133,8 +133,7 @@ uint8_t tsm_next_free_invokeID(void)
bool found = false; bool found = false;
/* is there even space available? */ /* is there even space available? */
if (tsm_transaction_available()) if (tsm_transaction_available()) {
{
while (!found) { while (!found) {
index = tsm_find_invokeID_index(current_invokeID); index = tsm_find_invokeID_index(current_invokeID);
/* not found - that is good! */ /* not found - that is good! */