tinkerforge 2.1.22 → 2.1.27

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 (144) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +157 -76
  3. data/lib/tinkerforge/brick_hat.rb +115 -32
  4. data/lib/tinkerforge/brick_hat_zero.rb +119 -21
  5. data/lib/tinkerforge/brick_imu.rb +192 -87
  6. data/lib/tinkerforge/brick_imu_v2.rb +220 -119
  7. data/lib/tinkerforge/brick_master.rb +498 -198
  8. data/lib/tinkerforge/brick_red.rb +197 -74
  9. data/lib/tinkerforge/brick_servo.rb +187 -103
  10. data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
  11. data/lib/tinkerforge/brick_stepper.rb +214 -102
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
  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 +77 -49
  31. data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
  32. data/lib/tinkerforge/bricklet_compass.rb +397 -0
  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 +335 -0
  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 +416 -0
  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 +101 -53
  77. data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -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 +371 -0
  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 +97 -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_piezo_buzzer.rb +19 -13
  102. data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
  103. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
  104. data/lib/tinkerforge/bricklet_ptc.rb +76 -51
  105. data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
  106. data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
  107. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
  108. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  109. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  110. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  111. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  112. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  113. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  114. data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
  115. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
  116. data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
  117. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
  118. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  119. data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
  120. data/lib/tinkerforge/bricklet_rs485.rb +303 -207
  121. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  122. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
  123. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  124. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  125. data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
  126. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
  127. data/lib/tinkerforge/bricklet_temperature.rb +43 -28
  128. data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
  129. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
  130. data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
  131. data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
  132. data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
  133. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
  134. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  135. data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
  136. data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
  137. data/lib/tinkerforge/bricklet_voltage.rb +54 -37
  138. data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
  139. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
  140. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
  141. data/lib/tinkerforge/device_display_names.rb +165 -0
  142. data/lib/tinkerforge/ip_connection.rb +155 -33
  143. data/lib/tinkerforge/version.rb +1 -1
  144. metadata +14 -4
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-05-21. #
3
+ # This file was automatically generated on 2020-11-02. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.22 #
5
+ # Ruby Bindings Version 2.1.27 #
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
  # Measures two DC currents between 0mA and 20mA (IEC 60381-1)
14
16
  class BrickletIndustrialDual020mAV2 < Device
@@ -83,7 +85,7 @@ module Tinkerforge
83
85
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
84
86
  # the IP Connection <tt>ipcon</tt>.
85
87
  def initialize(uid, ipcon)
86
- super uid, ipcon
88
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
87
89
 
88
90
  @api_version = [2, 0, 0]
89
91
 
@@ -111,12 +113,12 @@ module Tinkerforge
111
113
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
112
114
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
113
115
 
114
- @callback_formats[CALLBACK_CURRENT] = 'C l'
116
+ @callback_formats[CALLBACK_CURRENT] = [13, 'C l']
115
117
 
118
+ @ipcon.add_device self
116
119
  end
117
120
 
118
- # Returns the current of the specified channel. The value is in nA and between
119
- # 0nA and 22505322nA (22.5mA).
121
+ # Returns the current of the specified channel.
120
122
  #
121
123
  # It is possible to detect if an IEC 60381-1 compatible sensor is connected
122
124
  # and if it works probably.
@@ -130,10 +132,12 @@ module Tinkerforge
130
132
  # CALLBACK_CURRENT callback. You can set the callback configuration
131
133
  # with BrickletIndustrialDual020mAV2#set_current_callback_configuration.
132
134
  def get_current(channel)
133
- send_request FUNCTION_GET_CURRENT, [channel], 'C', 4, 'l'
135
+ check_validity
136
+
137
+ send_request FUNCTION_GET_CURRENT, [channel], 'C', 12, 'l'
134
138
  end
135
139
 
136
- # The period in ms is the period with which the CALLBACK_CURRENT callback is triggered
140
+ # The period is the period with which the CALLBACK_CURRENT callback is triggered
137
141
  # periodically. A value of 0 turns the callback off.
138
142
  #
139
143
  # If the `value has to change`-parameter is set to true, the callback is only
@@ -158,15 +162,17 @@ module Tinkerforge
158
162
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
159
163
  #
160
164
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
161
- #
162
- # The default value is (0, false, 'x', 0, 0).
163
165
  def set_current_callback_configuration(channel, period, value_has_to_change, option, min, max)
164
- send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change, option, min, max], 'C L ? k l l', 0, ''
166
+ check_validity
167
+
168
+ send_request FUNCTION_SET_CURRENT_CALLBACK_CONFIGURATION, [channel, period, value_has_to_change, option, min, max], 'C L ? k l l', 8, ''
165
169
  end
166
170
 
167
171
  # Returns the callback configuration as set by BrickletIndustrialDual020mAV2#set_current_callback_configuration.
168
172
  def get_current_callback_configuration(channel)
169
- send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [channel], 'C', 14, 'L ? k l l'
173
+ check_validity
174
+
175
+ send_request FUNCTION_GET_CURRENT_CALLBACK_CONFIGURATION, [channel], 'C', 22, 'L ? k l l'
170
176
  end
171
177
 
172
178
  # Sets the sample rate to either 240, 60, 15 or 4 samples per second.
@@ -178,15 +184,17 @@ module Tinkerforge
178
184
  # "1", "60 samples per second, 14 bit resolution"
179
185
  # "2", "15 samples per second, 16 bit resolution"
180
186
  # "3", "4 samples per second, 18 bit resolution"
181
- #
182
- # The default value is 3 (4 samples per second with 18 bit resolution).
183
187
  def set_sample_rate(rate)
184
- send_request FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 0, ''
188
+ check_validity
189
+
190
+ send_request FUNCTION_SET_SAMPLE_RATE, [rate], 'C', 8, ''
185
191
  end
186
192
 
187
- # Returns the gain as set by BrickletIndustrialDual020mAV2#set_sample_rate.
193
+ # Returns the sample rate as set by BrickletIndustrialDual020mAV2#set_sample_rate.
188
194
  def get_sample_rate
189
- send_request FUNCTION_GET_SAMPLE_RATE, [], '', 1, 'C'
195
+ check_validity
196
+
197
+ send_request FUNCTION_GET_SAMPLE_RATE, [], '', 9, 'C'
190
198
  end
191
199
 
192
200
  # Sets a gain between 1x and 8x. If you want to measure a very small current,
@@ -194,15 +202,17 @@ module Tinkerforge
194
202
  #
195
203
  # Example: If you measure 0.5mA with a gain of 8x the return value will be
196
204
  # 4mA.
197
- #
198
- # The default gain is 1x.
199
205
  def set_gain(gain)
200
- send_request FUNCTION_SET_GAIN, [gain], 'C', 0, ''
206
+ check_validity
207
+
208
+ send_request FUNCTION_SET_GAIN, [gain], 'C', 8, ''
201
209
  end
202
210
 
203
211
  # Returns the gain as set by BrickletIndustrialDual020mAV2#set_gain.
204
212
  def get_gain
205
- send_request FUNCTION_GET_GAIN, [], '', 1, 'C'
213
+ check_validity
214
+
215
+ send_request FUNCTION_GET_GAIN, [], '', 9, 'C'
206
216
  end
207
217
 
208
218
  # Each channel has a corresponding LED. You can turn the LED off, on or show a
@@ -211,15 +221,17 @@ module Tinkerforge
211
221
  # of the LED can change with the measured value.
212
222
  #
213
223
  # You can configure the channel status behavior with BrickletIndustrialDual020mAV2#set_channel_led_status_config.
214
- #
215
- # By default all channel LEDs are configured as "Channel Status".
216
224
  def set_channel_led_config(channel, config)
217
- send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 0, ''
225
+ check_validity
226
+
227
+ send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 8, ''
218
228
  end
219
229
 
220
230
  # Returns the channel LED configuration as set by BrickletIndustrialDual020mAV2#set_channel_led_config
221
231
  def get_channel_led_config(channel)
222
- send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 1, 'C'
232
+ check_validity
233
+
234
+ send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 9, 'C'
223
235
  end
224
236
 
225
237
  # Sets the channel LED status config. This config is used if the channel LED is
@@ -242,17 +254,18 @@ module Tinkerforge
242
254
  # on at 20mA and above and the brightness is linearly scaled between the values
243
255
  # 4mA and 20mA. If the min value is greater than the max value, the LED brightness
244
256
  # is scaled the other way around.
245
- #
246
- # By default the channel LED status config is set to intensity with min=4mA and
247
- # max=20mA.
248
257
  def set_channel_led_status_config(channel, min, max, config)
249
- send_request FUNCTION_SET_CHANNEL_LED_STATUS_CONFIG, [channel, min, max, config], 'C l l C', 0, ''
258
+ check_validity
259
+
260
+ send_request FUNCTION_SET_CHANNEL_LED_STATUS_CONFIG, [channel, min, max, config], 'C l l C', 8, ''
250
261
  end
251
262
 
252
263
  # Returns the channel LED status configuration as set by
253
264
  # BrickletIndustrialDual020mAV2#set_channel_led_status_config.
254
265
  def get_channel_led_status_config(channel)
255
- send_request FUNCTION_GET_CHANNEL_LED_STATUS_CONFIG, [channel], 'C', 9, 'l l C'
266
+ check_validity
267
+
268
+ send_request FUNCTION_GET_CHANNEL_LED_STATUS_CONFIG, [channel], 'C', 17, 'l l C'
256
269
  end
257
270
 
258
271
  # Returns the error count for the communication between Brick and Bricklet.
@@ -267,7 +280,9 @@ module Tinkerforge
267
280
  # The errors counts are for errors that occur on the Bricklet side. All
268
281
  # Bricks have a similar function that returns the errors on the Brick side.
269
282
  def get_spitfp_error_count
270
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
283
+ check_validity
284
+
285
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
271
286
  end
272
287
 
273
288
  # Sets the bootloader mode and returns the status after the requested
@@ -280,12 +295,16 @@ module Tinkerforge
280
295
  # This function is used by Brick Viewer during flashing. It should not be
281
296
  # necessary to call it in a normal user program.
282
297
  def set_bootloader_mode(mode)
283
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
298
+ check_validity
299
+
300
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
284
301
  end
285
302
 
286
303
  # Returns the current bootloader mode, see BrickletIndustrialDual020mAV2#set_bootloader_mode.
287
304
  def get_bootloader_mode
288
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
305
+ check_validity
306
+
307
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
289
308
  end
290
309
 
291
310
  # Sets the firmware pointer for BrickletIndustrialDual020mAV2#write_firmware. The pointer has
@@ -295,7 +314,9 @@ module Tinkerforge
295
314
  # This function is used by Brick Viewer during flashing. It should not be
296
315
  # necessary to call it in a normal user program.
297
316
  def set_write_firmware_pointer(pointer)
298
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
317
+ check_validity
318
+
319
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
299
320
  end
300
321
 
301
322
  # Writes 64 Bytes of firmware at the position as written by
@@ -307,7 +328,9 @@ module Tinkerforge
307
328
  # This function is used by Brick Viewer during flashing. It should not be
308
329
  # necessary to call it in a normal user program.
309
330
  def write_firmware(data)
310
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
331
+ check_validity
332
+
333
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
311
334
  end
312
335
 
313
336
  # Sets the status LED configuration. By default the LED shows
@@ -318,22 +341,28 @@ module Tinkerforge
318
341
  #
319
342
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
320
343
  def set_status_led_config(config)
321
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
344
+ check_validity
345
+
346
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
322
347
  end
323
348
 
324
349
  # Returns the configuration as set by BrickletIndustrialDual020mAV2#set_status_led_config
325
350
  def get_status_led_config
326
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
351
+ check_validity
352
+
353
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
327
354
  end
328
355
 
329
- # Returns the temperature in °C as measured inside the microcontroller. The
356
+ # Returns the temperature as measured inside the microcontroller. The
330
357
  # value returned is not the ambient temperature!
331
358
  #
332
359
  # The temperature is only proportional to the real temperature and it has bad
333
360
  # accuracy. Practically it is only useful as an indicator for
334
361
  # temperature changes.
335
362
  def get_chip_temperature
336
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
363
+ check_validity
364
+
365
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
337
366
  end
338
367
 
339
368
  # Calling this function will reset the Bricklet. All configurations
@@ -343,7 +372,9 @@ module Tinkerforge
343
372
  # calling functions on the existing ones will result in
344
373
  # undefined behavior!
345
374
  def reset
346
- send_request FUNCTION_RESET, [], '', 0, ''
375
+ check_validity
376
+
377
+ send_request FUNCTION_RESET, [], '', 8, ''
347
378
  end
348
379
 
349
380
  # Writes a new UID into flash. If you want to set a new UID
@@ -352,25 +383,31 @@ module Tinkerforge
352
383
  #
353
384
  # We recommend that you use Brick Viewer to change the UID.
354
385
  def write_uid(uid)
355
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
386
+ check_validity
387
+
388
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
356
389
  end
357
390
 
358
391
  # Returns the current UID as an integer. Encode as
359
392
  # Base58 to get the usual string version.
360
393
  def read_uid
361
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
394
+ check_validity
395
+
396
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
362
397
  end
363
398
 
364
399
  # Returns the UID, the UID where the Bricklet is connected to,
365
400
  # the position, the hardware and firmware version as well as the
366
401
  # device identifier.
367
402
  #
368
- # The position can be 'a', 'b', 'c' or 'd'.
403
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
404
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
405
+ # position 'z'.
369
406
  #
370
407
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
371
408
  # |device_identifier_constant|
372
409
  def get_identity
373
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
410
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
374
411
  end
375
412
 
376
413
  # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
@@ -0,0 +1,325 @@
1
+ # -*- ruby encoding: utf-8 -*-
2
+ #############################################################
3
+ # This file was automatically generated on 2020-11-02. #
4
+ # #
5
+ # Ruby Bindings Version 2.1.27 #
6
+ # #
7
+ # If you have a bugfix for this file and want to commit it, #
8
+ # please fix the bug in the generator. You can find a link #
9
+ # to the generators git repository on tinkerforge.com #
10
+ #############################################################
11
+
12
+ require_relative './ip_connection'
13
+
14
+ module Tinkerforge
15
+ # Two relays to switch AC devices
16
+ class BrickletIndustrialDualACRelay < Device
17
+ DEVICE_IDENTIFIER = 2162 # :nodoc:
18
+ DEVICE_DISPLAY_NAME = 'Industrial Dual AC Relay Bricklet' # :nodoc:
19
+
20
+ # This callback is triggered whenever a monoflop timer reaches 0. The
21
+ # parameters contain the relay and the current state of the relay
22
+ # (the state after the monoflop).
23
+ CALLBACK_MONOFLOP_DONE = 7
24
+
25
+ FUNCTION_SET_VALUE = 1 # :nodoc:
26
+ FUNCTION_GET_VALUE = 2 # :nodoc:
27
+ FUNCTION_SET_CHANNEL_LED_CONFIG = 3 # :nodoc:
28
+ FUNCTION_GET_CHANNEL_LED_CONFIG = 4 # :nodoc:
29
+ FUNCTION_SET_MONOFLOP = 5 # :nodoc:
30
+ FUNCTION_GET_MONOFLOP = 6 # :nodoc:
31
+ FUNCTION_SET_SELECTED_VALUE = 8 # :nodoc:
32
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
33
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
34
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
35
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
36
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
37
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
38
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
39
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
40
+ FUNCTION_RESET = 243 # :nodoc:
41
+ FUNCTION_WRITE_UID = 248 # :nodoc:
42
+ FUNCTION_READ_UID = 249 # :nodoc:
43
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
44
+
45
+ CHANNEL_LED_CONFIG_OFF = 0 # :nodoc:
46
+ CHANNEL_LED_CONFIG_ON = 1 # :nodoc:
47
+ CHANNEL_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
48
+ CHANNEL_LED_CONFIG_SHOW_CHANNEL_STATUS = 3 # :nodoc:
49
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
50
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
51
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
52
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
53
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
54
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
55
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
56
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
57
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
58
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
59
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
60
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
61
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
62
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
63
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
64
+
65
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
66
+ # the IP Connection <tt>ipcon</tt>.
67
+ def initialize(uid, ipcon)
68
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
69
+
70
+ @api_version = [2, 0, 0]
71
+
72
+ @response_expected[FUNCTION_SET_VALUE] = RESPONSE_EXPECTED_FALSE
73
+ @response_expected[FUNCTION_GET_VALUE] = RESPONSE_EXPECTED_ALWAYS_TRUE
74
+ @response_expected[FUNCTION_SET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
75
+ @response_expected[FUNCTION_GET_CHANNEL_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
76
+ @response_expected[FUNCTION_SET_MONOFLOP] = RESPONSE_EXPECTED_FALSE
77
+ @response_expected[FUNCTION_GET_MONOFLOP] = RESPONSE_EXPECTED_ALWAYS_TRUE
78
+ @response_expected[FUNCTION_SET_SELECTED_VALUE] = RESPONSE_EXPECTED_FALSE
79
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
80
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
81
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
82
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
83
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
84
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
85
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
86
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
87
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
88
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
89
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
90
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
91
+
92
+ @callback_formats[CALLBACK_MONOFLOP_DONE] = [10, 'C ?']
93
+
94
+ @ipcon.add_device self
95
+ end
96
+
97
+ # Sets the state of the relays, *true* means on and *false* means off.
98
+ # For example: (true, false) turns relay 0 on and relay 1 off.
99
+ #
100
+ # If you just want to set one of the relays and don't know the current state
101
+ # of the other relay, you can get the state with BrickletIndustrialDualACRelay#get_value or you
102
+ # can use BrickletIndustrialDualACRelay#set_selected_value.
103
+ #
104
+ # All running monoflop timers will be aborted if this function is called.
105
+ def set_value(channel0, channel1)
106
+ check_validity
107
+
108
+ send_request FUNCTION_SET_VALUE, [channel0, channel1], '? ?', 8, ''
109
+ end
110
+
111
+ # Returns the state of the relays, *true* means on and *false* means off.
112
+ def get_value
113
+ check_validity
114
+
115
+ send_request FUNCTION_GET_VALUE, [], '', 10, '? ?'
116
+ end
117
+
118
+ # Each channel has a corresponding LED. You can turn the LED off, on or show a
119
+ # heartbeat. You can also set the LED to "Channel Status". In this mode the
120
+ # LED is on if the channel is high and off otherwise.
121
+ def set_channel_led_config(channel, config)
122
+ check_validity
123
+
124
+ send_request FUNCTION_SET_CHANNEL_LED_CONFIG, [channel, config], 'C C', 8, ''
125
+ end
126
+
127
+ # Returns the channel LED configuration as set by BrickletIndustrialDualACRelay#set_channel_led_config
128
+ def get_channel_led_config(channel)
129
+ check_validity
130
+
131
+ send_request FUNCTION_GET_CHANNEL_LED_CONFIG, [channel], 'C', 9, 'C'
132
+ end
133
+
134
+ # The first parameter can be 0 or 1 (relay 0 or relay 1). The second parameter
135
+ # is the desired state of the relay (*true* means on and *false* means off).
136
+ # The third parameter indicates the time that the relay should hold
137
+ # the state.
138
+ #
139
+ # If this function is called with the parameters (1, true, 1500):
140
+ # Relay 1 will turn on and in 1.5s it will turn off again.
141
+ #
142
+ # A monoflop can be used as a failsafe mechanism. For example: Lets assume you
143
+ # have a RS485 bus and a Industrial Dual AC Relay Bricklet connected to one of the
144
+ # slave stacks. You can now call this function every second, with a time parameter
145
+ # of two seconds. The relay will be on all the time. If now the RS485
146
+ # connection is lost, the relay will turn off in at most two seconds.
147
+ def set_monoflop(channel, value, time)
148
+ check_validity
149
+
150
+ send_request FUNCTION_SET_MONOFLOP, [channel, value, time], 'C ? L', 8, ''
151
+ end
152
+
153
+ # Returns (for the given relay) the current state and the time as set by
154
+ # BrickletIndustrialDualACRelay#set_monoflop as well as the remaining time until the state flips.
155
+ #
156
+ # If the timer is not running currently, the remaining time will be returned
157
+ # as 0.
158
+ def get_monoflop(channel)
159
+ check_validity
160
+
161
+ send_request FUNCTION_GET_MONOFLOP, [channel], 'C', 17, '? L L'
162
+ end
163
+
164
+ # Sets the state of the selected relay, *true* means on and *false*
165
+ # means off.
166
+ #
167
+ # A running monoflop timer for the selected relay will be aborted if this function
168
+ # is called.
169
+ #
170
+ # The other relay remains untouched.
171
+ def set_selected_value(channel, value)
172
+ check_validity
173
+
174
+ send_request FUNCTION_SET_SELECTED_VALUE, [channel, value], 'C ?', 8, ''
175
+ end
176
+
177
+ # Returns the error count for the communication between Brick and Bricklet.
178
+ #
179
+ # The errors are divided into
180
+ #
181
+ # * ACK checksum errors,
182
+ # * message checksum errors,
183
+ # * framing errors and
184
+ # * overflow errors.
185
+ #
186
+ # The errors counts are for errors that occur on the Bricklet side. All
187
+ # Bricks have a similar function that returns the errors on the Brick side.
188
+ def get_spitfp_error_count
189
+ check_validity
190
+
191
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
192
+ end
193
+
194
+ # Sets the bootloader mode and returns the status after the requested
195
+ # mode change was instigated.
196
+ #
197
+ # You can change from bootloader mode to firmware mode and vice versa. A change
198
+ # from bootloader mode to firmware mode will only take place if the entry function,
199
+ # device identifier and CRC are present and correct.
200
+ #
201
+ # This function is used by Brick Viewer during flashing. It should not be
202
+ # necessary to call it in a normal user program.
203
+ def set_bootloader_mode(mode)
204
+ check_validity
205
+
206
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
207
+ end
208
+
209
+ # Returns the current bootloader mode, see BrickletIndustrialDualACRelay#set_bootloader_mode.
210
+ def get_bootloader_mode
211
+ check_validity
212
+
213
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
214
+ end
215
+
216
+ # Sets the firmware pointer for BrickletIndustrialDualACRelay#write_firmware. The pointer has
217
+ # to be increased by chunks of size 64. The data is written to flash
218
+ # every 4 chunks (which equals to one page of size 256).
219
+ #
220
+ # This function is used by Brick Viewer during flashing. It should not be
221
+ # necessary to call it in a normal user program.
222
+ def set_write_firmware_pointer(pointer)
223
+ check_validity
224
+
225
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
226
+ end
227
+
228
+ # Writes 64 Bytes of firmware at the position as written by
229
+ # BrickletIndustrialDualACRelay#set_write_firmware_pointer before. The firmware is written
230
+ # to flash every 4 chunks.
231
+ #
232
+ # You can only write firmware in bootloader mode.
233
+ #
234
+ # This function is used by Brick Viewer during flashing. It should not be
235
+ # necessary to call it in a normal user program.
236
+ def write_firmware(data)
237
+ check_validity
238
+
239
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
240
+ end
241
+
242
+ # Sets the status LED configuration. By default the LED shows
243
+ # communication traffic between Brick and Bricklet, it flickers once
244
+ # for every 10 received data packets.
245
+ #
246
+ # You can also turn the LED permanently on/off or show a heartbeat.
247
+ #
248
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
249
+ def set_status_led_config(config)
250
+ check_validity
251
+
252
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
253
+ end
254
+
255
+ # Returns the configuration as set by BrickletIndustrialDualACRelay#set_status_led_config
256
+ def get_status_led_config
257
+ check_validity
258
+
259
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
260
+ end
261
+
262
+ # Returns the temperature as measured inside the microcontroller. The
263
+ # value returned is not the ambient temperature!
264
+ #
265
+ # The temperature is only proportional to the real temperature and it has bad
266
+ # accuracy. Practically it is only useful as an indicator for
267
+ # temperature changes.
268
+ def get_chip_temperature
269
+ check_validity
270
+
271
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
272
+ end
273
+
274
+ # Calling this function will reset the Bricklet. All configurations
275
+ # will be lost.
276
+ #
277
+ # After a reset you have to create new device objects,
278
+ # calling functions on the existing ones will result in
279
+ # undefined behavior!
280
+ def reset
281
+ check_validity
282
+
283
+ send_request FUNCTION_RESET, [], '', 8, ''
284
+ end
285
+
286
+ # Writes a new UID into flash. If you want to set a new UID
287
+ # you have to decode the Base58 encoded UID string into an
288
+ # integer first.
289
+ #
290
+ # We recommend that you use Brick Viewer to change the UID.
291
+ def write_uid(uid)
292
+ check_validity
293
+
294
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
295
+ end
296
+
297
+ # Returns the current UID as an integer. Encode as
298
+ # Base58 to get the usual string version.
299
+ def read_uid
300
+ check_validity
301
+
302
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
303
+ end
304
+
305
+ # Returns the UID, the UID where the Bricklet is connected to,
306
+ # the position, the hardware and firmware version as well as the
307
+ # device identifier.
308
+ #
309
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
310
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
311
+ # position 'z'.
312
+ #
313
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
314
+ # |device_identifier_constant|
315
+ def get_identity
316
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
317
+ end
318
+
319
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
320
+ def register_callback(id, &block)
321
+ callback = block
322
+ @registered_callbacks[id] = callback
323
+ end
324
+ end
325
+ end