tinkerforge 2.1.23 → 2.1.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +109 -30
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +191 -86
  6. data/lib/tinkerforge/brick_imu_v2.rb +219 -118
  7. data/lib/tinkerforge/brick_master.rb +495 -195
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +186 -102
  10. data/lib/tinkerforge/brick_silent_stepper.rb +248 -168
  11. data/lib/tinkerforge/brick_stepper.rb +212 -100
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +107 -63
  14. data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
  18. data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
  21. data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
  24. data/lib/tinkerforge/bricklet_barometer.rb +108 -58
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
  26. data/lib/tinkerforge/bricklet_can.rb +84 -24
  27. data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
  28. data/lib/tinkerforge/bricklet_co2.rb +36 -25
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
  30. data/lib/tinkerforge/bricklet_color.rb +75 -47
  31. data/lib/tinkerforge/bricklet_color_v2.rb +91 -47
  32. data/lib/tinkerforge/bricklet_compass.rb +81 -40
  33. data/lib/tinkerforge/bricklet_current12.rb +61 -40
  34. data/lib/tinkerforge/bricklet_current25.rb +61 -40
  35. data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
  36. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
  37. data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
  38. data/lib/tinkerforge/bricklet_distance_us_v2.rb +68 -33
  39. data/lib/tinkerforge/bricklet_dmx.rb +92 -48
  40. data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
  41. data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
  42. data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
  43. data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
  44. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
  45. data/lib/tinkerforge/bricklet_energy_monitor.rb +81 -40
  46. data/lib/tinkerforge/bricklet_gps.rb +72 -48
  47. data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
  48. data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
  49. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
  50. data/lib/tinkerforge/bricklet_humidity.rb +54 -38
  51. data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
  52. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  53. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
  54. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
  55. data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
  56. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
  58. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
  60. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
  62. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  63. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
  65. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
  66. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
  67. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
  68. data/lib/tinkerforge/bricklet_io16.rb +57 -32
  69. data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
  70. data/lib/tinkerforge/bricklet_io4.rb +56 -31
  71. data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
  72. data/lib/tinkerforge/bricklet_isolator.rb +111 -35
  73. data/lib/tinkerforge/bricklet_joystick.rb +63 -42
  74. data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
  75. data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
  76. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +99 -51
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +219 -131
  78. data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
  79. data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
  80. data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
  81. data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
  82. data/lib/tinkerforge/bricklet_line.rb +35 -22
  83. data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
  84. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
  85. data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
  86. data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
  87. data/lib/tinkerforge/bricklet_moisture.rb +43 -30
  88. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  89. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
  90. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
  91. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
  92. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -39
  93. data/lib/tinkerforge/bricklet_nfc.rb +130 -80
  94. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  95. data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
  96. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +75 -40
  97. data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
  98. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  99. data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
  100. data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
  101. data/lib/tinkerforge/bricklet_performance_dc.rb +676 -0
  102. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
  103. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  104. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  105. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  106. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  107. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  108. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  109. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  110. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  111. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  112. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  113. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  114. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  115. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  116. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  117. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  118. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -26
  119. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  120. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  121. data/lib/tinkerforge/bricklet_rs485.rb +250 -164
  122. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  123. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  124. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  125. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  126. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  127. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  128. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  129. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  130. data/lib/tinkerforge/bricklet_temperature_ir.rb +61 -47
  131. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +74 -44
  132. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  133. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  134. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  135. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  136. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  137. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  138. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  139. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  140. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  141. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +92 -77
  142. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +81 -36
  143. data/lib/tinkerforge/device_display_names.rb +167 -0
  144. data/lib/tinkerforge/ip_connection.rb +156 -33
  145. data/lib/tinkerforge/version.rb +1 -1
  146. metadata +8 -3
@@ -1,23 +1,23 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-08-23. #
3
+ # This file was automatically generated on 2021-01-15. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.23 #
5
+ # Ruby Bindings Version 2.1.28 #
6
6
  # #
7
7
  # If you have a bugfix for this file and want to commit it, #
8
8
  # please fix the bug in the generator. You can find a link #
9
9
  # to the generators git repository on tinkerforge.com #
10
10
  #############################################################
11
11
 
12
+ require_relative './ip_connection'
13
+
12
14
  module Tinkerforge
13
15
  # Communicates with RS485/Modbus devices with full- or half-duplex
14
16
  class BrickletRS485 < Device
15
17
  DEVICE_IDENTIFIER = 277 # :nodoc:
16
18
  DEVICE_DISPLAY_NAME = 'RS485 Bricklet' # :nodoc:
17
19
 
18
- # This callback is called if new data is available.
19
- #
20
- # To enable this callback, use BrickletRS485#enable_read_callback.
20
+ # See CALLBACK_READ
21
21
  CALLBACK_READ_LOW_LEVEL = 41
22
22
 
23
23
  # This callback is called if a new error occurs. It returns
@@ -33,19 +33,7 @@ module Tinkerforge
33
33
  # To send a response of this request use BrickletRS485#modbus_slave_answer_read_coils_request.
34
34
  CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST = 43
35
35
 
36
- # This callback is called only in Modbus master mode when the master receives a
37
- # valid response of a request to read coils.
38
- #
39
- # The parameters are request ID
40
- # of the request, exception code of the response and the data as received by the
41
- # response.
42
- #
43
- # Any non-zero exception code indicates a problem. If the exception code
44
- # is greater than 0 then the number represents a Modbus exception code. If it is
45
- # less than 0 then it represents other errors. For example, -1 indicates that
46
- # the request timed out or that the master did not receive any valid response of the
47
- # request within the master request timeout period as set by
48
- # BrickletRS485#set_modbus_configuration.
36
+ # See CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE
49
37
  CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL = 44
50
38
 
51
39
  # This callback is called only in Modbus slave mode when the slave receives a
@@ -57,19 +45,7 @@ module Tinkerforge
57
45
  # To send a response of this request use BrickletRS485#modbus_slave_answer_read_holding_registers_request.
58
46
  CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST = 45
59
47
 
60
- # This callback is called only in Modbus master mode when the master receives a
61
- # valid response of a request to read holding registers.
62
- #
63
- # The parameters are
64
- # request ID of the request, exception code of the response and the data as received
65
- # by the response.
66
- #
67
- # Any non-zero exception code indicates a problem. If the exception
68
- # code is greater than 0 then the number represents a Modbus exception code. If
69
- # it is less than 0 then it represents other errors. For example, -1 indicates that
70
- # the request timed out or that the master did not receive any valid response of the
71
- # request within the master request timeout period as set by
72
- # BrickletRS485#set_modbus_configuration.
48
+ # See CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE
73
49
  CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL = 46
74
50
 
75
51
  # This callback is called only in Modbus slave mode when the slave receives a
@@ -118,13 +94,7 @@ module Tinkerforge
118
94
  # timeout period as set by BrickletRS485#set_modbus_configuration.
119
95
  CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE = 50
120
96
 
121
- # This callback is called only in Modbus slave mode when the slave receives a
122
- # valid request from a Modbus master to write multiple coils. The parameters
123
- # are request ID of the request, the number of the first coil and the data to be written as
124
- # received by the request. The number of the first coil is called starting address for backwards compatibility reasons.
125
- # It is not an address, but instead a coil number in the range of 1 to 65536.
126
- #
127
- # To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_coils_request.
97
+ # See CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST
128
98
  CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL = 51
129
99
 
130
100
  # This callback is called only in Modbus master mode when the master receives a
@@ -141,13 +111,7 @@ module Tinkerforge
141
111
  # timeout period as set by BrickletRS485#set_modbus_configuration.
142
112
  CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE = 52
143
113
 
144
- # This callback is called only in Modbus slave mode when the slave receives a
145
- # valid request from a Modbus master to write multiple holding registers. The parameters
146
- # are request ID of the request, the number of the first holding register and the data to be written as
147
- # received by the request. The number of the first holding register is called starting address for backwards compatibility reasons.
148
- # It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is omitted.
149
- #
150
- # To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_registers_request.
114
+ # See CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST
151
115
  CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL = 53
152
116
 
153
117
  # This callback is called only in Modbus master mode when the master receives a
@@ -173,19 +137,7 @@ module Tinkerforge
173
137
  # To send a response of this request use BrickletRS485#modbus_slave_answer_read_discrete_inputs_request.
174
138
  CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST = 55
175
139
 
176
- # This callback is called only in Modbus master mode when the master receives a
177
- # valid response of a request to read discrete inputs.
178
- #
179
- # The parameters are
180
- # request ID of the request, exception code of the response and the data as received
181
- # by the response.
182
- #
183
- # Any non-zero exception code indicates a problem. If the exception
184
- # code is greater than 0 then the number represents a Modbus exception code. If
185
- # it is less than 0 then it represents other errors. For example, -1 indicates that
186
- # the request timedout or that the master did not receive any valid response of the
187
- # request within the master request timeout period as set by
188
- # BrickletRS485#set_modbus_configuration.
140
+ # See CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE
189
141
  CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL = 56
190
142
 
191
143
  # This callback is called only in Modbus slave mode when the slave receives a
@@ -197,24 +149,23 @@ module Tinkerforge
197
149
  # To send a response of this request use BrickletRS485#modbus_slave_answer_read_input_registers_request.
198
150
  CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST = 57
199
151
 
200
- # This callback is called only in Modbus master mode when the master receives a
201
- # valid response of a request to read input registers.
202
- #
203
- # The parameters are
204
- # request ID of the request, exception code of the response and the data as received
205
- # by the response.
206
- #
207
- # Any non-zero exception code indicates a problem. If the exception
208
- # code is greater than 0 then the number represents a Modbus exception code. If
209
- # it is less than 0 then it represents other errors. For example, -1 indicates that
210
- # the request timedout or that the master did not receive any valid response of the
211
- # request within the master request timeout period as set by
212
- # BrickletRS485#set_modbus_configuration.
152
+ # See CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE
213
153
  CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE_LOW_LEVEL = 58
214
154
 
155
+ # This callback is called if at least one frame of data is readable. The frame size is configured with BrickletRS485#set_frame_readable_callback_configuration.
156
+ # The frame count parameter is the number of frames that can be read.
157
+ # This callback is triggered only once until BrickletRS485#read is called. This means, that if you have configured a frame size of X bytes,
158
+ # you can read exactly X bytes using the BrickletRS485#read function, every time the callback triggers without checking the frame count parameter.
159
+ #
160
+ # .. versionadded:: 2.0.5$nbsp;(Plugin)
161
+ CALLBACK_FRAME_READABLE = 61
162
+
215
163
  # This callback is called if new data is available.
216
164
  #
217
165
  # To enable this callback, use BrickletRS485#enable_read_callback.
166
+ #
167
+ # .. note::
168
+ # If reconstructing the value fails, the callback is triggered with nil for message.
218
169
  CALLBACK_READ = -41
219
170
 
220
171
  # This callback is called only in Modbus master mode when the master receives a
@@ -230,6 +181,9 @@ module Tinkerforge
230
181
  # the request timed out or that the master did not receive any valid response of the
231
182
  # request within the master request timeout period as set by
232
183
  # BrickletRS485#set_modbus_configuration.
184
+ #
185
+ # .. note::
186
+ # If reconstructing the value fails, the callback is triggered with nil for coils.
233
187
  CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE = -44
234
188
 
235
189
  # This callback is called only in Modbus master mode when the master receives a
@@ -245,6 +199,9 @@ module Tinkerforge
245
199
  # the request timed out or that the master did not receive any valid response of the
246
200
  # request within the master request timeout period as set by
247
201
  # BrickletRS485#set_modbus_configuration.
202
+ #
203
+ # .. note::
204
+ # If reconstructing the value fails, the callback is triggered with nil for holding_registers.
248
205
  CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE = -46
249
206
 
250
207
  # This callback is called only in Modbus slave mode when the slave receives a
@@ -254,6 +211,9 @@ module Tinkerforge
254
211
  # It is not an address, but instead a coil number in the range of 1 to 65536.
255
212
  #
256
213
  # To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_coils_request.
214
+ #
215
+ # .. note::
216
+ # If reconstructing the value fails, the callback is triggered with nil for coils.
257
217
  CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST = -51
258
218
 
259
219
  # This callback is called only in Modbus slave mode when the slave receives a
@@ -263,6 +223,9 @@ module Tinkerforge
263
223
  # It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is omitted.
264
224
  #
265
225
  # To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_registers_request.
226
+ #
227
+ # .. note::
228
+ # If reconstructing the value fails, the callback is triggered with nil for registers.
266
229
  CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST = -53
267
230
 
268
231
  # This callback is called only in Modbus master mode when the master receives a
@@ -278,6 +241,9 @@ module Tinkerforge
278
241
  # the request timedout or that the master did not receive any valid response of the
279
242
  # request within the master request timeout period as set by
280
243
  # BrickletRS485#set_modbus_configuration.
244
+ #
245
+ # .. note::
246
+ # If reconstructing the value fails, the callback is triggered with nil for discrete_inputs.
281
247
  CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE = -56
282
248
 
283
249
  # This callback is called only in Modbus master mode when the master receives a
@@ -293,6 +259,9 @@ module Tinkerforge
293
259
  # the request timedout or that the master did not receive any valid response of the
294
260
  # request within the master request timeout period as set by
295
261
  # BrickletRS485#set_modbus_configuration.
262
+ #
263
+ # .. note::
264
+ # If reconstructing the value fails, the callback is triggered with nil for input_registers.
296
265
  CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE = -58
297
266
 
298
267
  FUNCTION_WRITE_LOW_LEVEL = 1 # :nodoc:
@@ -335,6 +304,8 @@ module Tinkerforge
335
304
  FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS = 38 # :nodoc:
336
305
  FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL = 39 # :nodoc:
337
306
  FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS = 40 # :nodoc:
307
+ FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION = 59 # :nodoc:
308
+ FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION = 60 # :nodoc:
338
309
  FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
339
310
  FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
340
311
  FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
@@ -400,9 +371,9 @@ module Tinkerforge
400
371
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
401
372
  # the IP Connection <tt>ipcon</tt>.
402
373
  def initialize(uid, ipcon)
403
- super uid, ipcon
374
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
404
375
 
405
- @api_version = [2, 0, 0]
376
+ @api_version = [2, 0, 1]
406
377
 
407
378
  @response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
408
379
  @response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -444,6 +415,8 @@ module Tinkerforge
444
415
  @response_expected[FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
445
416
  @response_expected[FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
446
417
  @response_expected[FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS] = RESPONSE_EXPECTED_ALWAYS_TRUE
418
+ @response_expected[FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
419
+ @response_expected[FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
447
420
  @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
448
421
  @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
449
422
  @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -457,24 +430,25 @@ module Tinkerforge
457
430
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
458
431
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
459
432
 
460
- @callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
461
- @callback_formats[CALLBACK_ERROR_COUNT] = 'L L'
462
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST] = 'C L S'
463
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
464
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST] = 'C L S'
465
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL] = 'C c S S S29'
466
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST] = 'C L ?'
467
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_COIL_RESPONSE] = 'C c'
468
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_REGISTER_REQUEST] = 'C L S'
469
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE] = 'C c'
470
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL] = 'C L S S ?440'
471
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE] = 'C c'
472
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL] = 'C L S S S27'
473
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_RESPONSE] = 'C c'
474
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST] = 'C L S'
475
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
476
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST] = 'C L S'
477
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE_LOW_LEVEL] = 'C c S S S29'
433
+ @callback_formats[CALLBACK_READ_LOW_LEVEL] = [72, 'S S k60']
434
+ @callback_formats[CALLBACK_ERROR_COUNT] = [16, 'L L']
435
+ @callback_formats[CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST] = [15, 'C L S']
436
+ @callback_formats[CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL] = [72, 'C c S S ?464']
437
+ @callback_formats[CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST] = [15, 'C L S']
438
+ @callback_formats[CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL] = [72, 'C c S S S29']
439
+ @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST] = [14, 'C L ?']
440
+ @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_COIL_RESPONSE] = [10, 'C c']
441
+ @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_REGISTER_REQUEST] = [15, 'C L S']
442
+ @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE] = [10, 'C c']
443
+ @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL] = [72, 'C L S S ?440']
444
+ @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE] = [10, 'C c']
445
+ @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL] = [71, 'C L S S S27']
446
+ @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_RESPONSE] = [10, 'C c']
447
+ @callback_formats[CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST] = [15, 'C L S']
448
+ @callback_formats[CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL] = [72, 'C c S S ?464']
449
+ @callback_formats[CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST] = [15, 'C L S']
450
+ @callback_formats[CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE_LOW_LEVEL] = [72, 'C c S S S29']
451
+ @callback_formats[CALLBACK_FRAME_READABLE] = [10, 'S']
478
452
 
479
453
  @high_level_callbacks[CALLBACK_READ] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
480
454
  @high_level_callbacks[CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE] = [[nil, nil, 'stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
@@ -483,6 +457,7 @@ module Tinkerforge
483
457
  @high_level_callbacks[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST] = [[nil, nil, 'stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
484
458
  @high_level_callbacks[CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE] = [[nil, nil, 'stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
485
459
  @high_level_callbacks[CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE] = [[nil, nil, 'stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
460
+ @ipcon.add_device self
486
461
  end
487
462
 
488
463
  # Writes characters to the RS485 interface. The characters can be binary data,
@@ -493,7 +468,9 @@ module Tinkerforge
493
468
  # See BrickletRS485#set_rs485_configuration for configuration possibilities
494
469
  # regarding baudrate, parity and so on.
495
470
  def write_low_level(message_length, message_chunk_offset, message_chunk_data)
496
- send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 1, 'C'
471
+ check_validity
472
+
473
+ send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 9, 'C'
497
474
  end
498
475
 
499
476
  # Returns up to *length* characters from receive buffer.
@@ -503,60 +480,66 @@ module Tinkerforge
503
480
  # data only when the read callback is disabled.
504
481
  # See BrickletRS485#enable_read_callback and CALLBACK_READ callback.
505
482
  def read_low_level(length)
506
- send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 64, 'S S k60'
483
+ check_validity
484
+
485
+ send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 72, 'S S k60'
507
486
  end
508
487
 
509
- # Enables the CALLBACK_READ callback.
488
+ # Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
510
489
  #
511
490
  # By default the callback is disabled.
512
491
  def enable_read_callback
513
- send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 0, ''
492
+ check_validity
493
+
494
+ send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
514
495
  end
515
496
 
516
497
  # Disables the CALLBACK_READ callback.
517
498
  #
518
499
  # By default the callback is disabled.
519
500
  def disable_read_callback
520
- send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 0, ''
501
+ check_validity
502
+
503
+ send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
521
504
  end
522
505
 
523
506
  # Returns *true* if the CALLBACK_READ callback is enabled,
524
507
  # *false* otherwise.
525
508
  def is_read_callback_enabled
526
- send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 1, '?'
509
+ check_validity
510
+
511
+ send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
527
512
  end
528
513
 
529
- # Sets the configuration for the RS485 communication. Available options:
530
- #
531
- # * Baudrate between 100 and 2000000 baud.
532
- # * Parity of none, odd or even.
533
- # * Stopbits can be 1 or 2.
534
- # * Word length of 5 to 8.
535
- # * Half- or Full-Duplex.
536
- #
537
- # The default is: 115200 baud, parity none, 1 stop bit, word length 8, half duplex.
514
+ # Sets the configuration for the RS485 communication.
538
515
  def set_rs485_configuration(baudrate, parity, stopbits, wordlength, duplex)
539
- send_request FUNCTION_SET_RS485_CONFIGURATION, [baudrate, parity, stopbits, wordlength, duplex], 'L C C C C', 0, ''
516
+ check_validity
517
+
518
+ send_request FUNCTION_SET_RS485_CONFIGURATION, [baudrate, parity, stopbits, wordlength, duplex], 'L C C C C', 8, ''
540
519
  end
541
520
 
542
521
  # Returns the configuration as set by BrickletRS485#set_rs485_configuration.
543
522
  def get_rs485_configuration
544
- send_request FUNCTION_GET_RS485_CONFIGURATION, [], '', 8, 'L C C C C'
523
+ check_validity
524
+
525
+ send_request FUNCTION_GET_RS485_CONFIGURATION, [], '', 16, 'L C C C C'
545
526
  end
546
527
 
547
528
  # Sets the configuration for the RS485 Modbus communication. Available options:
548
529
  #
549
530
  # * Slave Address: Address to be used as the Modbus slave address in Modbus slave mode. Valid Modbus slave address range is 1 to 247.
550
- # * Master Request Timeout: Specifies how long the master should wait for a response from a slave in milliseconds when in Modbus master mode.
551
- #
552
- # The default is: Slave Address = 1 and Master Request Timeout = 1000 milliseconds (1 second).
531
+ # * Master Request Timeout: Specifies how long the master should wait for a response from a slave when in Modbus master mode.
553
532
  def set_modbus_configuration(slave_address, master_request_timeout)
554
- send_request FUNCTION_SET_MODBUS_CONFIGURATION, [slave_address, master_request_timeout], 'C L', 0, ''
533
+ check_validity
534
+
535
+ send_request FUNCTION_SET_MODBUS_CONFIGURATION, [slave_address, master_request_timeout], 'C L', 8, ''
555
536
  end
556
537
 
557
538
  # Returns the configuration as set by BrickletRS485#set_modbus_configuration.
558
539
  def get_modbus_configuration
559
- send_request FUNCTION_GET_MODBUS_CONFIGURATION, [], '', 5, 'C L'
540
+ check_validity
541
+
542
+ send_request FUNCTION_GET_MODBUS_CONFIGURATION, [], '', 13, 'C L'
560
543
  end
561
544
 
562
545
  # Sets the mode of the Bricklet in which it operates. Available options are
@@ -564,15 +547,17 @@ module Tinkerforge
564
547
  # * RS485,
565
548
  # * Modbus Master RTU and
566
549
  # * Modbus Slave RTU.
567
- #
568
- # The default is: RS485 mode.
569
550
  def set_mode(mode)
570
- send_request FUNCTION_SET_MODE, [mode], 'C', 0, ''
551
+ check_validity
552
+
553
+ send_request FUNCTION_SET_MODE, [mode], 'C', 8, ''
571
554
  end
572
555
 
573
556
  # Returns the configuration as set by BrickletRS485#set_mode.
574
557
  def get_mode
575
- send_request FUNCTION_GET_MODE, [], '', 1, 'C'
558
+ check_validity
559
+
560
+ send_request FUNCTION_GET_MODE, [], '', 9, 'C'
576
561
  end
577
562
 
578
563
  # Sets the communication LED configuration. By default the LED shows RS485
@@ -582,12 +567,16 @@ module Tinkerforge
582
567
  #
583
568
  # If the Bricklet is in bootloader mode, the LED is off.
584
569
  def set_communication_led_config(config)
585
- send_request FUNCTION_SET_COMMUNICATION_LED_CONFIG, [config], 'C', 0, ''
570
+ check_validity
571
+
572
+ send_request FUNCTION_SET_COMMUNICATION_LED_CONFIG, [config], 'C', 8, ''
586
573
  end
587
574
 
588
575
  # Returns the configuration as set by BrickletRS485#set_communication_led_config
589
576
  def get_communication_led_config
590
- send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 1, 'C'
577
+ check_validity
578
+
579
+ send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 9, 'C'
591
580
  end
592
581
 
593
582
  # Sets the error LED configuration.
@@ -600,17 +589,21 @@ module Tinkerforge
600
589
  #
601
590
  # If the Bricklet is in bootloader mode, the LED is off.
602
591
  def set_error_led_config(config)
603
- send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 0, ''
592
+ check_validity
593
+
594
+ send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 8, ''
604
595
  end
605
596
 
606
597
  # Returns the configuration as set by BrickletRS485#set_error_led_config.
607
598
  def get_error_led_config
608
- send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 1, 'C'
599
+ check_validity
600
+
601
+ send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
609
602
  end
610
603
 
611
604
  # Sets the send and receive buffer size in byte. In sum there is
612
- # 10240 byte (10kb) buffer available and the minimum buffer size
613
- # is 1024 byte (1kb) for both.
605
+ # 10240 byte (10KiB) buffer available and the minimum buffer size
606
+ # is 1024 byte (1KiB) for both.
614
607
  #
615
608
  # The current buffer content is lost if this function is called.
616
609
  #
@@ -618,47 +611,59 @@ module Tinkerforge
618
611
  # could not be written yet. The receive buffer holds data that is
619
612
  # received through RS485 but could not yet be send to the
620
613
  # user, either by BrickletRS485#read or through CALLBACK_READ callback.
621
- #
622
- # The default configuration is 5120 byte (5kb) per buffer.
623
614
  def set_buffer_config(send_buffer_size, receive_buffer_size)
624
- send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 0, ''
615
+ check_validity
616
+
617
+ send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 8, ''
625
618
  end
626
619
 
627
620
  # Returns the buffer configuration as set by BrickletRS485#set_buffer_config.
628
621
  def get_buffer_config
629
- send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 4, 'S S'
622
+ check_validity
623
+
624
+ send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 12, 'S S'
630
625
  end
631
626
 
632
627
  # Returns the currently used bytes for the send and received buffer.
633
628
  #
634
629
  # See BrickletRS485#set_buffer_config for buffer size configuration.
635
630
  def get_buffer_status
636
- send_request FUNCTION_GET_BUFFER_STATUS, [], '', 4, 'S S'
631
+ check_validity
632
+
633
+ send_request FUNCTION_GET_BUFFER_STATUS, [], '', 12, 'S S'
637
634
  end
638
635
 
639
636
  # Enables the CALLBACK_ERROR_COUNT callback.
640
637
  #
641
638
  # By default the callback is disabled.
642
639
  def enable_error_count_callback
643
- send_request FUNCTION_ENABLE_ERROR_COUNT_CALLBACK, [], '', 0, ''
640
+ check_validity
641
+
642
+ send_request FUNCTION_ENABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
644
643
  end
645
644
 
646
645
  # Disables the CALLBACK_ERROR_COUNT callback.
647
646
  #
648
647
  # By default the callback is disabled.
649
648
  def disable_error_count_callback
650
- send_request FUNCTION_DISABLE_ERROR_COUNT_CALLBACK, [], '', 0, ''
649
+ check_validity
650
+
651
+ send_request FUNCTION_DISABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
651
652
  end
652
653
 
653
654
  # Returns *true* if the CALLBACK_ERROR_COUNT callback is enabled,
654
655
  # *false* otherwise.
655
656
  def is_error_count_callback_enabled
656
- send_request FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED, [], '', 1, '?'
657
+ check_validity
658
+
659
+ send_request FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED, [], '', 9, '?'
657
660
  end
658
661
 
659
662
  # Returns the current number of overrun and parity errors.
660
663
  def get_error_count
661
- send_request FUNCTION_GET_ERROR_COUNT, [], '', 8, 'L L'
664
+ check_validity
665
+
666
+ send_request FUNCTION_GET_ERROR_COUNT, [], '', 16, 'L L'
662
667
  end
663
668
 
664
669
  # Returns the current number of errors occurred in Modbus mode.
@@ -671,7 +676,9 @@ module Tinkerforge
671
676
  # * Illegal Data Value Error Count: Number of errors due to invalid data value. This corresponds to Modbus exception code 3.
672
677
  # * Slave Device Failure Error Count: Number of errors occurred on the slave device which were unrecoverable. This corresponds to Modbus exception code 4.
673
678
  def get_modbus_common_error_count
674
- send_request FUNCTION_GET_MODBUS_COMMON_ERROR_COUNT, [], '', 28, 'L L L L L L L'
679
+ check_validity
680
+
681
+ send_request FUNCTION_GET_MODBUS_COMMON_ERROR_COUNT, [], '', 36, 'L L L L L L L'
675
682
  end
676
683
 
677
684
  # In Modbus slave mode this function can be used to report a Modbus exception for
@@ -680,7 +687,9 @@ module Tinkerforge
680
687
  # * Request ID: Request ID of the request received by the slave.
681
688
  # * Exception Code: Modbus exception code to report to the Modbus master.
682
689
  def modbus_slave_report_exception(request_id, exception_code)
683
- send_request FUNCTION_MODBUS_SLAVE_REPORT_EXCEPTION, [request_id, exception_code], 'C c', 0, ''
690
+ check_validity
691
+
692
+ send_request FUNCTION_MODBUS_SLAVE_REPORT_EXCEPTION, [request_id, exception_code], 'C c', 8, ''
684
693
  end
685
694
 
686
695
  # In Modbus slave mode this function can be used to answer a master request to
@@ -692,7 +701,9 @@ module Tinkerforge
692
701
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST callback
693
702
  # with the Request ID as provided by the argument of the callback.
694
703
  def modbus_slave_answer_read_coils_request_low_level(request_id, coils_length, coils_chunk_offset, coils_chunk_data)
695
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_COILS_REQUEST_LOW_LEVEL, [request_id, coils_length, coils_chunk_offset, coils_chunk_data], 'C S S ?472', 0, ''
704
+ check_validity
705
+
706
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_COILS_REQUEST_LOW_LEVEL, [request_id, coils_length, coils_chunk_offset, coils_chunk_data], 'C S S ?472', 8, ''
696
707
  end
697
708
 
698
709
  # In Modbus master mode this function can be used to read coils from a slave. This
@@ -711,7 +722,9 @@ module Tinkerforge
711
722
  # matched with the Request ID returned from this function to verify that the callback
712
723
  # is indeed for a particular request.
713
724
  def modbus_master_read_coils(slave_address, starting_address, count)
714
- send_request FUNCTION_MODBUS_MASTER_READ_COILS, [slave_address, starting_address, count], 'C L S', 1, 'C'
725
+ check_validity
726
+
727
+ send_request FUNCTION_MODBUS_MASTER_READ_COILS, [slave_address, starting_address, count], 'C L S', 9, 'C'
715
728
  end
716
729
 
717
730
  # In Modbus slave mode this function can be used to answer a master request to
@@ -723,7 +736,9 @@ module Tinkerforge
723
736
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST
724
737
  # callback with the Request ID as provided by the argument of the callback.
725
738
  def modbus_slave_answer_read_holding_registers_request_low_level(request_id, holding_registers_length, holding_registers_chunk_offset, holding_registers_chunk_data)
726
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_HOLDING_REGISTERS_REQUEST_LOW_LEVEL, [request_id, holding_registers_length, holding_registers_chunk_offset, holding_registers_chunk_data], 'C S S S29', 0, ''
739
+ check_validity
740
+
741
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_HOLDING_REGISTERS_REQUEST_LOW_LEVEL, [request_id, holding_registers_length, holding_registers_chunk_offset, holding_registers_chunk_data], 'C S S S29', 8, ''
727
742
  end
728
743
 
729
744
  # In Modbus master mode this function can be used to read holding registers from a slave.
@@ -742,7 +757,9 @@ module Tinkerforge
742
757
  # with the Request ID returned from this function to verify that the callback is indeed for a
743
758
  # particular request.
744
759
  def modbus_master_read_holding_registers(slave_address, starting_address, count)
745
- send_request FUNCTION_MODBUS_MASTER_READ_HOLDING_REGISTERS, [slave_address, starting_address, count], 'C L S', 1, 'C'
760
+ check_validity
761
+
762
+ send_request FUNCTION_MODBUS_MASTER_READ_HOLDING_REGISTERS, [slave_address, starting_address, count], 'C L S', 9, 'C'
746
763
  end
747
764
 
748
765
  # In Modbus slave mode this function can be used to answer a master request to
@@ -753,7 +770,9 @@ module Tinkerforge
753
770
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST
754
771
  # callback with the Request ID as provided by the arguments of the callback.
755
772
  def modbus_slave_answer_write_single_coil_request(request_id)
756
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_COIL_REQUEST, [request_id], 'C', 0, ''
773
+ check_validity
774
+
775
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_COIL_REQUEST, [request_id], 'C', 8, ''
757
776
  end
758
777
 
759
778
  # In Modbus master mode this function can be used to write a single coil of a slave.
@@ -772,7 +791,9 @@ module Tinkerforge
772
791
  # with the Request ID returned from this function to verify that the callback is indeed for a
773
792
  # particular request.
774
793
  def modbus_master_write_single_coil(slave_address, coil_address, coil_value)
775
- send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_COIL, [slave_address, coil_address, coil_value], 'C L ?', 1, 'C'
794
+ check_validity
795
+
796
+ send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_COIL, [slave_address, coil_address, coil_value], 'C L ?', 9, 'C'
776
797
  end
777
798
 
778
799
  # In Modbus slave mode this function can be used to answer a master request to
@@ -784,7 +805,9 @@ module Tinkerforge
784
805
  # callback with the Request ID, Register Address and Register Value as provided by
785
806
  # the arguments of the callback.
786
807
  def modbus_slave_answer_write_single_register_request(request_id)
787
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_REGISTER_REQUEST, [request_id], 'C', 0, ''
808
+ check_validity
809
+
810
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_REGISTER_REQUEST, [request_id], 'C', 8, ''
788
811
  end
789
812
 
790
813
  # In Modbus master mode this function can be used to write a single holding register of a
@@ -803,7 +826,9 @@ module Tinkerforge
803
826
  # with the Request ID returned from this function to verify that the callback is indeed for a
804
827
  # particular request.
805
828
  def modbus_master_write_single_register(slave_address, register_address, register_value)
806
- send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_REGISTER, [slave_address, register_address, register_value], 'C L S', 1, 'C'
829
+ check_validity
830
+
831
+ send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_REGISTER, [slave_address, register_address, register_value], 'C L S', 9, 'C'
807
832
  end
808
833
 
809
834
  # In Modbus slave mode this function can be used to answer a master request to
@@ -814,7 +839,9 @@ module Tinkerforge
814
839
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST
815
840
  # callback with the Request ID of the callback.
816
841
  def modbus_slave_answer_write_multiple_coils_request(request_id)
817
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_COILS_REQUEST, [request_id], 'C', 0, ''
842
+ check_validity
843
+
844
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_COILS_REQUEST, [request_id], 'C', 8, ''
818
845
  end
819
846
 
820
847
  # In Modbus master mode this function can be used to write multiple coils of a slave.
@@ -832,7 +859,9 @@ module Tinkerforge
832
859
  # with the Request ID returned from this function to verify that the callback is indeed for a
833
860
  # particular request.
834
861
  def modbus_master_write_multiple_coils_low_level(slave_address, starting_address, coils_length, coils_chunk_offset, coils_chunk_data)
835
- send_request FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_COILS_LOW_LEVEL, [slave_address, starting_address, coils_length, coils_chunk_offset, coils_chunk_data], 'C L S S ?440', 1, 'C'
862
+ check_validity
863
+
864
+ send_request FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_COILS_LOW_LEVEL, [slave_address, starting_address, coils_length, coils_chunk_offset, coils_chunk_data], 'C L S S ?440', 9, 'C'
836
865
  end
837
866
 
838
867
  # In Modbus slave mode this function can be used to answer a master request to
@@ -843,7 +872,9 @@ module Tinkerforge
843
872
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST
844
873
  # callback with the Request ID of the callback.
845
874
  def modbus_slave_answer_write_multiple_registers_request(request_id)
846
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_REGISTERS_REQUEST, [request_id], 'C', 0, ''
875
+ check_validity
876
+
877
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_REGISTERS_REQUEST, [request_id], 'C', 8, ''
847
878
  end
848
879
 
849
880
  # In Modbus master mode this function can be used to write multiple registers of a slave.
@@ -861,7 +892,9 @@ module Tinkerforge
861
892
  # with the Request ID returned from this function to verify that the callback is indeed for a
862
893
  # particular request.
863
894
  def modbus_master_write_multiple_registers_low_level(slave_address, starting_address, registers_length, registers_chunk_offset, registers_chunk_data)
864
- send_request FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_LOW_LEVEL, [slave_address, starting_address, registers_length, registers_chunk_offset, registers_chunk_data], 'C L S S S27', 1, 'C'
895
+ check_validity
896
+
897
+ send_request FUNCTION_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_LOW_LEVEL, [slave_address, starting_address, registers_length, registers_chunk_offset, registers_chunk_data], 'C L S S S27', 9, 'C'
865
898
  end
866
899
 
867
900
  # In Modbus slave mode this function can be used to answer a master request to
@@ -873,7 +906,9 @@ module Tinkerforge
873
906
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST
874
907
  # callback with the Request ID as provided by the argument of the callback.
875
908
  def modbus_slave_answer_read_discrete_inputs_request_low_level(request_id, discrete_inputs_length, discrete_inputs_chunk_offset, discrete_inputs_chunk_data)
876
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_DISCRETE_INPUTS_REQUEST_LOW_LEVEL, [request_id, discrete_inputs_length, discrete_inputs_chunk_offset, discrete_inputs_chunk_data], 'C S S ?472', 0, ''
909
+ check_validity
910
+
911
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_DISCRETE_INPUTS_REQUEST_LOW_LEVEL, [request_id, discrete_inputs_length, discrete_inputs_chunk_offset, discrete_inputs_chunk_data], 'C S S ?472', 8, ''
877
912
  end
878
913
 
879
914
  # In Modbus master mode this function can be used to read discrete inputs from a slave.
@@ -892,7 +927,9 @@ module Tinkerforge
892
927
  # with the Request ID returned from this function to verify that the callback is indeed for a
893
928
  # particular request.
894
929
  def modbus_master_read_discrete_inputs(slave_address, starting_address, count)
895
- send_request FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS, [slave_address, starting_address, count], 'C L S', 1, 'C'
930
+ check_validity
931
+
932
+ send_request FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS, [slave_address, starting_address, count], 'C L S', 9, 'C'
896
933
  end
897
934
 
898
935
  # In Modbus slave mode this function can be used to answer a master request to
@@ -904,7 +941,9 @@ module Tinkerforge
904
941
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST callback
905
942
  # with the Request ID as provided by the argument of the callback.
906
943
  def modbus_slave_answer_read_input_registers_request_low_level(request_id, input_registers_length, input_registers_chunk_offset, input_registers_chunk_data)
907
- send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL, [request_id, input_registers_length, input_registers_chunk_offset, input_registers_chunk_data], 'C S S S29', 0, ''
944
+ check_validity
945
+
946
+ send_request FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL, [request_id, input_registers_length, input_registers_chunk_offset, input_registers_chunk_data], 'C S S S29', 8, ''
908
947
  end
909
948
 
910
949
  # In Modbus master mode this function can be used to read input registers from a slave.
@@ -923,7 +962,30 @@ module Tinkerforge
923
962
  # with the Request ID returned from this function to verify that the callback is indeed for a
924
963
  # particular request.
925
964
  def modbus_master_read_input_registers(slave_address, starting_address, count)
926
- send_request FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS, [slave_address, starting_address, count], 'C L S', 1, 'C'
965
+ check_validity
966
+
967
+ send_request FUNCTION_MODBUS_MASTER_READ_INPUT_REGISTERS, [slave_address, starting_address, count], 'C L S', 9, 'C'
968
+ end
969
+
970
+ # Configures the CALLBACK_FRAME_READABLE callback. The frame size is the number of bytes, that have to be readable to trigger the callback.
971
+ # A frame size of 0 disables the callback. A frame size greater than 0 enables the callback and disables the CALLBACK_READ callback.
972
+ #
973
+ # By default the callback is disabled.
974
+ #
975
+ # .. versionadded:: 2.0.5$nbsp;(Plugin)
976
+ def set_frame_readable_callback_configuration(frame_size)
977
+ check_validity
978
+
979
+ send_request FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION, [frame_size], 'S', 8, ''
980
+ end
981
+
982
+ # Returns the callback configuration as set by BrickletRS485#set_frame_readable_callback_configuration.
983
+ #
984
+ # .. versionadded:: 2.0.5$nbsp;(Plugin)
985
+ def get_frame_readable_callback_configuration
986
+ check_validity
987
+
988
+ send_request FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION, [], '', 10, 'S'
927
989
  end
928
990
 
929
991
  # Returns the error count for the communication between Brick and Bricklet.
@@ -938,7 +1000,9 @@ module Tinkerforge
938
1000
  # The errors counts are for errors that occur on the Bricklet side. All
939
1001
  # Bricks have a similar function that returns the errors on the Brick side.
940
1002
  def get_spitfp_error_count
941
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
1003
+ check_validity
1004
+
1005
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
942
1006
  end
943
1007
 
944
1008
  # Sets the bootloader mode and returns the status after the requested
@@ -951,12 +1015,16 @@ module Tinkerforge
951
1015
  # This function is used by Brick Viewer during flashing. It should not be
952
1016
  # necessary to call it in a normal user program.
953
1017
  def set_bootloader_mode(mode)
954
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
1018
+ check_validity
1019
+
1020
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
955
1021
  end
956
1022
 
957
1023
  # Returns the current bootloader mode, see BrickletRS485#set_bootloader_mode.
958
1024
  def get_bootloader_mode
959
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
1025
+ check_validity
1026
+
1027
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
960
1028
  end
961
1029
 
962
1030
  # Sets the firmware pointer for BrickletRS485#write_firmware. The pointer has
@@ -966,7 +1034,9 @@ module Tinkerforge
966
1034
  # This function is used by Brick Viewer during flashing. It should not be
967
1035
  # necessary to call it in a normal user program.
968
1036
  def set_write_firmware_pointer(pointer)
969
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
1037
+ check_validity
1038
+
1039
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
970
1040
  end
971
1041
 
972
1042
  # Writes 64 Bytes of firmware at the position as written by
@@ -978,7 +1048,9 @@ module Tinkerforge
978
1048
  # This function is used by Brick Viewer during flashing. It should not be
979
1049
  # necessary to call it in a normal user program.
980
1050
  def write_firmware(data)
981
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
1051
+ check_validity
1052
+
1053
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
982
1054
  end
983
1055
 
984
1056
  # Sets the status LED configuration. By default the LED shows
@@ -989,22 +1061,28 @@ module Tinkerforge
989
1061
  #
990
1062
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
991
1063
  def set_status_led_config(config)
992
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
1064
+ check_validity
1065
+
1066
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
993
1067
  end
994
1068
 
995
1069
  # Returns the configuration as set by BrickletRS485#set_status_led_config
996
1070
  def get_status_led_config
997
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
1071
+ check_validity
1072
+
1073
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
998
1074
  end
999
1075
 
1000
- # Returns the temperature in °C as measured inside the microcontroller. The
1076
+ # Returns the temperature as measured inside the microcontroller. The
1001
1077
  # value returned is not the ambient temperature!
1002
1078
  #
1003
1079
  # The temperature is only proportional to the real temperature and it has bad
1004
1080
  # accuracy. Practically it is only useful as an indicator for
1005
1081
  # temperature changes.
1006
1082
  def get_chip_temperature
1007
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
1083
+ check_validity
1084
+
1085
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
1008
1086
  end
1009
1087
 
1010
1088
  # Calling this function will reset the Bricklet. All configurations
@@ -1014,7 +1092,9 @@ module Tinkerforge
1014
1092
  # calling functions on the existing ones will result in
1015
1093
  # undefined behavior!
1016
1094
  def reset
1017
- send_request FUNCTION_RESET, [], '', 0, ''
1095
+ check_validity
1096
+
1097
+ send_request FUNCTION_RESET, [], '', 8, ''
1018
1098
  end
1019
1099
 
1020
1100
  # Writes a new UID into flash. If you want to set a new UID
@@ -1023,25 +1103,31 @@ module Tinkerforge
1023
1103
  #
1024
1104
  # We recommend that you use Brick Viewer to change the UID.
1025
1105
  def write_uid(uid)
1026
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
1106
+ check_validity
1107
+
1108
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
1027
1109
  end
1028
1110
 
1029
1111
  # Returns the current UID as an integer. Encode as
1030
1112
  # Base58 to get the usual string version.
1031
1113
  def read_uid
1032
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
1114
+ check_validity
1115
+
1116
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
1033
1117
  end
1034
1118
 
1035
1119
  # Returns the UID, the UID where the Bricklet is connected to,
1036
1120
  # the position, the hardware and firmware version as well as the
1037
1121
  # device identifier.
1038
1122
  #
1039
- # The position can be 'a', 'b', 'c' or 'd'.
1123
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
1124
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
1125
+ # position 'z'.
1040
1126
  #
1041
1127
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
1042
1128
  # |device_identifier_constant|
1043
1129
  def get_identity
1044
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
1130
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
1045
1131
  end
1046
1132
 
1047
1133
  # Writes characters to the RS485 interface. The characters can be binary data,