Modbux.Tcp.Client (Modbux v0.3.14)
View SourceAPI for Modbus TCP Client.
Summary
Functions
Returns a specification to start this module under a supervisor.
Close the tcp port of the Client.
Configure the Client (status must be :closed).
In passive mode (active: false), reads the confirmation of the connected Modbux Server.
Connect the Client to a Server.
In passive mode (active: false), flushed the pending messages.
Callback implementation for GenServer.init/1.
Send a request to Modbux TCP Server.
Starts a Modbus TCP Client process.
Gets the state of the Client.
Stops the Client.
Types
@type client_option() :: {:ip, {byte(), byte(), byte(), byte()}} | {:active, boolean()} | {:tcp_port, non_neg_integer()} | {:timeout, non_neg_integer()}
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Close the tcp port of the Client.
Configure the Client (status must be :closed).
The following options are available:
ip- is the internet address of the desired Modbux TCP Server.tcp_port- is the Modbux TCP Server tcp port number .timeout- is the connection timeout.active- (trueorfalse) specifies whether data is received as messages (mailbox) or by callingconfirmation/1each timerequest/2is called.
In passive mode (active: false), reads the confirmation of the connected Modbux Server.
Connect the Client to a Server.
In passive mode (active: false), flushed the pending messages.
Callback implementation for GenServer.init/1.
Send a request to Modbux TCP Server.
cmd is a 4 elements tuple, as follows:
{:rc, slave, address, count}readcountcoils.{:ri, slave, address, count}readcountinputs.{:rhr, slave, address, count}readcountholding registers.{:rir, slave, address, count}readcountinput registers.{:fc, slave, address, value}force single coil.{:phr, slave, address, value}preset single holding register.{:fc, slave, address, values}force multiple coils.{:phr, slave, address, values}preset multiple holding registers.
Starts a Modbus TCP Client process.
The following options are available:
ip- is the internet address of the desired Modbux TCP Server.tcp_port- is the desired Modbux TCP Server tcp port number.timeout- is the connection timeout.active- (trueorfalse) specifies whether data is received as messages (mailbox) or by callingconfirmation/1each timerequest/2is called.
The messages (when active mode is true) have the following form:
{:modbus_tcp, cmd, values}
Example
Modbux.Tcp.Client.start_link(ip: {10,77,0,2}, port: 502, timeout: 2000, active: true)
Gets the state of the Client.
Stops the Client.