Skip to content

Commit 7be6570

Browse files
author
CI
committed
Sync to GitHub
1 parent 41404ff commit 7be6570

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

lib/bacnet/stack/transport/mstp_transport.ex

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ if Code.ensure_loaded?(Circuits.UART) do
99
up to 1476 bytes. When sending such large APDUs the receiving device must also support ASHRAE 135-2016,
1010
otherwise it will ignore us, and that's a sad thing to do! As such, sending large APDUs is opt-in.
1111
12+
It can act as a master or slave node, depending on the address this transport is started with.
13+
As a slave node, it'll only be able to respond to request and never be able to initiate requests.
14+
Master nodes actively participate in the Token Passing and are able to send MS/TP frames freely
15+
when holding the token. Slave nodes are restricted to only responding to requests and also are
16+
not able to use segmentation, since segmentation requires nodes to be able to send MS/TP frames
17+
whenever needed.
18+
19+
The recommendation is to always start this transport as master node with a distinct and
20+
unique address in the range `0..127`. Note that other MS/TP nodes `max_master_address`
21+
needs to be considered when selecting an address.
22+
1223
Proprietary frames are sent to the defined `callback` as:
1324
1425
```elixir
@@ -428,7 +439,7 @@ if Code.ensure_loaded?(Circuits.UART) do
428439
- `max_info_frames: pos_integer()` - Optional. This value specifies the maximum number of information
429440
frames the node may send before it must pass the token (defaults to `1`).
430441
- `max_master_address: 0..127` - Optional. The maximum master address that is used in the MS/TP network.
431-
This is used for polling and successor determination. Defaults to `127`.
442+
This is used for polling and successor determination (defaults to `127`).
432443
- `port_name: binary()` - Required. Name of the serial port (use `Circuits.UART.enumerate/0`).
433444
- `supervisor: Supervisor.supervisor()` - Optional. The task supervisor to use to spawn tasks under.
434445
Tasks are spawned to invoke the given callback. If no supervisor is given,
@@ -681,6 +692,7 @@ if Code.ensure_loaded?(Circuits.UART) do
681692
@spec send_test(GenServer.server(), source_address(), iodata()) ::
682693
{:ok, iodata()}
683694
| {:error, term()}
695+
| {:error, :invalid_frame_response}
684696
| {:error, :slave_mode}
685697
| {:error, :token_passing_disabled}
686698
def send_test(portal, destination, data \\ "Hello World")
@@ -1925,6 +1937,16 @@ if Code.ensure_loaded?(Circuits.UART) do
19251937
state
19261938
end
19271939

1940+
# If a test is active, resolve it with an error
1941+
new_state =
1942+
if state.active_test do
1943+
GenServer.reply(state.active_test, {:error, :invalid_frame_response})
1944+
1945+
%{new_state | active_test: nil}
1946+
else
1947+
new_state
1948+
end
1949+
19281950
# Update received frame counter
19291951
new_state = update_received_statistics(:invalid_frame, new_state)
19301952

0 commit comments

Comments
 (0)