..
 #############################################################
 # This file was automatically generated on 2015-05-08.      #
 #                                                           #
 # If you have a bugfix for this file and want to commit it, #
 # please fix the bug in the generator. You can find a link  #
 # to the generators git repository on tinkerforge.com       #
 #############################################################


:breadcrumbs: <a href="../../index.html">Home</a> / <a href="../../index.html#software-tcpip">Software</a> / TCP/IP - Industrial Dual 0-20mA Bricklet

.. |device_identifier_constant| unicode:: 0xA0
   :trim:

.. _industrial_dual_0_20ma_bricklet_tcpip:

TCP/IP - Industrial Dual 0-20mA Bricklet
========================================

This is the description of the :ref:`TCP/IP protocol <llproto_tcpip>` for the :ref:`Industrial Dual 0-20mA Bricklet <industrial_dual_0_20ma_bricklet>`. General information and technical
specifications for the Industrial Dual 0-20mA Bricklet are summarized in its :ref:`hardware description
<industrial_dual_0_20ma_bricklet_description>`.

.. _industrial_dual_0_20ma_bricklet_tcpip_api:

API
---

A general description of the TCP/IP protocol structure can be found
:ref:`here <llproto_tcpip>`.


Two sensors can be connected to the Bricklet. Functions that are related
directly to a sensor have a ``sensor`` parameter to specify one of the two
sensors. Valid values for the ``sensor`` parameter are 0 and 1.



Basic Functions
^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletIndustrialDual020mA.get_current

 :functionid: 1
 :request sensor: uint8

 :response current: int32

 Returns the current of the specified sensor (0 or 1). The value is in nA
 and between 0nA and 22505322nA (22.5mA).
 
 It is possible to detect if an IEC 60381-1 compatible sensor is connected
 and if it works probably.
 
 If the returned current is below 4mA, there is likely no sensor connected
 or the sensor may be defect. If the returned current is over 20mA, there might
 be a short circuit or the sensor may be defect.
 
 If you want to get the current periodically, it is recommended to use the
 callback :tcpip:func:`CALLBACK_CURRENT <BrickletIndustrialDual020mA.CALLBACK_CURRENT>` and set the period with 
 :tcpip:func:`set_current_callback_period <BrickletIndustrialDual020mA.set_current_callback_period>`.
 


Advanced Functions
^^^^^^^^^^^^^^^^^^

.. tcpip:function:: BrickletIndustrialDual020mA.set_sample_rate

 :functionid: 8
 :request rate: uint8

 :noresponse: no response

 Sets the sample rate to either 240, 60, 15 or 4 samples per second.
 The resolution for the rates is 12, 14, 16 and 18 bit respectively.
 
 .. csv-table::
  :header: "Value", "Description"
  :widths: 10, 100
 
  "0",    "240 samples per second, 12 bit resolution"
  "1",    "60 samples per second, 14 bit resolution"
  "2",    "15 samples per second, 16 bit resolution"
  "3",    "4 samples per second, 18 bit resolution"
 
 The default value is 3: 4 samples per second with 18 bit resolution.
 
.. tcpip:function:: BrickletIndustrialDual020mA.get_sample_rate

 :functionid: 9
 :emptyrequest: empty payload

 :response rate: uint8

 Returns the sample rate as set by :tcpip:func:`set_sample_rate <BrickletIndustrialDual020mA.set_sample_rate>`.
 
.. tcpip:function:: BrickletIndustrialDual020mA.get_identity

 :functionid: 255
 :emptyrequest: empty payload

 :response uid: char[8]
 :response connected_uid: char[8]
 :response position: char
 :response hardware_version: uint8[3]
 :response firmware_version: uint8[3]
 :response device_identifier: uint16

 Returns the UID, the UID where the Bricklet is connected to, 
 the position, the hardware and firmware version as well as the
 device identifier.
 
 The position can be 'a', 'b', 'c' or 'd'.
 
 The device identifier numbers can be found :ref:`here <device_identifier>`.
 |device_identifier_constant|
 


Callback Configuration Functions
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^



.. tcpip:function:: BrickletIndustrialDual020mA.set_current_callback_period

 :functionid: 2
 :request sensor: uint8
 :request period: uint32

 :noresponse: no response

 Sets the period in ms with which the :tcpip:func:`CALLBACK_CURRENT <BrickletIndustrialDual020mA.CALLBACK_CURRENT>` callback is triggered
 periodically for the given sensor. A value of 0 turns the callback off.
 
 :tcpip:func:`CALLBACK_CURRENT <BrickletIndustrialDual020mA.CALLBACK_CURRENT>` is only triggered if the current has changed since the
 last triggering.
 
 The default value is 0.
 
.. tcpip:function:: BrickletIndustrialDual020mA.get_current_callback_period

 :functionid: 3
 :request sensor: uint8

 :response period: uint32

 Returns the period as set by :tcpip:func:`set_current_callback_period <BrickletIndustrialDual020mA.set_current_callback_period>`.
 
.. tcpip:function:: BrickletIndustrialDual020mA.set_current_callback_threshold

 :functionid: 4
 :request sensor: uint8
 :request option: char
 :request min: int32
 :request max: int32

 :noresponse: no response

 Sets the thresholds for the :tcpip:func:`CALLBACK_CURRENT_REACHED <BrickletIndustrialDual020mA.CALLBACK_CURRENT_REACHED>` callback for the given
 sensor.
 
 The following options are possible:
 
 .. csv-table::
  :header: "Option", "Description"
  :widths: 10, 100
 
  "'x'",    "Callback is turned off"
  "'o'",    "Callback is triggered when the current is *outside* the min and max values"
  "'i'",    "Callback is triggered when the current is *inside* the min and max values"
  "'<'",    "Callback is triggered when the current is smaller than the min value (max is ignored)"
  "'>'",    "Callback is triggered when the current is greater than the min value (max is ignored)"
 
 The default value is ('x', 0, 0).
 
.. tcpip:function:: BrickletIndustrialDual020mA.get_current_callback_threshold

 :functionid: 5
 :request sensor: uint8

 :response option: char
 :response min: int32
 :response max: int32

 Returns the threshold as set by :tcpip:func:`set_current_callback_threshold <BrickletIndustrialDual020mA.set_current_callback_threshold>`.
 
.. tcpip:function:: BrickletIndustrialDual020mA.set_debounce_period

 :functionid: 6
 :request debounce: uint32

 :noresponse: no response

 Sets the period in ms with which the threshold callback
 
 * :tcpip:func:`CALLBACK_CURRENT_REACHED <BrickletIndustrialDual020mA.CALLBACK_CURRENT_REACHED>`
 
 is triggered, if the threshold
 
 * :tcpip:func:`set_current_callback_threshold <BrickletIndustrialDual020mA.set_current_callback_threshold>`
 
 keeps being reached.
 
 The default value is 100.
 
.. tcpip:function:: BrickletIndustrialDual020mA.get_debounce_period

 :functionid: 7
 :emptyrequest: empty payload

 :response debounce: uint32

 Returns the debounce period as set by :tcpip:func:`set_debounce_period <BrickletIndustrialDual020mA.set_debounce_period>`.
 


.. _industrial_dual_0_20ma_bricklet_tcpip_callbacks:

Callbacks
^^^^^^^^^

.. tcpip:function:: BrickletIndustrialDual020mA.CALLBACK_CURRENT

 :functionid: 10

 :response sensor: uint8
 :response current: int32


 This callback is triggered periodically with the period that is set by
 :tcpip:func:`set_current_callback_period <BrickletIndustrialDual020mA.set_current_callback_period>`. The response value is the current of the
 sensor.
 
 :tcpip:func:`CALLBACK_CURRENT <BrickletIndustrialDual020mA.CALLBACK_CURRENT>` is only triggered if the current has changed since the
 last triggering.
 
.. tcpip:function:: BrickletIndustrialDual020mA.CALLBACK_CURRENT_REACHED

 :functionid: 11

 :response sensor: uint8
 :response current: int32


 This callback is triggered when the threshold as set by
 :tcpip:func:`set_current_callback_threshold <BrickletIndustrialDual020mA.set_current_callback_threshold>` is reached.
 The response value is the current of the sensor.
 
 If the threshold keeps being reached, the callback is triggered periodically
 with the period as set by :tcpip:func:`set_debounce_period <BrickletIndustrialDual020mA.set_debounce_period>`.
 


