This repository was archived by the owner on Oct 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBACnetClientExample.py
More file actions
471 lines (405 loc) · 24.2 KB
/
BACnetClientExample.py
File metadata and controls
471 lines (405 loc) · 24.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
import ctypes
import sys
import time
import socket
from io import BlockingIOError
import keyboard
from CASBACnetStackExampleConstants import *
from CASBACnetStackAdapter import * # Contains all the Enumerations, and callback prototypes
import pathlib
APPLICATION_VERSION = "0.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"
downstreamConnectionString = None # TODO: Update accordingly
invokeId = None
udpSocket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
def DoUserInput():
"""
Function checks if the user has hit any key and return false if quit key is hit
:returns false for quit and true for no key hit
:return:
"""
action = keyboard.read_key()
if not action:
return True
print (action)
if action == "q":
return False
elif action == "w":
ExampleWhoIs()
pass
elif action == "r":
ExampleReadProperty()
pass
elif action == "u":
ExampleWriteProperty()
pass
elif action == "c":
ExampleSubscribeCOV()
pass
elif action == "t":
ExampleConfirmedTextMessage()
pass
else:
print("CAS BACnet Stack Client Example v", APPLICATION_VERSION)
print ("https://github.com/chipkin/BACnetClientExamplePython2.7")
print ("Usage: BACnetClient {IPAddress}")
print ("Example: BACnetClient 192.168.1.127")
print ("Help")
print ("- Q - Quit")
print ("- W - Send WhoIs message")
print("- R - Send Read property messages")
print ("- U - Send Write property messages")
print ("- C - Send Subscribe COV Request")
print("- T - Send Confirmed Text Message Request")
return True
def WaitForResponse(timeout=3):
expireTime = time.time() + timeout
while time.time() < expireTime:
# fpLoop()
pass
def octetStringCopy(source, destination, length, offset=0):
for i in range(length):
destination[int(i + offset)] = int(source[i])
def ExampleWhoIs():
if not downstreamConnectionString:
print ("Error: Invalid connection string")
return
print("Sending WhoIs with no range. timeout=[3]...")
ctype_connection_string = ctypes.cast(downstreamConnectionString, ctypes.POINTER(ctypes.c_uint8))
ctype_connection_string_length = ctypes.c_uint8(6)
ctype_network_type = ctypes.c_uint8(casbacnetstack_networkType["ip"])
ctype_broadcast = ctypes.c_bool(True)
CASBACnetStack.BACnetStack_SendWhoIs(ctype_connection_string, ctype_connection_string_length
, ctype_network_type, ctype_broadcast
,
ctypes.c_uint16(65535), None, ctypes.c_uint8(0))
# CASBACnetStack.BACnetStack_SendWhoIs(ctypes.c_uint32(downstreamConnectionString, 6, 0, True, 0, None, 0)
WaitForResponse()
print("Sending WhoIs with range, low=[389900], high=[389999] 3 second timeout...")
CASBACnetStack.BACnetStack_SendWhoIsWithLimits(ctypes.c_uint32(389900), ctypes.c_uint32(389999),
ctype_connection_string, ctype_connection_string_length,
ctype_network_type, ctype_broadcast, 0,
None, 0)
WaitForResponse()
print("Sending WhoIs to specific network. network=[15], timeout=[3]")
CASBACnetStack.BACnetStack_SendWhoIs(downstreamConnectionString, 6, 0, True, 15, None, 0)
WaitForResponse()
print("Sending WhoIs to broadcast network. network=[65535], timeout=[3]")
CASBACnetStack.BACnetStack_SendWhoIs(downstreamConnectionString, 6, 0, True, 65535, None, 0)
#
WaitForResponse()
def CallbackGetSystemTime():
return int(time.time())
def ExampleReadProperty():
print ("Sending Read Property. DeviceID=[" + str(SETTING_DOWNSTREAM_DEVICE_INSTANCE) + "], property=[" + str(
PROPERTY_IDENTIFIER_ALL) + "], timeout=[3]...")
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_ANALOG_INPUT), ctypes.c_uint32(0),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME), ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_ANALOG_OUTPUT),
ctypes.c_uint32(1),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_ANALOG_VALUE),
ctypes.c_uint32(2),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_BINARY_INPUT),
ctypes.c_uint32(3),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_BINARY_OUTPUT),
ctypes.c_uint32(4),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_BINARY_VALUE),
ctypes.c_uint32(5),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_DEVICE),
ctypes.c_uint32(8),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_MULTI_STATE_INPUT),
ctypes.c_uint32(13),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_MULTI_STATE_OUTPUT),
ctypes.c_uint32(14),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_MULTI_STATE_VALUE),
ctypes.c_uint32(19),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_uint32(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_TREND_LOG),
ctypes.c_uint32(20),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_BITSTRING_VALUE),
ctypes.c_uint32(39),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_CHARACTERSTRING_VALUE),
ctypes.c_uint32(40),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_DATE_VALUE),
ctypes.c_uint32(42),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_INTEGER_VALUE),
ctypes.c_uint32(45),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_LARGE_ANALOG_VALUE),
ctypes.c_uint32(46),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_OCTETSTRING_VALUE),
ctypes.c_uint32(47),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_POSITIVE_INTEGER_VALUE),
ctypes.c_uint32(48),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_TIME_VALUE),
ctypes.c_uint32(50),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_NETWORK_PORT),
ctypes.c_uint32(56),
ctypes.c_uint32(PROPERTY_IDENTIFIER_OBJECT_NAME),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_MULTI_STATE_VALUE),
ctypes.c_uint32(19),
ctypes.c_uint32(PROPERTY_IDENTIFIER_PRESENT_VALUE),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_SendReadProperty(ctypes.cast(invokeId, ctypes.POINTER(ctypes.c_uint8)),
ctypes.cast(downstreamConnectionString, ctypes.POINTER(ctypes.c_uint8)),
ctypes.c_uint8(6),
ctypes.c_uint8(0),
ctypes.c_uint16(0),
ctypes.cast(None, ctypes.POINTER(ctypes.c_uint8)), ctypes.c_uint8(0))
WaitForResponse()
def ExampleWriteProperty():
print("Sending Read Property. AnalogValue, INSTANCE=[2], property=[" + str(PROPERTY_IDENTIFIER_PRESENT_VALUE
) + "], timeout=[3]...")
CASBACnetStack.BACnetStack_BuildReadProperty(ctypes.c_uint16(OBJECT_TYPE_ANALOG_VALUE),
ctypes.c_uint32(2),
ctypes.c_uint32(PROPERTY_IDENTIFIER_PRESENT_VALUE),
ctypes.c_bool(False),
ctypes.c_uint32(0))
CASBACnetStack.BACnetStack_SendReadProperty(ctypes.cast(invokeId, ctypes.POINTER(ctypes.c_uint8)),
ctypes.cast(downstreamConnectionString, ctypes.POINTER(ctypes.c_uint8)),
ctypes.c_uint8(6),
ctypes.c_uint8(0),
ctypes.c_uint16(0),
ctypes.cast(None, ctypes.POINTER(ctypes.c_uint8)), ctypes.c_uint8(0))
WaitForResponse()
print("Sending WriteProperty to the Present Value of Analog Value 2...")
CASBACnetStack.BACnetStack_BuildWriteProperty(4, "1.0", 3, OBJECT_TYPE_ANALOG_VALUE, 2,
PROPERTY_IDENTIFIER_PRESENT_VALUE, False, 0, False,
16)
CASBACnetStack.BACnetStack_SendWriteProperty(invokeId, downstreamConnectionString, 6, 0, 0, None, 0)
WaitForResponse()
print("Sending Read Property. AnalogValue, INSTANCE=[2], property=[" + str(PROPERTY_IDENTIFIER_PRESENT_VALUE
) + "], timeout=[3]...")
CASBACnetStack.BACnetStack_BuildReadProperty(OBJECT_TYPE_ANALOG_VALUE, 2, PROPERTY_IDENTIFIER_PRESENT_VALUE, False,
0)
CASBACnetStack.BACnetStack_SendReadProperty(invokeId, downstreamConnectionString, 6, 0, 0, None, 0)
WaitForResponse()
def ExampleSubscribeCOV():
timeToLive = 60 * 5
analogValueProcessIdentifier = 0
analogInputProcessIdentifier = 1
print("Sending Subscribe COV Request. Analog Input, INSTANCE=[0], timeToLive = " + str(timeToLive) +
", processIdentifier = " + str(analogValueProcessIdentifier))
CASBACnetStack.BACnetStack_SendSubscribeCOV(invokeId, analogInputProcessIdentifier, OBJECT_TYPE_ANALOG_INPUT, 0,
False, timeToLive,
downstreamConnectionString, 6, 0, 0, None, 0)
WaitForResponse()
print("Sending Subscribe COV Request. Analog Value, INSTANCE=[2], timeToLive = " + str(timeToLive) +
", processIdentifier = " + str(analogInputProcessIdentifier))
CASBACnetStack.BACnetStack_SendSubscribeCOV(invokeId, analogValueProcessIdentifier, OBJECT_TYPE_ANALOG_VALUE, 2,
False, timeToLive,
downstreamConnectionString, 6, 0, 0, None, 0)
WaitForResponse()
def ExampleConfirmedTextMessage():
useMessageClass = True
messageClassUnsigned = 5
messageClassString = ""
messagePriority = 0
message = "Hello from the Python client example"
print("Sending Confirmed Text Message")
CASBACnetStack.BACnetStack_SendConfirmedTextMessage(invokeId, SETTING_CLIENT_DEVICE_INSTANCE, useMessageClass,
messageClassUnsigned,
messageClassString, len(messageClassString), messagePriority,
message, len(message),
downstreamConnectionString, 6, 0, 0, None, 0);
WaitForResponse()
def CallbackReceiveMessage(message, maxMessageLength, receivedConnectionString, maxConnectionStringLength,
receivedConnectionStringLength,
networkType):
try:
data, addr = udpSocket.recvfrom(maxMessageLength)
# if not data:
# print("DEBUG: not data")
# A message was received.
# 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(".")))
for index, value in enumerate(ip_as_bytes):
receivedConnectionString[index] = value
# UDP Port
receivedConnectionString[4] = int(addr[1] / 256)
receivedConnectionString[5] = addr[1] % 256
# New ConnectionString Length
receivedConnectionStringLength[0] = 6
# Convert the received data to a format that CAS BACnet Stack can process.
for i in range(len(data)):
message[i] = data[i]
# Set the network type
networkType[0] = ctypes.c_uint8(casbacnetstack_networkType["ip"])
return len(data)
except BlockingIOError:
# No message, We are not waiting for a incoming message so our socket returns a BlockingIOError. This is normal.
return 0
# Catch all
return 0
def CallbackSendMessage(message, messageLength, connectionString, connectionStringLength, networkType, broadcast):
# Currently we are only supporting IP
if networkType != casbacnetstack_networkType["ip"]:
print("Error: Unsupported network type. networkType:", networkType)
return 0
# Extract the Connection String from CAS BACnet Stack into an IP address and port.
udpPort = connectionString[4] * 256 + connectionString[5]
if broadcast:
# Use broadcast IP address
# ToDo: Get the subnet mask and apply it to the IP address
ipAddress = str(connectionString[0]) + "." + str(connectionString[1]) + "." + str(
connectionString[2]) + "." + str(connectionString[3])
else:
ipAddress = str(connectionString[0]) + "." + str(connectionString[1]) + "." + str(
connectionString[2]) + "." + str(connectionString[3])
# Extract the message from CAS BACnet Stack to a bytearray
data = bytearray(messageLength)
for i in range(len(data)):
data[i] = message[i]
# Send the message
udpSocket.sendto(data, (ipAddress, udpPort))
# print("Sent message:" + str(message) + "\n to:" + str(ipAddress) + "\n Port:" + str(
# udpPort) + "\n Message lenth:" + str(messageLength))
return messageLength
def SetServiceIamEnabled():
pass
def convertIpAddStringToConnectionString(IPAddress, Port):
import struct
ConnectionString = [None] * 6
# print (IPAddress)
ip_as_bytes = struct.unpack('BBBB', socket.inet_aton(IPAddress)) # bytes(map(int, IPAddress.split(".")))
print (ip_as_bytes)
for index, value in enumerate(ip_as_bytes):
print (value)
ConnectionString[index] = value
# UDP Port
ConnectionString[4] = int(Port / 256)
ConnectionString[5] = Port % 256
print (ConnectionString)
return ConnectionString
def generateAddressString(ip_address, port):
addressString = (ctypes.c_uint8 * 6)()
octetStringCopy(ip_address.split("."), addressString, 4)
addressString[4] = int(port / 256)
addressString[5] = port % 256
return addressString
def main(args):
print ("CAS BACnet Stack Client Example v" + str(APPLICATION_VERSION) + ".") # +CIBUILDNUMBER
print("https://github.com/chipkin/BACnetClientExamplePython2.7")
# Print the version information
print("FYI: CAS BACnet Stack version: " + str(CASBACnetStack.BACnetStack_GetAPIMajorVersion()) + "." +
str(CASBACnetStack.BACnetStack_GetAPIMinorVersion()) +
"." + str(CASBACnetStack.BACnetStack_GetAPIPatchVersion()) + "." +
str(CASBACnetStack.BACnetStack_GetAPIBuildVersion()))
print("FYI: CAS BACnet Stack python adapter version:" + str(casbacnetstack_adapter_version))
downstream_Device_ip_address = SETTING_DEFAULT_DOWNSTREAM_DEVICE_IP_ADDRESS
if len(args) >= 1:
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:
print ("OK")
# "FYI: CAS BACnet Stack version: " << fpGetAPIMajorVersion() << "." << fpGetAPIMinorVersion() << "." <<
# fpGetAPIPatchVersion() << "." << fpGetAPIBuildVersion()
print("FYI: Registering the callback Functions with the CAS BACnet Stack")
# ---------------------------------------------------------------------------
# Note:
# Make sure you keep references to CFUNCTYPE() objects as long as they are used from C code.
# ctypes doesn't, and if you don"t, they may be garbage collected, crashing your program when
# a callback is made
#
# Because of garbage collection, the pyCallback**** functions need to stay in scope.
pyCallbackReceiveMessage = fpCallbackReceiveMessage(CallbackReceiveMessage)
CASBACnetStack.BACnetStack_RegisterCallbackReceiveMessage(pyCallbackReceiveMessage)
pyCallbackSendMessage = fpCallbackSendMessage(CallbackSendMessage)
CASBACnetStack.BACnetStack_RegisterCallbackSendMessage(pyCallbackSendMessage)
pyCallbackGetSystemTime = fpCallbackGetSystemTime(CallbackGetSystemTime)
CASBACnetStack.BACnetStack_RegisterCallbackGetSystemTime(pyCallbackGetSystemTime)
print("Setting up client device. device.instance=[" + str(SETTING_CLIENT_DEVICE_INSTANCE) + "]")
if not CASBACnetStack.BACnetStack_AddDevice(SETTING_CLIENT_DEVICE_INSTANCE):
print("Failed to add Device.")
return False
# TODO:
print("Created Device.")
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_I_AM, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_I_HAVE, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_WHO_IS, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_WHO_HAS, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_READ_PROPERTY_MULTIPLE, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_WRITE_PROPERTY, True)
CASBACnetStack.BACnetStack_SetServiceEnabled(SETTING_CLIENT_DEVICE_INSTANCE, SERVICE_WRITE_PROPERTY_MULTIPLE, True)
print("Generated the connection string for the downstream device. ")
global downstreamConnectionString
downstreamConnectionString = generateAddressString(ip_address=downstream_Device_ip_address,
port=SETTING_DOWNSTREAM_DEVICE_PORT)
print ("FYI: Entering main loop...")
while True:
# Call the DLLs loop function which checks for messages and processes them.
# fpLoop()
print ("FYI: Waiting for command...")
if not DoUserInput():
break
# Call Sleep to give some time back to the system
time.sleep(0)
if __name__ == "__main__":
# Load the shared library into ctypes
libpath = pathlib.Path().absolute() / libname
print("FYI: Libary path: ", libpath)
CASBACnetStack = ctypes.CDLL(str(libpath), mode=ctypes.RTLD_GLOBAL)
args = sys.argv[1:]
main(args=args)