made the datalink generic while adding datalink for MS/TP
This commit is contained in:
@@ -6,12 +6,14 @@ BASEDIR = .
|
|||||||
#CFLAGS = -Wall -I. -O2 -g
|
#CFLAGS = -Wall -I. -O2 -g
|
||||||
# Note: you can strip out symbols using the strip command
|
# Note: you can strip out symbols using the strip command
|
||||||
# to get an idea of how big the compile really is.
|
# to get an idea of how big the compile really is.
|
||||||
#CFLAGS = -Wall -I. -g -DBACDL_ETHERNET=1
|
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_MSTP=1
|
||||||
|
#CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_ETHERNET=1
|
||||||
CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1
|
CFLAGS = -Wall -I. -Iports/linux -g -DBACDL_BIP=1
|
||||||
|
|
||||||
SRCS = ports/linux/main.c \
|
SRCS = ports/linux/main.c \
|
||||||
ports/linux/ethernet.c \
|
ports/linux/ethernet.c \
|
||||||
ports/linux/bip.c \
|
ports/linux/bip.c \
|
||||||
|
dlmstp.c \
|
||||||
handlers.c \
|
handlers.c \
|
||||||
bacdcode.c \
|
bacdcode.c \
|
||||||
bigend.c \
|
bigend.c \
|
||||||
|
|||||||
+40
-10
@@ -46,14 +46,14 @@ int datalink_send_pdu(
|
|||||||
uint8_t *pdu, // any data to be sent - may be null
|
uint8_t *pdu, // any data to be sent - may be null
|
||||||
unsigned pdu_len) // number of bytes of data
|
unsigned pdu_len) // number of bytes of data
|
||||||
{
|
{
|
||||||
#ifdef BACDL_ETHERNET
|
#ifdef BACDL_MSTP
|
||||||
return ethernet_send_pdu(
|
return dlmstp_send_pdu(
|
||||||
dest,
|
dest,
|
||||||
pdu,
|
pdu,
|
||||||
pdu_len);
|
pdu_len);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BACDL_MSTP
|
#ifdef BACDL_ETHERNET
|
||||||
return mstp_send_pdu(
|
return ethernet_send_pdu(
|
||||||
dest,
|
dest,
|
||||||
pdu,
|
pdu,
|
||||||
pdu_len);
|
pdu_len);
|
||||||
@@ -66,15 +66,45 @@ int datalink_send_pdu(
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// returns the number of octets in the PDU, or zero on failure
|
||||||
|
uint16_t datalink_receive(
|
||||||
|
BACNET_ADDRESS *src, // source address
|
||||||
|
uint8_t *pdu, // PDU data
|
||||||
|
uint16_t max_pdu, // amount of space available in the PDU
|
||||||
|
unsigned timeout) // number of milliseconds to wait for a packet
|
||||||
|
{
|
||||||
|
#ifdef BACDL_MSTP
|
||||||
|
return dlmstp_receive(
|
||||||
|
src,
|
||||||
|
pdu,
|
||||||
|
max_pdu,
|
||||||
|
timeout);
|
||||||
|
#endif
|
||||||
|
#ifdef BACDL_ETHERNET
|
||||||
|
return ethernet_receive(
|
||||||
|
src,
|
||||||
|
pdu,
|
||||||
|
max_pdu,
|
||||||
|
timeout);
|
||||||
|
#endif
|
||||||
|
#ifdef BACDL_BIP
|
||||||
|
return bip_receive(
|
||||||
|
src,
|
||||||
|
pdu,
|
||||||
|
max_pdu,
|
||||||
|
timeout);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void datalink_get_broadcast_address(
|
void datalink_get_broadcast_address(
|
||||||
BACNET_ADDRESS *dest) // destination address
|
BACNET_ADDRESS *dest) // destination address
|
||||||
{
|
{
|
||||||
|
#ifdef BACDL_MSTP
|
||||||
|
dlmstp_get_broadcast_address(dest);
|
||||||
|
#endif
|
||||||
#ifdef BACDL_ETHERNET
|
#ifdef BACDL_ETHERNET
|
||||||
ethernet_get_broadcast_address(dest);
|
ethernet_get_broadcast_address(dest);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BACDL_MSTP
|
|
||||||
mstp_get_broadcast_address(dest);
|
|
||||||
#endif
|
|
||||||
#ifdef BACDL_BIP
|
#ifdef BACDL_BIP
|
||||||
bip_get_broadcast_address(dest);
|
bip_get_broadcast_address(dest);
|
||||||
#endif
|
#endif
|
||||||
@@ -83,12 +113,12 @@ void datalink_get_broadcast_address(
|
|||||||
void datalink_get_my_address(
|
void datalink_get_my_address(
|
||||||
BACNET_ADDRESS *my_address)
|
BACNET_ADDRESS *my_address)
|
||||||
{
|
{
|
||||||
|
#ifdef BACDL_MSTP
|
||||||
|
dlmstp_get_my_address(my_address);
|
||||||
|
#endif
|
||||||
#ifdef BACDL_ETHERNET
|
#ifdef BACDL_ETHERNET
|
||||||
ethernet_get_my_address(my_address);
|
ethernet_get_my_address(my_address);
|
||||||
#endif
|
#endif
|
||||||
#ifdef BACDL_MSTP
|
|
||||||
mstp_get_my_address(my_address);
|
|
||||||
#endif
|
|
||||||
#ifdef BACDL_BIP
|
#ifdef BACDL_BIP
|
||||||
bip_get_my_address(my_address);
|
bip_get_my_address(my_address);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BACDL_MSTP
|
#ifdef BACDL_MSTP
|
||||||
#include "mstp.h"
|
#include "dlmstp.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef BACDL_BIP
|
#ifdef BACDL_BIP
|
||||||
@@ -57,6 +57,13 @@ int datalink_send_pdu(
|
|||||||
uint8_t *pdu, // any data to be sent - may be null
|
uint8_t *pdu, // any data to be sent - may be null
|
||||||
unsigned pdu_len); // number of bytes of data
|
unsigned pdu_len); // number of bytes of data
|
||||||
|
|
||||||
|
// returns the number of octets in the PDU, or zero on failure
|
||||||
|
uint16_t datalink_receive(
|
||||||
|
BACNET_ADDRESS *src, // source address
|
||||||
|
uint8_t *pdu, // PDU data
|
||||||
|
uint16_t max_pdu, // amount of space available in the PDU
|
||||||
|
unsigned timeout); // number of milliseconds to wait for a packet
|
||||||
|
|
||||||
void datalink_get_broadcast_address(
|
void datalink_get_broadcast_address(
|
||||||
BACNET_ADDRESS *dest); // destination address
|
BACNET_ADDRESS *dest); // destination address
|
||||||
|
|
||||||
|
|||||||
+1
-4
@@ -40,10 +40,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "bacdef.h"
|
#include "bacdef.h"
|
||||||
|
#include "dlmstp.h"
|
||||||
// defines specific to MS/TP
|
|
||||||
#define MAX_HEADER (2+1+1+1+2+1+2+1)
|
|
||||||
#define MAX_MPDU (MAX_HEADER+MAX_PDU)
|
|
||||||
|
|
||||||
// The value 255 is used to denote broadcast when used as a
|
// The value 255 is used to denote broadcast when used as a
|
||||||
// destination address but is not allowed as a value for a station.
|
// destination address but is not allowed as a value for a station.
|
||||||
|
|||||||
@@ -39,12 +39,7 @@
|
|||||||
#include "tsm.h"
|
#include "tsm.h"
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "bacfile.h"
|
#include "bacfile.h"
|
||||||
#ifdef BACDL_ETHERNET
|
#include "datalink.h"
|
||||||
#include "ethernet.h"
|
|
||||||
#endif
|
|
||||||
#ifdef BACDL_BIP
|
|
||||||
#include "bip.h"
|
|
||||||
#endif
|
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
|
||||||
// This is an example application using the BACnet Stack on Linux
|
// This is an example application using the BACnet Stack on Linux
|
||||||
@@ -329,20 +324,11 @@ int main(int argc, char *argv[])
|
|||||||
// input
|
// input
|
||||||
new_time = time(NULL);
|
new_time = time(NULL);
|
||||||
// returns 0 bytes on timeout
|
// returns 0 bytes on timeout
|
||||||
#ifdef BACDL_ETHERNET
|
pdu_len = datalink_receive(
|
||||||
pdu_len = ethernet_receive(
|
|
||||||
&src,
|
&src,
|
||||||
&Rx_Buf[0],
|
&Rx_Buf[0],
|
||||||
MAX_MPDU,
|
MAX_MPDU,
|
||||||
timeout);
|
timeout);
|
||||||
#endif
|
|
||||||
#ifdef BACDL_BIP
|
|
||||||
pdu_len = bip_receive(
|
|
||||||
&src,
|
|
||||||
&Rx_Buf[0],
|
|
||||||
MAX_MPDU,
|
|
||||||
timeout);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// process
|
// process
|
||||||
if (pdu_len)
|
if (pdu_len)
|
||||||
|
|||||||
Reference in New Issue
Block a user