Skip to content

Update tcp client#28

Merged
pojiro merged 19 commits into
mainfrom
update-tcp-client
May 31, 2026
Merged

Update tcp client#28
pojiro merged 19 commits into
mainfrom
update-tcp-client

Conversation

@pojiro
Copy link
Copy Markdown
Member

@pojiro pojiro commented May 19, 2026

No description provided.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

@pojiro pojiro force-pushed the update-tcp-client branch from 2d14274 to 9896cd9 Compare May 21, 2026 07:14

This comment was marked as outdated.

@pojiro pojiro force-pushed the update-tcp-client branch from dacb863 to 74b380b Compare May 30, 2026 08:43

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/4 forwards a timeout parameter but doesn't pass it to GenServer.call/3 (so the call will still time out after the default 5000ms). This can cause callers using timeout > 5000 to crash with a GenServer.call timeout instead of receiving {:error, :timeout} from the client logic. Also, the guard allows negative timeouts even though the spec says non_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 thread lib/modbuzz/tcp/client.ex
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
@pojiro pojiro merged commit 00b1265 into main May 31, 2026
5 checks passed
@pojiro pojiro deleted the update-tcp-client branch May 31, 2026 04:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants