Astarte.Flow.Blocks.ModbusTCPSource (astarte_flow v0.1.0)
An Astarte Flow source that produces data by polling a Modbus device. This block is built to poll a single Modbus slave, if you want to poll multiple slaves you must instantiate multiple flows changing the slave id.
The message contains these fields:
keycontains the name defined in the configurationdatacontains the data read from the Modbus device, converted with the format indicated in the configuration.typedepends on the format indicated in the configuration.metadatacontains the static metadata indicated in the configuration.timestampcontains the timestamp (in microseconds) the message was polled on.
Since polling happens at regular intervals while Flow works in a demand-driven way, this block implements a queue to buffer incoming messages while waiting for consumer demand.
Link to this section Summary
Functions
Starts the ModbusTCPSource.
Link to this section Functions
Link to this function
start_link(opts)
@spec start_link(opts) :: GenServer.on_start() when opts: [opt], opt: {:host, String.t()} | {:port, integer()} | {:slave_id, integer()} | {:targets, [map(), ...]}
Starts the ModbusTCPSource.
options
Options
host(required): the IP address of the Modbus master this block will connect to.slave_id(required): the slave id that will be polled.targets(required): an array of maps representing the polling targets. See the section below for the structure of the map.port: the TCP port. Defaults to 502, which is the standard Modbus TCP port.
target-map
Target map
Each map in the targets option must have this keys, with string keys:
name(required): the name of the measured quantity. This will be used askeyin the resulting Flow Messagebase_address(required): the address where the data starts. Depending onformat, one or more registers will be read starting from this address.format(required): one of:int16,:uint16,:float32be,:float32le,:boolean. Thebeandlesuffix infloat32format indicates the endianness, i.e. the order of the two 16 bits halves.modbus_type(required): one of:coil,:discrete_input,:input_register,:holding_register.polling_interval_ms(required): the interval between two polling on this target. Must be- Caveat: currently this block only supports setting the same
polling_interval_msfor all targets, this limitation will be removed in a future release.
- Caveat: currently this block only supports setting the same
static_metadata: a map containing some static metadata that will be added to the message in themetadatafield. It can be used to add information (e.g. units of measurement).