Update tcp client#28
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
lib/modbuzz/tcp/client.ex:74
call/4forwards atimeoutparameter but doesn't pass it toGenServer.call/3(so the call will still time out after the default 5000ms). This can cause callers usingtimeout > 5000to crash with aGenServer.calltimeout instead of receiving{:error, :timeout}from the client logic. Also, the guard allows negative timeouts even though the spec saysnon_neg_integer().
def call(name \\ __MODULE__, unit_id \\ 0, request, timeout \\ 5000)
when unit_id in 0x00..0xFF and is_struct(request) and is_integer(timeout) do
GenServer.call(name, {:call, unit_id, request, timeout})
end
Comment on lines
+107
to
110
| def cast(name \\ __MODULE__, unit_id \\ 0, request, pid \\ self(), timeout \\ 5000) | ||
| when unit_id in 0x00..0xFF and is_struct(request) and is_pid(pid) and is_integer(timeout) do | ||
| GenServer.cast(name, {:cast, unit_id, request, pid, timeout}) | ||
| end |
Comment on lines
70
to
+75
| defp request(data_source, unit_id, request, timeout) do | ||
| case GenServer.call(data_source, {:call, unit_id, request, timeout}) do | ||
| {:ok, response} -> response | ||
| {:error, error} -> error | ||
| {:ok, pdu} when is_struct(pdu) -> pdu | ||
| {:error, pdu} when is_struct(pdu) -> pdu | ||
| {:error, _reason} -> nil | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.