Skip to content

Commit

Permalink
Add Privilage violation error and handle errors properly rather than …
Browse files Browse the repository at this point in the history
…returning blank strings
  • Loading branch information
Kaleb Bozorgzadeh committed Oct 26, 2020
1 parent 79620f7 commit b18a28d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/scrub/cip.ex
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
defmodule Scrub.CIP do
def status_code(0x00), do: :success
def status_code(0x06), do: :too_much_data
def status_code(0x0F), do: :privilage_violation
def status_code(status), do: status
end
11 changes: 10 additions & 1 deletion lib/scrub/cip/connection_manager.ex
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ defmodule Scrub.CIP.ConnectionManager do

defp decode_service(
:unconnected_send,
%{size: _size},
%{status_code: :success},
<<
data::binary
>>,
Expand All @@ -218,6 +218,15 @@ defmodule Scrub.CIP.ConnectionManager do
end
end

defp decode_service(
_,
%{status_code: code},
_,
_
) do
{:error, code}
end

defp large_forward_open_network_parameters(opts \\ []) do
owner = opts[:owner] || 0
connection_type = opts[:connection_type] || :point_to_point
Expand Down

0 comments on commit b18a28d

Please sign in to comment.