From 1cd8834d1a5f07a1eb1666ae0dc5d206b846aa30 Mon Sep 17 00:00:00 2001 From: Kaiserchen85 <109826681+Kaiserchen85@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:33:05 -0700 Subject: [PATCH 1/2] Added building details in README and fixed example to receive and process messages from server - Updated README.md with more detailed instructions for compiling and building the example. Made sure that all files required for compiling are mentioned. - Fixed looping so that messages from a server device can be received and processed. --- BACnetClientExample.py | 21 ++++++++++----------- CHANGELOG.md | 13 +++++++++++++ README.md | 10 +++++++++- 3 files changed, 32 insertions(+), 12 deletions(-) diff --git a/BACnetClientExample.py b/BACnetClientExample.py index 40f58df..06304c4 100644 --- a/BACnetClientExample.py +++ b/BACnetClientExample.py @@ -9,12 +9,12 @@ from CASBACnetStackAdapter import * # Contains all the Enumerations, and callback prototypes import pathlib -APPLICATION_VERSION = "0.0.1" +APPLICATION_VERSION = "1.0.1" SETTING_BACNET_IP_PORT = 47808 SETTING_CLIENT_DEVICE_INSTANCE = 389002 SETTING_DOWNSTREAM_DEVICE_PORT = SETTING_BACNET_IP_PORT SETTING_DOWNSTREAM_DEVICE_INSTANCE = 389999 -SETTING_DEFAULT_DOWNSTREAM_DEVICE_IP_ADDRESS = "192.168.2.217" +SETTING_DEFAULT_DOWNSTREAM_DEVICE_IP_ADDRESS = "192.168.68.105" downstreamConnectionString = None # TODO: Update accordingly invokeId = None @@ -66,7 +66,7 @@ def DoUserInput(): def WaitForResponse(timeout=3): expireTime = time.time() + timeout while time.time() < expireTime: - # fpLoop() + CASBACnetStack.BACnetStack_Tick() pass @@ -300,10 +300,10 @@ def CallbackReceiveMessage(message, maxMessageLength, receivedConnectionString, networkType): try: data, addr = udpSocket.recvfrom(maxMessageLength) - # if not data: - # print("DEBUG: not data") + if not data: + return 0 # A message was received. - # print ("DEBUG: CallbackReceiveMessage. Message Received", addr, data, len(data) ) + print ("DEBUG: CallbackReceiveMessage. Message Received", addr, data, len(data) ) # Convert the received address to the CAS BACnet Stack connection string format. ip_as_bytes = bytes(map(int, addr[0].split("."))) @@ -407,13 +407,12 @@ def main(args): downstream_Device_ip_address = args[0] print("FYI: Using " + str(downstream_Device_ip_address) + " for the downstream device IP address") print("FYI: Loading CAS BACnet Stack functions... ") - # TODO: + + udpSocket.bind(('', SETTING_BACNET_IP_PORT)) + udpSocket.setblocking(False) print ("OK") - # "FYI: CAS BACnet Stack version: " << fpGetAPIMajorVersion() << "." << fpGetAPIMinorVersion() << "." << - # fpGetAPIPatchVersion() << "." << fpGetAPIBuildVersion() - print("FYI: Registering the callback Functions with the CAS BACnet Stack") # --------------------------------------------------------------------------- @@ -454,7 +453,7 @@ def main(args): print ("FYI: Entering main loop...") while True: # Call the DLLs loop function which checks for messages and processes them. - # fpLoop() + CASBACnetStack.BACnetStack_Tick() print ("FYI: Waiting for command...") if not DoUserInput(): break diff --git a/CHANGELOG.md b/CHANGELOG.md index e69de29..ff66ca9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -0,0 +1,13 @@ +# Change Log + +## Version 1.0.X + +### Version 1.0.1 (2023Oct06) + +- Updated README.md with more detailed instructions for compiling and building the example. Made sure that all files required for compiling are mentioned. [Issue/6](https://github.com/chipkin/BACnetServerExamplePython/issues/6) +- Fixed looping so that messages from a server device can be received and processed. +- Tested using BACnet Version 4.1.19.2330 + +### Version 1.0.0 (N/A) + +- Initial Release \ No newline at end of file diff --git a/README.md b/README.md index 96cf222..6c9a0c5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,8 @@ # BACnetClientExamplePython2.7 + +## Required Files +Make sure to add the [CASBACnetStack_x64_Debug.dll](https://store.chipkin.com/services/stacks/bacnet-stack) into the source directory. + ## Installing Requirements ### Windows ```cmd @@ -15,7 +19,11 @@ pip2 install -r requirements.txt ```ps python BACnetClientExample.py {IPAddress} ``` +Be sure to remove the {} in the actual command. + ### Linux ```bash python3 BACnetClientExample.py {IPAddress} -``` \ No newline at end of file +``` + +Be sure to remove the {} in the actual command. \ No newline at end of file From b458b39ba8102f5ab878c665dcf7732caa29f201 Mon Sep 17 00:00:00 2001 From: Kaiserchen85 <109826681+Kaiserchen85@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:35:34 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md Fixed date --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff66ca9..d25c447 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## Version 1.0.X -### Version 1.0.1 (2023Oct06) +### Version 1.0.1 (2023-Oct-20) - Updated README.md with more detailed instructions for compiling and building the example. Made sure that all files required for compiling are mentioned. [Issue/6](https://github.com/chipkin/BACnetServerExamplePython/issues/6) - Fixed looping so that messages from a server device can be received and processed. @@ -10,4 +10,4 @@ ### Version 1.0.0 (N/A) -- Initial Release \ No newline at end of file +- Initial Release