Updated the Datalink Data-Expecting-Reply for the at91sam7s and atmega168 projects.

This commit is contained in:
skarg
2007-08-24 00:34:32 +00:00
parent b41f8709d8
commit 686030e197
6 changed files with 201 additions and 94 deletions
+5 -45
View File
@@ -32,6 +32,7 @@
#include "rs485.h"
#include "npdu.h"
#include "apdu.h"
#include "bacaddr.h"
#include "bits.h"
/* This file has been customized for use with the AT91SAM7S-EK */
#include "board.h"
@@ -49,23 +50,6 @@ static volatile struct mstp_port_struct_t MSTP_Port;
static uint8_t TxBuffer[MAX_MPDU];
static uint8_t RxBuffer[MAX_MPDU];
void dlmstp_copy_bacnet_address(BACNET_ADDRESS * dest, BACNET_ADDRESS * src)
{
int i = 0;
if (dest && src) {
dest->mac_len = src->mac_len;
for (i = 0; i < MAX_MAC_LEN; i++) {
dest->mac[i] = src->mac[i];
}
dest->net = src->net;
dest->len = src->len;
for (i = 0; i < MAX_MAC_LEN; i++) {
dest->adr[i] = src->adr[i];
}
}
}
bool dlmstp_init(char *ifname)
{
(void)ifname;
@@ -112,7 +96,7 @@ int dlmstp_send_pdu(BACNET_ADDRESS * dest, /* destination address */
for (i = 0; i < pdu_len; i++) {
Transmit_Packet.pdu[i] = pdu[i];
}
dlmstp_copy_bacnet_address(&Transmit_Packet.address, dest);
bacnet_address_copy(&Transmit_Packet.address, dest);
bytes_sent = sizeof(Transmit_Packet);
Transmit_Packet.ready = true;
}
@@ -164,7 +148,7 @@ uint16_t dlmstp_receive(
for (i = 0; i < Receive_Packet.pdu_len; i++) {
pdu[i] = Receive_Packet.pdu[i];
}
dlmstp_copy_bacnet_address(src, &Receive_Packet.address);
bacnet_address_copy(src, &Receive_Packet.address);
pdu_len = Receive_Packet.pdu_len;
}
Receive_Packet.ready = false;
@@ -256,30 +240,6 @@ uint16_t MSTP_Get_Send(
return pdu_len;
}
bool dlmstp_same_bacnet_address(BACNET_ADDRESS * dest, BACNET_ADDRESS * src)
{
int i = 0;
if (!dest || !src)
return false;
if (dest->mac_len != src->mac_len)
return false;
for (i = 0; i < dest->mac_len; i++) {
if (dest->mac[i] != src->mac[i])
return false;
}
if (dest->net != src->net)
return false;
if (dest->len != src->len)
return false;
for (i = 0; i < dest->len; i++) {
if (dest->adr[i] != src->adr[i])
return false;
}
return true;
}
bool dlmstp_compare_data_expecting_reply(
uint8_t *request_pdu,
uint16_t request_pdu_len,
@@ -321,7 +281,7 @@ bool dlmstp_compare_data_expecting_reply(
else
request.service_choice = request_pdu[offset+3];
/* decode the reply data */
dlmstp_copy_bacnet_address(&reply.address, dest_address);
bacnet_address_copy(&reply.address, dest_address);
offset = npdu_decode(&reply_pdu[0],
&reply.address, NULL, &reply.npdu_data);
if (reply.npdu_data.network_layer_message) {
@@ -382,7 +342,7 @@ bool dlmstp_compare_data_expecting_reply(
if (request.npdu_data.priority != reply.npdu_data.priority) {
return false;
}
if (!dlmstp_same_bacnet_address(&request.address, &reply.address)) {
if (!bacnet_address_same(&request.address, &reply.address)) {
return false;
}
+1
View File
@@ -59,6 +59,7 @@ CORESRC = ../../npdu.c \
../../bacint.c \
../../apdu.c \
../../bacdcode.c \
../../bacaddr.c \
../../bacstr.c \
../../abort.c \
../../bacerror.c \