tm_mercury v0.6.0 TM.Mercury.Reader

Link to this section Summary

Functions

Execute the reader's bootloader

Execute the reader's firmware from the bootloader

Returns a specification to start this module under a supervisor

Clear the tag buffer

Enumerate the logical antenna ports and report the antenna detection status of each one

Invoked in order to access the value stored under key in the given term term

Invoked in order to access the value under key and update it at the same time

Return the antenna port configuration used by the reader

Return the antenna return loss of logical antenna ports

Return the identity of the program currently running on the device

Return the current value of an optional reader parameter with a given key

Get the power-consumption mode of the reader

Get the current TX power for reading tags in centi-dBm

Return the RF regulatory environment that the reader will operate within

Return the tags that have accumulated in the reader's buffer while waiting on a synchronous read timeout to expire

Return the tag protocol used by the reader

Get the radio's temperature

Return the current TX and RX antenna port

Return hardware, firmware, and bootloader version details

Catch-all handlers for op commands that don't require state binding or special handling

Invoked when the server is started. start_link/3 or start/3 will block until it returns

Invoked to "pop" the value under key out of the given data structure

Stop reading tags asynchronously

Reboot the reader

Disconnect the reader

Set the antenna port configuration used by the reader

Set the reader's serial baud rate

Set the value of an optional reader parameter with a given key

Set the power-consumption mode of the reader

Set the current TX power for reading tags in centi-dBm

Set the RF regulatory environment that the reader will operate within

Set the tag protocol used by the reader

Start a process and open a connection with the reader over UART connected via TTL / USB

Return the reader's transport connection status

Link to this section Types

Link to this type

command_result()
command_result() :: :ok

Link to this type

error()
error() :: {:error, term()}

Link to this type

query_result()
query_result() :: {:ok, term()}

Link to this type

read_timeout()
read_timeout() :: pos_integer()

Link to this section Functions

Link to this function

boot_bootloader(pid)
boot_bootloader(pid()) :: command_result() | error()

Execute the reader's bootloader.

Link to this function

boot_firmware(pid)
boot_firmware(pid()) :: command_result() | error()

Execute the reader's firmware from the bootloader.

Link to this function

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

clear_tag_id_buffer(pid)
clear_tag_id_buffer(pid()) :: command_result() | error()

Clear the tag buffer.

Link to this function

detect_antennas(pid)

Enumerate the logical antenna ports and report the antenna detection status of each one.

Link to this function

fetch(term, key)

Invoked in order to access the value stored under key in the given term term.

This function should return {:ok, value} where value is the value under key if the key exists in the term, or :error if the key does not exist in the term.

Many of the functions defined in the Access module internally call this function. This function is also used when the square-brackets access syntax (structure[key]) is used: the fetch/2 callback implemented by the module that defines the structure struct is invoked and if it returns {:ok, value} then value is returned, or if it returns :error then nil is returned.

See the Map.fetch/2 and Keyword.fetch/2 implementations for examples of how to implement this callback.

Callback implementation for Access.fetch/2.

Link to this function

get(structure, key, default)

Link to this function

get_and_update(data, key, function)

Invoked in order to access the value under key and update it at the same time.

The implementation of this callback should invoke fun with the value under key in the passed structure data, or with nil if key is not present in it. This function must return either {get_value, update_value} or :pop.

If the passed function returns {get_value, update_value}, the return value of this callback should be {get_value, new_data}, where:

  • get_value is the retrieved value (which can be operated on before being returned)

  • update_value is the new value to be stored under key

  • new_data is data after updating the value of key with update_value.

If the passed function returns :pop, the return value of this callback must be {value, new_data} where value is the value under key (or nil if not present) and new_data is data without key.

See the implementations of Map.get_and_update/3 or Keyword.get_and_update/3 for more examples.

Callback implementation for Access.get_and_update/3.

Link to this function

get_antenna_port(pid)
get_antenna_port(pid()) :: query_result() | error()

Return the antenna port configuration used by the reader

Link to this function

get_antenna_return_loss(pid)

Return the antenna return loss of logical antenna ports.

Link to this function

get_current_program(pid)
get_current_program(pid()) :: query_result() | error()

Return the identity of the program currently running on the device.

Link to this function

get_param(pid, key)
get_param(pid(), atom()) :: query_result() | error()

Return the current value of an optional reader parameter with a given key.

Link to this function

get_power_mode(pid)
get_power_mode(pid()) :: query_result() | error()

Get the power-consumption mode of the reader.

This is not related to the TX/RX power.

Link to this function

get_read_tx_power(pid)
get_read_tx_power(pid()) :: query_result() | error()

Get the current TX power for reading tags in centi-dBm.

Examples

iex> TM.Mercury.Reader.get_read_tx_power(pid)
{:ok, 2500} # 25 dBm
Link to this function

get_reader_stats(pid, option, flags)

TODO

Link to this function

get_region(pid)
get_region(pid()) :: query_result() | error()

Return the RF regulatory environment that the reader will operate within.

Link to this function

get_tag_id_buffer(pid, metadata_flags)
get_tag_id_buffer(pid(), list()) :: query_result() | error()

Return the tags that have accumulated in the reader's buffer while waiting on a synchronous read timeout to expire.

Link to this function

get_tag_protocol(pid)
get_tag_protocol(pid()) :: query_result() | error()

Return the tag protocol used by the reader

Link to this function

get_temperature(pid)
get_temperature(pid()) :: query_result() | error()

Get the radio's temperature

Link to this function

get_tx_rx_ports(pid)

Return the current TX and RX antenna port.

Link to this function

get_version(pid)
get_version(pid()) :: query_result() | error()

Return hardware, firmware, and bootloader version details.

Link to this function

handle_call(msg, from, state)

Catch-all handlers for op commands that don't require state binding or special handling

Invoked when the server is started. start_link/3 or start/3 will block until it returns.

init_arg is the argument term (second argument) passed to start_link/3.

Returning {:ok, state} will cause start_link/3 to return {:ok, pid} and the process to enter its loop.

Returning {:ok, state, timeout} is similar to {:ok, state} except handle_info(:timeout, state) will be called after timeout milliseconds if no messages are received within the timeout.

Returning {:ok, state, :hibernate} is similar to {:ok, state} except the process is hibernated before entering the loop. See c:handle_call/3 for more information on hibernation.

Returning {:ok, state, {:continue, continue}} is similar to {:ok, state} except that immediately after entering the loop the c:handle_continue/2 callback will be invoked with the value continue as first argument.

Returning :ignore will cause start_link/3 to return :ignore and the process will exit normally without entering the loop or calling c:terminate/2. If used when part of a supervision tree the parent supervisor will not fail to start nor immediately try to restart the GenServer. The remainder of the supervision tree will be started and so the GenServer should not be required by other processes. It can be started later with Supervisor.restart_child/2 as the child specification is saved in the parent supervisor. The main use cases for this are:

  • The GenServer is disabled by configuration but might be enabled later.
  • An error occurred and it will be handled by a different mechanism than the Supervisor. Likely this approach involves calling Supervisor.restart_child/2 after a delay to attempt a restart.

Returning {:stop, reason} will cause start_link/3 to return {:error, reason} and the process to exit with reason reason without entering the loop or calling c:terminate/2.

Callback implementation for GenServer.init/1.

Invoked to "pop" the value under key out of the given data structure.

When key exists in the given structure data, the implementation should return a {value, new_data} tuple where value is the value that was under key and new_data is term without key.

When key is not present in the given structure, a tuple {value, data} should be returned, where value is implementation-defined.

See the implementations for Map.pop/3 or Keyword.pop/3 for more examples.

Callback implementation for Access.pop/2.

Link to this function

read_async_start(pid, listener, on_time_ms \\ 100, off_time_ms \\ 400, rp \\ %{__struct__: TM.Mercury.SimpleReadPlan, antennas: {1, 1}, autonomous_read: false, fast_search: false, filter: "", protocol: :gen2, tag_op: nil, weight: 1000}, rate_limit \\ :infinity)
read_async_start(
  pid(),
  pid(),
  pos_integer(),
  pos_integer(),
  read_plan(),
  timeout()
) :: query_result() | error()

Start reading tags asynchronously using a custom read plan. Tag reads will be sent to the process with pid listener until stop_read_async is called.

If on_time_ms is not provided, it will default to 100. If off_time_ms is not provided, it will default to 400.

If a read plan is not provided, it will default to SimpleReadPlan.

Link to this function

read_async_stop(pid)

Stop reading tags asynchronously

Link to this function

read_sync(pid, timeout_ms \\ 100, rp \\ %{__struct__: TM.Mercury.SimpleReadPlan, antennas: {1, 1}, autonomous_read: false, fast_search: false, filter: "", protocol: :gen2, tag_op: nil, weight: 1000})
read_sync(pid(), read_timeout(), read_plan()) :: query_result() | error()

Read tags synchronously using a read plan and timeout.

If a timeout is not provided, it will default to 100. If a read plan is not provided, it will default to SimpleReadPlan.

Link to this function

reboot(pid)
reboot(pid()) :: command_result() | error()

Reboot the reader.

Link to this function

reconnect(pid)
reconnect(pid()) :: command_result() | error()

Disconnect the reader.

The connection will be restarted.

Link to this function

reset_reader_stats(pid, flags)

TODO

Link to this function

set_antenna_port(pid, ports)
set_antenna_port(pid(), term()) :: command_result() | error()

Set the antenna port configuration used by the reader

Link to this function

set_baud_rate(pid, rate)
set_baud_rate(pid(), pos_integer()) :: command_result() | error()

Set the reader's serial baud rate.

The host's baud rate must be changed separately.

Link to this function

set_param(pid, key, value)
set_param(pid(), atom(), term()) :: query_result() | error()

Set the value of an optional reader parameter with a given key.

Link to this function

set_power_mode(pid, mode)
set_power_mode(pid(), atom()) :: command_result() | error()

Set the power-consumption mode of the reader.

Link to this function

set_read_tx_power(pid, level)
set_read_tx_power(pid(), number()) :: command_result() | error()

Set the current TX power for reading tags in centi-dBm.

Examples

iex> TM.Mercury.Reader.set_read_tx_power(pid, 2500) # 25 dBm
:ok
Link to this function

set_region(pid, region)
set_region(pid(), atom()) :: command_result() | error()

Set the RF regulatory environment that the reader will operate within.

Link to this function

set_tag_protocol(pid, protocol)
set_tag_protocol(pid(), atom()) :: command_result() | error()

Set the tag protocol used by the reader

Link to this function

start_link(device, opts \\ [])
start_link(String.t(), keyword()) :: {:ok, pid()} | error()

Start a process and open a connection with the reader over UART connected via TTL / USB

The reader requires the following parameters:

  • device - the device file for the reader serial connection.

Optional Parameters

The following keys are optional:

  • speed - the serial port speed. Defaults to 115200.
  • region - the regulatory RF environment used by the reader. Defaults to :na (North America).

    • :none - Unspecified region
    • :na - North America
    • :eu - European Union
    • :kr - Korea
    • :in - India
    • :jp - Japan
    • :prc - People's Republic of China
    • :eu2 - European Union 2
    • :eu3 - European Union 3
    • :kr2 - Korea 2
    • :prc2 - People's Republic of China (840 MHz)
    • :au - Australia
    • :nz - New Zealand (Experimental)
    • :na2 - Reduced FCC region
    • :na3 - 5 MHz FCC band
    • :open - Open
  • power_mode - the power-consumption mode of the reader. Defaults to :full.

    • :full
    • :min_save
    • :med_save
    • :max_save
    • :sleep

Return the reader's transport connection status