[Bacnet-developers] Activating BVLC code
Brought to you by:
skarg
|
From: <tom...@sw...> - 2008-01-13 12:18:28
|
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
call me crazy, but I'm giving a try at the (as far as I can see not yet
fully functional) BVLC code. I need it at the moment, because at one
installation the BACnet devices run in a separate (sub-)net, so se have
to talk through a BACnet router.
So far I doscovered two buglets (I hope to send patches later), but
wanted to let you know. In bacenum.h I had to change
BVLC_BROADCAST_DIST_TABLE* to BVLC_BROADCAST_DISTRIBUTION_TABLE*, like
so:
- --- a/include/bacenum.h
+++ b/include/bacenum.h
@@ -946,8 +946,8 @@ typedef enum {
typedef enum {
BVLC_RESULT = 0,
BVLC_WRITE_BROADCAST_DISTRIBUTION_TABLE = 1,
- - BVLC_READ_BROADCAST_DIST_TABLE = 2,
- - BVLC_READ_BROADCAST_DIST_TABLE_ACK = 3,
+ BVLC_READ_BROADCAST_DISTRIBUTION_TABLE = 2,
+ BVLC_READ_BROADCAST_DISTRIBUTION_TABLE_ACK = 3,
BVLC_FORWARDED_NPDU = 4,
BVLC_REGISTER_FOREIGN_DEVICE = 5,
BVLC_READ_FOREIGN_DEVICE_TABLE = 6,
(I assumed that tobe the "right" fix because there are other
..._DISTRIBUTION_... around).
In bvlc.c there seems to be an endianness glitch with the IP address and
the port, which I addressed like so:
- --- a/src/bvlc.c
+++ b/src/bvlc.c
@@ -1076,7 +1076,7 @@ int bvlc_send_pdu(
uint8_t mtu[MAX_MPDU] = { 0 };
int mtu_len = 0;
int bytes_sent = 0;
- - uint32_t raw_address = 0;
+ uint32_t address, raw_address, port = 0;
/* bip datalink doesn't need to know the npdu data */
(void) npdu_data;
@@ -1088,8 +1088,10 @@ int bvlc_send_pdu(
bvlc_dest.sin_family = AF_INET;
if (dest->net == BACNET_BROADCAST_NETWORK) {
/* broadcast */
- - bvlc_dest.sin_addr.s_addr = bip_get_broadcast_addr();
- - bvlc_dest.sin_port = bip_get_port();
+ address = bip_get_broadcast_addr();
+ port = bip_get_port();
+ (void) decode_unsigned32(&address, &bvlc_dest.sin_addr.s_addr);
+ (void) decode_unsigned16(&port, &bvlc_dest.sin_port);
memset(&(bvlc_dest.sin_zero), '\0', 8);
mtu[1] = BVLC_ORIGINAL_BROADCAST_NPDU;
} else if (dest->mac_len == 6) {
The fix is not the prettiest, I'd like to take out more common code from
te two branches of the "if", but at the moment I'm just trying to be
minimally invasive.
Hope to follow up with a patch or two (I hope I get the patch format
this time right. Do you have a hint as to how?)
Regards and thanks for the good work
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFHigAkBcgs9XrR2kYRAvNYAJwIQaWQwGNr0trbuBUa6AeP0xe/xwCfRt4s
GqNJZLqCqVPHa/9IZpwUZwU=
=yaYk
-----END PGP SIGNATURE-----
|