Skip to content

Commit

Permalink
0.17.6 released
Browse files Browse the repository at this point in the history
  • Loading branch information
Joel Bender committed Apr 19, 2019
1 parent fd27c54 commit 4111b86
Show file tree
Hide file tree
Showing 71 changed files with 3,879 additions and 445 deletions.
4 changes: 2 additions & 2 deletions doc/source/gettingstarted/gettingstarted001.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ Updating the INI File

Now that you know what these values are going to be, you can
configure the BACnet portion of your workstation. Change into the
samples directory that you checked out earlier, make a copy
bacpypes directory that you checked out earlier, make a copy
of the sample configuration file, and edit it for your site::

$ cd bacpypes/samples
$ cd bacpypes
$ cp BACpypes~.ini BACpypes.ini

.. tip::
Expand Down
36 changes: 18 additions & 18 deletions doc/source/modules/npdu.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@ PDU Base Types

.. class:: NPCI(PCI)

This is a long line of text.
Header of the network layer message.

.. attribute:: npduVersion

This is a long line of text.
This is the version number of the BACnet protocol used. Current version is (1).

.. attribute:: npduControl

This is a long line of text.
This is the a single octet. Each bit of the byte indicates the presence of specific fields in the NPCI.

.. attribute:: npduDADR

This is a long line of text.
This is the destination address of the network layer message.

.. attribute:: npduSADR

This is a long line of text.
This is the source address of the network layer message.

.. attribute:: npduHopCount

This is a long line of text.
This is used to determine if network layer messages are being routed in a circular path.

.. attribute:: npduNetMessage

This is a long line of text.
This is the network layer message type.

.. attribute:: npduVendorID

This is a long line of text.
This is vendor specific ID number used for vendor specific network layer message.

.. method:: update(npci)

Expand Down Expand Up @@ -69,7 +69,7 @@ Service Requests

.. class:: WhoIsRouterToNetwork(NPCI)

This is a long line of text.
This message is used to find the router that is the destination for a specific network. It is also used for routers to update routing tables.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -80,7 +80,7 @@ Service Requests

.. class:: IAmRouterToNetwork(NPCI)

This is a long line of text.
Response to a WhoIsRouterToNetwork request. Contains network numbers of the networks a router provides access to.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -91,7 +91,7 @@ Service Requests

.. class:: ICouldBeRouterToNetwork(NPCI)

This is a long line of text.
Response to a WhoIsRouterToNetwork request. Contains network numbers of the networks a half-router could provide access to over a PTP connection, but the connection is not currently established.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -102,7 +102,7 @@ Service Requests

.. class:: RejectMessageToNetwork(NPCI)

This is a long line of text.
This is a message sent in response to a network layer message that was rejected due to an error.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -113,7 +113,7 @@ Service Requests

.. class:: RouterBusyToNetwork(NPCI)

This is a long line of text.
This is a message sent by a router to temporarily stop messages to specific destination networks.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -124,7 +124,7 @@ Service Requests

.. class:: RouterAvailableToNetwork(NPCI)

This is a long line of text.
This is a message sent by a router to enable or re-enable messages to specific destination networks.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -151,7 +151,7 @@ Service Requests

.. class:: InitializeRoutingTable(NPCI)

This is a long line of text.
This is a message used to initialize the routing table of a router or get the contents of the current routing table.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -162,7 +162,7 @@ Service Requests

.. class:: InitializeRoutingTableAck(NPCI)

This is a long line of text.
This is a message indicating the routing table of a router has been changed or the routing table has been initialized.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -173,7 +173,7 @@ Service Requests

.. class:: EstablishConnectionToNetwork(NPCI)

This is a long line of text.
This is a message used to tell a half-router to make a PTP connection to a network.

.. method:: encode(npdu)
decode(npdu)
Expand All @@ -184,7 +184,7 @@ Service Requests

.. class:: DisconnectConnectionToNetwork(NPCI)

This is a long line of text.
This is a message used to tell a half-router to close a PTP connection to a network.

.. method:: encode(npdu)
decode(npdu)
Expand Down
2 changes: 1 addition & 1 deletion py25/bacpypes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
# Project Metadata
#

__version__ = '0.17.5'
__version__ = '0.17.6'
__author__ = 'Joel Bender'
__email__ = '[email protected]'

Expand Down
10 changes: 7 additions & 3 deletions py25/bacpypes/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,9 +194,13 @@ def decode_packet(data):
if (pdu.pduData[0] == '\x81'):
if _debug: decode_packet._debug(" - BVLL header found")

xpdu = BVLPDU()
xpdu.decode(pdu)
pdu = xpdu
try:
xpdu = BVLPDU()
xpdu.decode(pdu)
pdu = xpdu
except Exception as err:
if _debug: decode_packet._debug(" - BVLPDU decoding error: %r", err)
return pdu

# make a more focused interpretation
atype = bvl_pdu_types.get(pdu.bvlciFunction)
Expand Down
8 changes: 4 additions & 4 deletions py25/bacpypes/apdu.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def encode_max_segments_accepted(arg):
if _max_segments_accepted_encoding[i] <= arg:
return i

raise ValueError("invalid max max segments accepted: {0}".format(arg))
raise ValueError("invalid max max segments accepted: %r" % (arg,))

def decode_max_segments_accepted(arg):
"""Decode the maximum number of segments the device will accept, Section
Expand All @@ -97,12 +97,12 @@ def encode_max_apdu_length_accepted(arg):
if (arg >= _max_apdu_length_encoding[i]):
return i

raise ValueError("invalid max APDU length accepted: {0}".format(arg))
raise ValueError("invalid max APDU length accepted: %r" % (arg,))

def decode_max_apdu_length_accepted(arg):
v = _max_apdu_length_encoding[arg]
if not v:
raise ValueError("invalid max APDU length accepted: {0}".format(arg))
raise ValueError("invalid max APDU length accepted: %r" % (arg,))

return v

Expand Down Expand Up @@ -927,7 +927,7 @@ class RangeByPosition(Sequence):

class RangeBySequenceNumber(Sequence):
sequenceElements = \
[ Element('referenceIndex', Unsigned)
[ Element('referenceSequenceNumber', Unsigned)
, Element('count', Integer)
]

Expand Down
7 changes: 5 additions & 2 deletions py25/bacpypes/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -598,7 +598,7 @@ def close_socket(self):

class BIPNetworkApplication(NetworkServiceElement):

def __init__(self, localAddress, eID=None):
def __init__(self, localAddress, bbmdAddress=None, bbmdTTL=None, eID=None):
if _debug: BIPNetworkApplication._debug("__init__ %r eID=%r", localAddress, eID)
NetworkServiceElement.__init__(self, eID)

Expand All @@ -616,7 +616,10 @@ def __init__(self, localAddress, eID=None):

# create a generic BIP stack, bound to the Annex J server
# on the UDP multiplexer
self.bip = BIPSimple()
if (not bbmdAddress) and (not bbmdTTL):
self.bip = BIPSimple()
else:
self.bip = BIPForeign(bbmdAddress, bbmdTTL)
self.annexj = AnnexJCodec()
self.mux = UDPMultiplexer(self.localAddress)

Expand Down
32 changes: 18 additions & 14 deletions py25/bacpypes/appservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class SSM(OneShotTask, DebugContents):
_debug_contents = ('ssmSAP', 'localDevice', 'device_info', 'invokeID'
, 'state', 'segmentAPDU', 'segmentSize', 'segmentCount', 'maxSegmentsAccepted'
, 'retryCount', 'segmentRetryCount', 'sentAllSegments', 'lastSequenceNumber'
, 'initialSequenceNumber', 'actualWindowSize', 'proposedWindowSize'
, 'initialSequenceNumber', 'actualWindowSize'
)

def __init__(self, sap, pdu_address):
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_segment(self, indx):

# check for invalid segment number
if indx >= self.segmentCount:
raise RuntimeError("invalid segment number {0}, APDU has {1} segments".format(indx, self.segmentCount))
raise RuntimeError("invalid segment number %r, APDU has %r segments" % (indx, self.segmentCount))

if self.segmentAPDU.apduType == ConfirmedRequestPDU.pduType:
if _debug: SSM._debug(" - confirmed request context")
Expand Down Expand Up @@ -193,8 +193,8 @@ def get_segment(self, indx):

# first segment sends proposed window size, rest get actual
if indx == 0:
if _debug: SSM._debug(" - proposedWindowSize: %r", self.proposedWindowSize)
segAPDU.apduWin = self.proposedWindowSize
if _debug: SSM._debug(" - proposedWindowSize: %r", self.ssmSAP.proposedWindowSize)
segAPDU.apduWin = self.ssmSAP.proposedWindowSize
else:
if _debug: SSM._debug(" - actualWindowSize: %r", self.actualWindowSize)
segAPDU.apduWin = self.actualWindowSize
Expand Down Expand Up @@ -506,7 +506,7 @@ def segmented_request(self, apdu):
self.set_segmentation_context(apdu)

# minimum of what the server is proposing and this client proposes
self.actualWindowSize = min(apdu.apduWin, self.proposedWindowSize)
self.actualWindowSize = min(apdu.apduWin, self.ssmSAP.proposedWindowSize)
self.lastSequenceNumber = 0
self.initialSequenceNumber = 0
self.set_state(SEGMENTED_CONFIRMATION, self.segmentTimeout)
Expand Down Expand Up @@ -825,15 +825,15 @@ def confirmation(self, apdu):
return

# make sure client supports segmented receive
if self.device_info.segmentationSupported not in ('segmentedReceive', 'segmentedBoth'):
if not self.segmented_response_accepted:
if _debug: ServerSSM._debug(" - client can't receive segmented responses")
abort = self.abort(AbortReason.segmentationNotSupported)
self.response(abort)
return

# make sure we dont exceed the number of segments in our response
# that the device said it was willing to accept in the request
if self.segmentCount > self.maxSegmentsAccepted:
# that the client said it was willing to accept in the request
if (self.maxSegmentsAccepted is not None) and (self.segmentCount > self.maxSegmentsAccepted):
if _debug: ServerSSM._debug(" - client can't receive enough segments")
abort = self.abort(AbortReason.apduTooLong)
self.response(abort)
Expand Down Expand Up @@ -898,11 +898,12 @@ def idle(self, apdu):
self.invokeID = apdu.apduInvokeID
if _debug: ServerSSM._debug(" - invoke ID: %r", self.invokeID)

if apdu.apduSA:
if not self.device_info:
if _debug: ServerSSM._debug(" - no client device info")
# remember if the client accepts segmented responses
self.segmented_response_accepted = apdu.apduSA

elif self.device_info.segmentationSupported == 'noSegmentation':
# if there is a cache record, check to see if it needs to be updated
if apdu.apduSA and self.device_info:
if self.device_info.segmentationSupported == 'noSegmentation':
if _debug: ServerSSM._debug(" - client actually supports segmented receive")
self.device_info.segmentationSupported = 'segmentedReceive'

Expand Down Expand Up @@ -958,8 +959,11 @@ def idle(self, apdu):

# the window size is the minimum of what I would propose and what the
# device has proposed
self.actualWindowSize = min(apdu.apduWin, self.proposedWindowSize)
if _debug: ServerSSM._debug(" - actualWindowSize? min(%r, %r) -> %r", apdu.apduWin, self.proposedWindowSize, self.actualWindowSize)
self.actualWindowSize = min(apdu.apduWin, self.ssmSAP.proposedWindowSize)
if _debug: ServerSSM._debug(
" - actualWindowSize? min(%r, %r) -> %r",
apdu.apduWin, self.ssmSAP.proposedWindowSize, self.actualWindowSize,
)

# initialize the state
self.lastSequenceNumber = 0
Expand Down
Loading

0 comments on commit 4111b86

Please sign in to comment.