Skip to content
This repository was archived by the owner on Oct 25, 2024. It is now read-only.

Added building details in README and fixed example to receive and process messages from server #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions BACnetClientExample.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,7 +66,7 @@ def DoUserInput():
def WaitForResponse(timeout=3):
expireTime = time.time() + timeout
while time.time() < expireTime:
# fpLoop()
CASBACnetStack.BACnetStack_Tick()
pass


Expand Down Expand Up @@ -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(".")))
Expand Down Expand Up @@ -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")
# ---------------------------------------------------------------------------

Expand Down Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Change Log

## Version 1.0.X

### 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.
- Tested using BACnet Version 4.1.19.2330

### Version 1.0.0 (N/A)

- Initial Release
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
```
```

Be sure to remove the {} in the actual command.