tinkerforge 2.1.24 → 2.1.29

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. checksums.yaml +5 -5
  2. data/lib/tinkerforge/brick_dc.rb +156 -75
  3. data/lib/tinkerforge/brick_hat.rb +69 -31
  4. data/lib/tinkerforge/brick_hat_zero.rb +55 -23
  5. data/lib/tinkerforge/brick_imu.rb +185 -78
  6. data/lib/tinkerforge/brick_imu_v2.rb +209 -106
  7. data/lib/tinkerforge/brick_master.rb +491 -183
  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 +247 -167
  11. data/lib/tinkerforge/brick_stepper.rb +211 -99
  12. data/lib/tinkerforge/bricklet_accelerometer.rb +57 -23
  13. data/lib/tinkerforge/bricklet_accelerometer_v2.rb +104 -54
  14. data/lib/tinkerforge/bricklet_air_quality.rb +116 -59
  15. data/lib/tinkerforge/bricklet_ambient_light.rb +50 -21
  16. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +44 -24
  17. data/lib/tinkerforge/bricklet_ambient_light_v3.rb +65 -27
  18. data/lib/tinkerforge/bricklet_analog_in.rb +62 -25
  19. data/lib/tinkerforge/bricklet_analog_in_v2.rb +56 -23
  20. data/lib/tinkerforge/bricklet_analog_in_v3.rb +66 -25
  21. data/lib/tinkerforge/bricklet_analog_out.rb +22 -9
  22. data/lib/tinkerforge/bricklet_analog_out_v2.rb +19 -8
  23. data/lib/tinkerforge/bricklet_analog_out_v3.rb +53 -20
  24. data/lib/tinkerforge/bricklet_barometer.rb +100 -27
  25. data/lib/tinkerforge/bricklet_barometer_v2.rb +98 -37
  26. data/lib/tinkerforge/bricklet_can.rb +83 -19
  27. data/lib/tinkerforge/bricklet_can_v2.rb +171 -38
  28. data/lib/tinkerforge/bricklet_co2.rb +33 -14
  29. data/lib/tinkerforge/bricklet_co2_v2.rb +97 -38
  30. data/lib/tinkerforge/bricklet_color.rb +68 -27
  31. data/lib/tinkerforge/bricklet_color_v2.rb +86 -33
  32. data/lib/tinkerforge/bricklet_compass.rb +77 -30
  33. data/lib/tinkerforge/bricklet_current12.rb +57 -24
  34. data/lib/tinkerforge/bricklet_current25.rb +57 -24
  35. data/lib/tinkerforge/bricklet_dc_v2.rb +521 -0
  36. data/lib/tinkerforge/bricklet_distance_ir.rb +56 -23
  37. data/lib/tinkerforge/bricklet_distance_ir_v2.rb +82 -31
  38. data/lib/tinkerforge/bricklet_distance_us.rb +39 -16
  39. data/lib/tinkerforge/bricklet_distance_us_v2.rb +66 -25
  40. data/lib/tinkerforge/bricklet_dmx.rb +87 -34
  41. data/lib/tinkerforge/bricklet_dual_button.rb +23 -10
  42. data/lib/tinkerforge/bricklet_dual_button_v2.rb +63 -24
  43. data/lib/tinkerforge/bricklet_dual_relay.rb +26 -11
  44. data/lib/tinkerforge/bricklet_dust_detector.rb +39 -16
  45. data/lib/tinkerforge/bricklet_e_paper_296x128.rb +87 -32
  46. data/lib/tinkerforge/bricklet_energy_monitor.rb +72 -27
  47. data/lib/tinkerforge/bricklet_gps.rb +63 -26
  48. data/lib/tinkerforge/bricklet_gps_v2.rb +116 -47
  49. data/lib/tinkerforge/bricklet_hall_effect.rb +42 -23
  50. data/lib/tinkerforge/bricklet_hall_effect_v2.rb +70 -27
  51. data/lib/tinkerforge/bricklet_humidity.rb +50 -21
  52. data/lib/tinkerforge/bricklet_humidity_v2.rb +82 -31
  53. data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
  54. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +37 -14
  55. data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +80 -29
  56. data/lib/tinkerforge/bricklet_industrial_counter.rb +100 -39
  57. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +44 -17
  58. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +76 -29
  59. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +35 -14
  60. data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +72 -27
  61. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +39 -16
  62. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -30
  63. data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
  64. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +48 -19
  65. data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +137 -31
  66. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +60 -23
  67. data/lib/tinkerforge/bricklet_industrial_ptc.rb +475 -0
  68. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +35 -14
  69. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +66 -25
  70. data/lib/tinkerforge/bricklet_io16.rb +54 -21
  71. data/lib/tinkerforge/bricklet_io16_v2.rb +89 -34
  72. data/lib/tinkerforge/bricklet_io4.rb +54 -23
  73. data/lib/tinkerforge/bricklet_io4_v2.rb +95 -36
  74. data/lib/tinkerforge/bricklet_isolator.rb +72 -29
  75. data/lib/tinkerforge/bricklet_joystick.rb +58 -25
  76. data/lib/tinkerforge/bricklet_joystick_v2.rb +67 -26
  77. data/lib/tinkerforge/bricklet_laser_range_finder.rb +81 -32
  78. data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +95 -36
  79. data/lib/tinkerforge/bricklet_lcd_128x64.rb +191 -70
  80. data/lib/tinkerforge/bricklet_lcd_16x2.rb +44 -18
  81. data/lib/tinkerforge/bricklet_lcd_20x4.rb +57 -23
  82. data/lib/tinkerforge/bricklet_led_strip.rb +59 -22
  83. data/lib/tinkerforge/bricklet_led_strip_v2.rb +90 -46
  84. data/lib/tinkerforge/bricklet_line.rb +33 -14
  85. data/lib/tinkerforge/bricklet_linear_poti.rb +50 -21
  86. data/lib/tinkerforge/bricklet_linear_poti_v2.rb +54 -21
  87. data/lib/tinkerforge/bricklet_load_cell.rb +60 -23
  88. data/lib/tinkerforge/bricklet_load_cell_v2.rb +79 -30
  89. data/lib/tinkerforge/bricklet_moisture.rb +39 -16
  90. data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
  91. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +61 -27
  92. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +70 -27
  93. data/lib/tinkerforge/bricklet_multi_touch.rb +30 -13
  94. data/lib/tinkerforge/bricklet_multi_touch_v2.rb +75 -28
  95. data/lib/tinkerforge/bricklet_nfc.rb +126 -62
  96. data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
  97. data/lib/tinkerforge/bricklet_oled_128x64.rb +28 -11
  98. data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +65 -24
  99. data/lib/tinkerforge/bricklet_oled_64x48.rb +28 -11
  100. data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
  101. data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -28
  102. data/lib/tinkerforge/bricklet_particulate_matter.rb +74 -30
  103. data/lib/tinkerforge/bricklet_performance_dc.rb +682 -0
  104. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +18 -9
  105. data/lib/tinkerforge/bricklet_piezo_speaker.rb +21 -10
  106. data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +79 -42
  107. data/lib/tinkerforge/bricklet_ptc.rb +73 -42
  108. data/lib/tinkerforge/bricklet_ptc_v2.rb +94 -48
  109. data/lib/tinkerforge/bricklet_real_time_clock.rb +44 -33
  110. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +77 -44
  111. data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
  112. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
  113. data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
  114. data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
  115. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
  116. data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
  117. data/lib/tinkerforge/bricklet_rotary_encoder.rb +38 -19
  118. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +59 -24
  119. data/lib/tinkerforge/bricklet_rotary_poti.rb +52 -28
  120. data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +56 -23
  121. data/lib/tinkerforge/bricklet_rs232.rb +89 -28
  122. data/lib/tinkerforge/bricklet_rs232_v2.rb +117 -44
  123. data/lib/tinkerforge/bricklet_rs485.rb +222 -95
  124. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
  125. data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +74 -35
  126. data/lib/tinkerforge/bricklet_servo_v2.rb +565 -0
  127. data/lib/tinkerforge/bricklet_silent_stepper_v2.rb +1024 -0
  128. data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
  129. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
  130. data/lib/tinkerforge/bricklet_sound_intensity.rb +34 -18
  131. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +71 -31
  132. data/lib/tinkerforge/bricklet_temperature.rb +39 -16
  133. data/lib/tinkerforge/bricklet_temperature_ir.rb +56 -23
  134. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +70 -27
  135. data/lib/tinkerforge/bricklet_temperature_v2.rb +60 -25
  136. data/lib/tinkerforge/bricklet_thermal_imaging.rb +104 -44
  137. data/lib/tinkerforge/bricklet_thermocouple.rb +44 -24
  138. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +64 -27
  139. data/lib/tinkerforge/bricklet_tilt.rb +23 -10
  140. data/lib/tinkerforge/bricklet_uv_light.rb +35 -18
  141. data/lib/tinkerforge/bricklet_uv_light_v2.rb +84 -37
  142. data/lib/tinkerforge/bricklet_voltage.rb +51 -28
  143. data/lib/tinkerforge/bricklet_voltage_current.rb +90 -73
  144. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +89 -68
  145. data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +79 -30
  146. data/lib/tinkerforge/device_display_names.rb +170 -0
  147. data/lib/tinkerforge/ip_connection.rb +153 -33
  148. data/lib/tinkerforge/version.rb +1 -1
  149. metadata +11 -3
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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 RS232 devices
14
16
  class BrickletRS232V2 < Device
@@ -22,6 +24,14 @@ module Tinkerforge
22
24
  # the current overrun and parity error count.
23
25
  CALLBACK_ERROR_COUNT = 13
24
26
 
27
+ # This callback is called if at least one frame of data is readable. The frame size is configured with BrickletRS232V2#set_frame_readable_callback_configuration.
28
+ # The frame count parameter is the number of frames that can be read.
29
+ # This callback is triggered only once until BrickletRS232V2#read is called. This means, that if you have configured a frame size of X bytes,
30
+ # you can read exactly X bytes using the BrickletRS232V2#read function, every time the callback triggers without checking the frame count parameter.
31
+ #
32
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
33
+ CALLBACK_FRAME_READABLE = 16
34
+
25
35
  # This callback is called if new data is available.
26
36
  #
27
37
  # To enable this callback, use BrickletRS232V2#enable_read_callback.
@@ -41,6 +51,8 @@ module Tinkerforge
41
51
  FUNCTION_GET_BUFFER_CONFIG = 9 # :nodoc:
42
52
  FUNCTION_GET_BUFFER_STATUS = 10 # :nodoc:
43
53
  FUNCTION_GET_ERROR_COUNT = 11 # :nodoc:
54
+ FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION = 14 # :nodoc:
55
+ FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION = 15 # :nodoc:
44
56
  FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
45
57
  FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
46
58
  FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
@@ -85,9 +97,9 @@ module Tinkerforge
85
97
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
86
98
  # the IP Connection <tt>ipcon</tt>.
87
99
  def initialize(uid, ipcon)
88
- super uid, ipcon
100
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
89
101
 
90
- @api_version = [2, 0, 0]
102
+ @api_version = [2, 0, 1]
91
103
 
92
104
  @response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
93
105
  @response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -100,6 +112,8 @@ module Tinkerforge
100
112
  @response_expected[FUNCTION_GET_BUFFER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
101
113
  @response_expected[FUNCTION_GET_BUFFER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
102
114
  @response_expected[FUNCTION_GET_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
+ @response_expected[FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
116
+ @response_expected[FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
103
117
  @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
104
118
  @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
105
119
  @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -113,10 +127,12 @@ module Tinkerforge
113
127
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
114
128
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
115
129
 
116
- @callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
117
- @callback_formats[CALLBACK_ERROR_COUNT] = 'L L'
130
+ @callback_formats[CALLBACK_READ_LOW_LEVEL] = [72, 'S S k60']
131
+ @callback_formats[CALLBACK_ERROR_COUNT] = [16, 'L L']
132
+ @callback_formats[CALLBACK_FRAME_READABLE] = [10, 'S']
118
133
 
119
134
  @high_level_callbacks[CALLBACK_READ] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
135
+ @ipcon.add_device self
120
136
  end
121
137
 
122
138
  # Writes characters to the RS232 interface. The characters can be binary data,
@@ -127,7 +143,9 @@ module Tinkerforge
127
143
  # See BrickletRS232V2#set_configuration for configuration possibilities
128
144
  # regarding baud rate, parity and so on.
129
145
  def write_low_level(message_length, message_chunk_offset, message_chunk_data)
130
- send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 1, 'C'
146
+ check_validity
147
+
148
+ send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 9, 'C'
131
149
  end
132
150
 
133
151
  # Returns up to *length* characters from receive buffer.
@@ -137,49 +155,53 @@ module Tinkerforge
137
155
  # data only when the read callback is disabled.
138
156
  # See BrickletRS232V2#enable_read_callback and CALLBACK_READ callback.
139
157
  def read_low_level(length)
140
- send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 64, 'S S k60'
158
+ check_validity
159
+
160
+ send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 72, 'S S k60'
141
161
  end
142
162
 
143
- # Enables the CALLBACK_READ callback.
163
+ # Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
144
164
  #
145
165
  # By default the callback is disabled.
146
166
  def enable_read_callback
147
- send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 0, ''
167
+ check_validity
168
+
169
+ send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
148
170
  end
149
171
 
150
172
  # Disables the CALLBACK_READ callback.
151
173
  #
152
174
  # By default the callback is disabled.
153
175
  def disable_read_callback
154
- send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 0, ''
176
+ check_validity
177
+
178
+ send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
155
179
  end
156
180
 
157
181
  # Returns *true* if the CALLBACK_READ callback is enabled,
158
182
  # *false* otherwise.
159
183
  def is_read_callback_enabled
160
- send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 1, '?'
184
+ check_validity
185
+
186
+ send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
161
187
  end
162
188
 
163
- # Sets the configuration for the RS232 communication. Available options:
164
- #
165
- # * Baud rate between 100 and 2000000 baud.
166
- # * Parity of none, odd or even.
167
- # * Stop bits can be 1 or 2.
168
- # * Word length of 5 to 8.
169
- # * Flow control can be off, software or hardware.
170
- #
171
- # The default is: 115200 baud, parity none, 1 stop bit, word length 8.
189
+ # Sets the configuration for the RS232 communication.
172
190
  def set_configuration(baudrate, parity, stopbits, wordlength, flowcontrol)
173
- send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, flowcontrol], 'L C C C C', 0, ''
191
+ check_validity
192
+
193
+ send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, flowcontrol], 'L C C C C', 8, ''
174
194
  end
175
195
 
176
196
  # Returns the configuration as set by BrickletRS232V2#set_configuration.
177
197
  def get_configuration
178
- send_request FUNCTION_GET_CONFIGURATION, [], '', 8, 'L C C C C'
198
+ check_validity
199
+
200
+ send_request FUNCTION_GET_CONFIGURATION, [], '', 16, 'L C C C C'
179
201
  end
180
202
 
181
203
  # Sets the send and receive buffer size in byte. In total the buffers have to be
182
- # 10240 byte (10kb) in size, the minimum buffer size is 1024 byte (1kb) for each.
204
+ # 10240 byte (10KiB) in size, the minimum buffer size is 1024 byte (1KiB) for each.
183
205
  #
184
206
  # The current buffer content is lost if this function is called.
185
207
  #
@@ -187,27 +209,54 @@ module Tinkerforge
187
209
  # can not be written yet. The receive buffer holds data that is
188
210
  # received through RS232 but could not yet be send to the
189
211
  # user, either by BrickletRS232V2#read or through CALLBACK_READ callback.
190
- #
191
- # The default configuration is 5120 byte (5kb) per buffer.
192
212
  def set_buffer_config(send_buffer_size, receive_buffer_size)
193
- send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 0, ''
213
+ check_validity
214
+
215
+ send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 8, ''
194
216
  end
195
217
 
196
218
  # Returns the buffer configuration as set by BrickletRS232V2#set_buffer_config.
197
219
  def get_buffer_config
198
- send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 4, 'S S'
220
+ check_validity
221
+
222
+ send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 12, 'S S'
199
223
  end
200
224
 
201
225
  # Returns the currently used bytes for the send and received buffer.
202
226
  #
203
227
  # See BrickletRS232V2#set_buffer_config for buffer size configuration.
204
228
  def get_buffer_status
205
- send_request FUNCTION_GET_BUFFER_STATUS, [], '', 4, 'S S'
229
+ check_validity
230
+
231
+ send_request FUNCTION_GET_BUFFER_STATUS, [], '', 12, 'S S'
206
232
  end
207
233
 
208
234
  # Returns the current number of overrun and parity errors.
209
235
  def get_error_count
210
- send_request FUNCTION_GET_ERROR_COUNT, [], '', 8, 'L L'
236
+ check_validity
237
+
238
+ send_request FUNCTION_GET_ERROR_COUNT, [], '', 16, 'L L'
239
+ end
240
+
241
+ # Configures the CALLBACK_FRAME_READABLE callback. The frame size is the number of bytes, that have to be readable to trigger the callback.
242
+ # A frame size of 0 disables the callback. A frame size greater than 0 enables the callback and disables the CALLBACK_READ callback.
243
+ #
244
+ # By default the callback is disabled.
245
+ #
246
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
247
+ def set_frame_readable_callback_configuration(frame_size)
248
+ check_validity
249
+
250
+ send_request FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION, [frame_size], 'S', 8, ''
251
+ end
252
+
253
+ # Returns the callback configuration as set by BrickletRS232V2#set_frame_readable_callback_configuration.
254
+ #
255
+ # .. versionadded:: 2.0.3$nbsp;(Plugin)
256
+ def get_frame_readable_callback_configuration
257
+ check_validity
258
+
259
+ send_request FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION, [], '', 10, 'S'
211
260
  end
212
261
 
213
262
  # Returns the error count for the communication between Brick and Bricklet.
@@ -222,7 +271,9 @@ module Tinkerforge
222
271
  # The errors counts are for errors that occur on the Bricklet side. All
223
272
  # Bricks have a similar function that returns the errors on the Brick side.
224
273
  def get_spitfp_error_count
225
- send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
274
+ check_validity
275
+
276
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
226
277
  end
227
278
 
228
279
  # Sets the bootloader mode and returns the status after the requested
@@ -235,12 +286,16 @@ module Tinkerforge
235
286
  # This function is used by Brick Viewer during flashing. It should not be
236
287
  # necessary to call it in a normal user program.
237
288
  def set_bootloader_mode(mode)
238
- send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
289
+ check_validity
290
+
291
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
239
292
  end
240
293
 
241
294
  # Returns the current bootloader mode, see BrickletRS232V2#set_bootloader_mode.
242
295
  def get_bootloader_mode
243
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
296
+ check_validity
297
+
298
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
244
299
  end
245
300
 
246
301
  # Sets the firmware pointer for BrickletRS232V2#write_firmware. The pointer has
@@ -250,7 +305,9 @@ module Tinkerforge
250
305
  # This function is used by Brick Viewer during flashing. It should not be
251
306
  # necessary to call it in a normal user program.
252
307
  def set_write_firmware_pointer(pointer)
253
- send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
308
+ check_validity
309
+
310
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
254
311
  end
255
312
 
256
313
  # Writes 64 Bytes of firmware at the position as written by
@@ -262,7 +319,9 @@ module Tinkerforge
262
319
  # This function is used by Brick Viewer during flashing. It should not be
263
320
  # necessary to call it in a normal user program.
264
321
  def write_firmware(data)
265
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
322
+ check_validity
323
+
324
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
266
325
  end
267
326
 
268
327
  # Sets the status LED configuration. By default the LED shows
@@ -273,22 +332,28 @@ module Tinkerforge
273
332
  #
274
333
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
275
334
  def set_status_led_config(config)
276
- send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
335
+ check_validity
336
+
337
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
277
338
  end
278
339
 
279
340
  # Returns the configuration as set by BrickletRS232V2#set_status_led_config
280
341
  def get_status_led_config
281
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
342
+ check_validity
343
+
344
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
282
345
  end
283
346
 
284
- # Returns the temperature in °C as measured inside the microcontroller. The
347
+ # Returns the temperature as measured inside the microcontroller. The
285
348
  # value returned is not the ambient temperature!
286
349
  #
287
350
  # The temperature is only proportional to the real temperature and it has bad
288
351
  # accuracy. Practically it is only useful as an indicator for
289
352
  # temperature changes.
290
353
  def get_chip_temperature
291
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
354
+ check_validity
355
+
356
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
292
357
  end
293
358
 
294
359
  # Calling this function will reset the Bricklet. All configurations
@@ -298,7 +363,9 @@ module Tinkerforge
298
363
  # calling functions on the existing ones will result in
299
364
  # undefined behavior!
300
365
  def reset
301
- send_request FUNCTION_RESET, [], '', 0, ''
366
+ check_validity
367
+
368
+ send_request FUNCTION_RESET, [], '', 8, ''
302
369
  end
303
370
 
304
371
  # Writes a new UID into flash. If you want to set a new UID
@@ -307,25 +374,31 @@ module Tinkerforge
307
374
  #
308
375
  # We recommend that you use Brick Viewer to change the UID.
309
376
  def write_uid(uid)
310
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
377
+ check_validity
378
+
379
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
311
380
  end
312
381
 
313
382
  # Returns the current UID as an integer. Encode as
314
383
  # Base58 to get the usual string version.
315
384
  def read_uid
316
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
385
+ check_validity
386
+
387
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
317
388
  end
318
389
 
319
390
  # Returns the UID, the UID where the Bricklet is connected to,
320
391
  # the position, the hardware and firmware version as well as the
321
392
  # device identifier.
322
393
  #
323
- # The position can be 'a', 'b', 'c' or 'd'.
394
+ # The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
395
+ # A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
396
+ # position 'z'.
324
397
  #
325
398
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
326
399
  # |device_identifier_constant|
327
400
  def get_identity
328
- send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
401
+ send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
329
402
  end
330
403
 
331
404
  # Writes characters to the RS232 interface. The characters can be binary data,
@@ -1,14 +1,16 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2019-11-25. #
3
+ # This file was automatically generated on 2021-05-06. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.24 #
5
+ # Ruby Bindings Version 2.1.29 #
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
@@ -150,6 +152,14 @@ module Tinkerforge
150
152
  # See CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE
151
153
  CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE_LOW_LEVEL = 58
152
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
+
153
163
  # This callback is called if new data is available.
154
164
  #
155
165
  # To enable this callback, use BrickletRS485#enable_read_callback.
@@ -294,6 +304,8 @@ module Tinkerforge
294
304
  FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS = 38 # :nodoc:
295
305
  FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL = 39 # :nodoc:
296
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:
297
309
  FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
298
310
  FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
299
311
  FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
@@ -359,9 +371,9 @@ module Tinkerforge
359
371
  # Creates an object with the unique device ID <tt>uid</tt> and adds it to
360
372
  # the IP Connection <tt>ipcon</tt>.
361
373
  def initialize(uid, ipcon)
362
- super uid, ipcon
374
+ super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
363
375
 
364
- @api_version = [2, 0, 0]
376
+ @api_version = [2, 0, 1]
365
377
 
366
378
  @response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
367
379
  @response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -403,6 +415,8 @@ module Tinkerforge
403
415
  @response_expected[FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
404
416
  @response_expected[FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
405
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
406
420
  @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
407
421
  @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
408
422
  @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -416,24 +430,25 @@ module Tinkerforge
416
430
  @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
417
431
  @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
418
432
 
419
- @callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
420
- @callback_formats[CALLBACK_ERROR_COUNT] = 'L L'
421
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST] = 'C L S'
422
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
423
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST] = 'C L S'
424
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL] = 'C c S S S29'
425
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST] = 'C L ?'
426
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_COIL_RESPONSE] = 'C c'
427
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_REGISTER_REQUEST] = 'C L S'
428
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE] = 'C c'
429
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL] = 'C L S S ?440'
430
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE] = 'C c'
431
- @callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL] = 'C L S S S27'
432
- @callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_RESPONSE] = 'C c'
433
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST] = 'C L S'
434
- @callback_formats[CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
435
- @callback_formats[CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST] = 'C L S'
436
- @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']
437
452
 
438
453
  @high_level_callbacks[CALLBACK_READ] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
439
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]
@@ -442,6 +457,7 @@ module Tinkerforge
442
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]
443
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]
444
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
445
461
  end
446
462
 
447
463
  # Writes characters to the RS485 interface. The characters can be binary data,
@@ -452,7 +468,9 @@ module Tinkerforge
452
468
  # See BrickletRS485#set_rs485_configuration for configuration possibilities
453
469
  # regarding baudrate, parity and so on.
454
470
  def write_low_level(message_length, message_chunk_offset, message_chunk_data)
455
- 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'
456
474
  end
457
475
 
458
476
  # Returns up to *length* characters from receive buffer.
@@ -462,60 +480,66 @@ module Tinkerforge
462
480
  # data only when the read callback is disabled.
463
481
  # See BrickletRS485#enable_read_callback and CALLBACK_READ callback.
464
482
  def read_low_level(length)
465
- 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'
466
486
  end
467
487
 
468
- # Enables the CALLBACK_READ callback.
488
+ # Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
469
489
  #
470
490
  # By default the callback is disabled.
471
491
  def enable_read_callback
472
- send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 0, ''
492
+ check_validity
493
+
494
+ send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
473
495
  end
474
496
 
475
497
  # Disables the CALLBACK_READ callback.
476
498
  #
477
499
  # By default the callback is disabled.
478
500
  def disable_read_callback
479
- send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 0, ''
501
+ check_validity
502
+
503
+ send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
480
504
  end
481
505
 
482
506
  # Returns *true* if the CALLBACK_READ callback is enabled,
483
507
  # *false* otherwise.
484
508
  def is_read_callback_enabled
485
- send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 1, '?'
509
+ check_validity
510
+
511
+ send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
486
512
  end
487
513
 
488
- # Sets the configuration for the RS485 communication. Available options:
489
- #
490
- # * Baudrate between 100 and 2000000 baud.
491
- # * Parity of none, odd or even.
492
- # * Stopbits can be 1 or 2.
493
- # * Word length of 5 to 8.
494
- # * Half- or Full-Duplex.
495
- #
496
- # The default is: 115200 baud, parity none, 1 stop bit, word length 8, half duplex.
514
+ # Sets the configuration for the RS485 communication.
497
515
  def set_rs485_configuration(baudrate, parity, stopbits, wordlength, duplex)
498
- 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, ''
499
519
  end
500
520
 
501
521
  # Returns the configuration as set by BrickletRS485#set_rs485_configuration.
502
522
  def get_rs485_configuration
503
- 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'
504
526
  end
505
527
 
506
528
  # Sets the configuration for the RS485 Modbus communication. Available options:
507
529
  #
508
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.
509
- # * Master Request Timeout: Specifies how long the master should wait for a response from a slave in milliseconds when in Modbus master mode.
510
- #
511
- # 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.
512
532
  def set_modbus_configuration(slave_address, master_request_timeout)
513
- 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, ''
514
536
  end
515
537
 
516
538
  # Returns the configuration as set by BrickletRS485#set_modbus_configuration.
517
539
  def get_modbus_configuration
518
- send_request FUNCTION_GET_MODBUS_CONFIGURATION, [], '', 5, 'C L'
540
+ check_validity
541
+
542
+ send_request FUNCTION_GET_MODBUS_CONFIGURATION, [], '', 13, 'C L'
519
543
  end
520
544
 
521
545
  # Sets the mode of the Bricklet in which it operates. Available options are
@@ -523,15 +547,17 @@ module Tinkerforge
523
547
  # * RS485,
524
548
  # * Modbus Master RTU and
525
549
  # * Modbus Slave RTU.
526
- #
527
- # The default is: RS485 mode.
528
550
  def set_mode(mode)
529
- send_request FUNCTION_SET_MODE, [mode], 'C', 0, ''
551
+ check_validity
552
+
553
+ send_request FUNCTION_SET_MODE, [mode], 'C', 8, ''
530
554
  end
531
555
 
532
556
  # Returns the configuration as set by BrickletRS485#set_mode.
533
557
  def get_mode
534
- send_request FUNCTION_GET_MODE, [], '', 1, 'C'
558
+ check_validity
559
+
560
+ send_request FUNCTION_GET_MODE, [], '', 9, 'C'
535
561
  end
536
562
 
537
563
  # Sets the communication LED configuration. By default the LED shows RS485
@@ -541,12 +567,16 @@ module Tinkerforge
541
567
  #
542
568
  # If the Bricklet is in bootloader mode, the LED is off.
543
569
  def set_communication_led_config(config)
544
- 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, ''
545
573
  end
546
574
 
547
575
  # Returns the configuration as set by BrickletRS485#set_communication_led_config
548
576
  def get_communication_led_config
549
- send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 1, 'C'
577
+ check_validity
578
+
579
+ send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 9, 'C'
550
580
  end
551
581
 
552
582
  # Sets the error LED configuration.
@@ -559,17 +589,21 @@ module Tinkerforge
559
589
  #
560
590
  # If the Bricklet is in bootloader mode, the LED is off.
561
591
  def set_error_led_config(config)
562
- 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, ''
563
595
  end
564
596
 
565
597
  # Returns the configuration as set by BrickletRS485#set_error_led_config.
566
598
  def get_error_led_config
567
- send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 1, 'C'
599
+ check_validity
600
+
601
+ send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
568
602
  end
569
603
 
570
604
  # Sets the send and receive buffer size in byte. In sum there is
571
- # 10240 byte (10kb) buffer available and the minimum buffer size
572
- # is 1024 byte (1kb) for both.
605
+ # 10240 byte (10KiB) buffer available and the minimum buffer size
606
+ # is 1024 byte (1KiB) for both.
573
607
  #
574
608
  # The current buffer content is lost if this function is called.
575
609
  #
@@ -577,47 +611,59 @@ module Tinkerforge
577
611
  # could not be written yet. The receive buffer holds data that is
578
612
  # received through RS485 but could not yet be send to the
579
613
  # user, either by BrickletRS485#read or through CALLBACK_READ callback.
580
- #
581
- # The default configuration is 5120 byte (5kb) per buffer.
582
614
  def set_buffer_config(send_buffer_size, receive_buffer_size)
583
- 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, ''
584
618
  end
585
619
 
586
620
  # Returns the buffer configuration as set by BrickletRS485#set_buffer_config.
587
621
  def get_buffer_config
588
- send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 4, 'S S'
622
+ check_validity
623
+
624
+ send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 12, 'S S'
589
625
  end
590
626
 
591
627
  # Returns the currently used bytes for the send and received buffer.
592
628
  #
593
629
  # See BrickletRS485#set_buffer_config for buffer size configuration.
594
630
  def get_buffer_status
595
- send_request FUNCTION_GET_BUFFER_STATUS, [], '', 4, 'S S'
631
+ check_validity
632
+
633
+ send_request FUNCTION_GET_BUFFER_STATUS, [], '', 12, 'S S'
596
634
  end
597
635
 
598
636
  # Enables the CALLBACK_ERROR_COUNT callback.
599
637
  #
600
638
  # By default the callback is disabled.
601
639
  def enable_error_count_callback
602
- send_request FUNCTION_ENABLE_ERROR_COUNT_CALLBACK, [], '', 0, ''
640
+ check_validity
641
+
642
+ send_request FUNCTION_ENABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
603
643
  end
604
644
 
605
645
  # Disables the CALLBACK_ERROR_COUNT callback.
606
646
  #
607
647
  # By default the callback is disabled.
608
648
  def disable_error_count_callback
609
- send_request FUNCTION_DISABLE_ERROR_COUNT_CALLBACK, [], '', 0, ''
649
+ check_validity
650
+
651
+ send_request FUNCTION_DISABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
610
652
  end
611
653
 
612
654
  # Returns *true* if the CALLBACK_ERROR_COUNT callback is enabled,
613
655
  # *false* otherwise.
614
656
  def is_error_count_callback_enabled
615
- send_request FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED, [], '', 1, '?'
657
+ check_validity
658
+
659
+ send_request FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED, [], '', 9, '?'
616
660
  end
617
661
 
618
662
  # Returns the current number of overrun and parity errors.
619
663
  def get_error_count
620
- send_request FUNCTION_GET_ERROR_COUNT, [], '', 8, 'L L'
664
+ check_validity
665
+
666
+ send_request FUNCTION_GET_ERROR_COUNT, [], '', 16, 'L L'
621
667
  end
622
668
 
623
669
  # Returns the current number of errors occurred in Modbus mode.
@@ -630,7 +676,9 @@ module Tinkerforge
630
676
  # * Illegal Data Value Error Count: Number of errors due to invalid data value. This corresponds to Modbus exception code 3.
631
677
  # * Slave Device Failure Error Count: Number of errors occurred on the slave device which were unrecoverable. This corresponds to Modbus exception code 4.
632
678
  def get_modbus_common_error_count
633
- 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'
634
682
  end
635
683
 
636
684
  # In Modbus slave mode this function can be used to report a Modbus exception for
@@ -639,7 +687,9 @@ module Tinkerforge
639
687
  # * Request ID: Request ID of the request received by the slave.
640
688
  # * Exception Code: Modbus exception code to report to the Modbus master.
641
689
  def modbus_slave_report_exception(request_id, exception_code)
642
- 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, ''
643
693
  end
644
694
 
645
695
  # In Modbus slave mode this function can be used to answer a master request to
@@ -651,7 +701,9 @@ module Tinkerforge
651
701
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST callback
652
702
  # with the Request ID as provided by the argument of the callback.
653
703
  def modbus_slave_answer_read_coils_request_low_level(request_id, coils_length, coils_chunk_offset, coils_chunk_data)
654
- 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, ''
655
707
  end
656
708
 
657
709
  # In Modbus master mode this function can be used to read coils from a slave. This
@@ -670,7 +722,9 @@ module Tinkerforge
670
722
  # matched with the Request ID returned from this function to verify that the callback
671
723
  # is indeed for a particular request.
672
724
  def modbus_master_read_coils(slave_address, starting_address, count)
673
- 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'
674
728
  end
675
729
 
676
730
  # In Modbus slave mode this function can be used to answer a master request to
@@ -682,7 +736,9 @@ module Tinkerforge
682
736
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST
683
737
  # callback with the Request ID as provided by the argument of the callback.
684
738
  def modbus_slave_answer_read_holding_registers_request_low_level(request_id, holding_registers_length, holding_registers_chunk_offset, holding_registers_chunk_data)
685
- 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, ''
686
742
  end
687
743
 
688
744
  # In Modbus master mode this function can be used to read holding registers from a slave.
@@ -701,7 +757,9 @@ module Tinkerforge
701
757
  # with the Request ID returned from this function to verify that the callback is indeed for a
702
758
  # particular request.
703
759
  def modbus_master_read_holding_registers(slave_address, starting_address, count)
704
- 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'
705
763
  end
706
764
 
707
765
  # In Modbus slave mode this function can be used to answer a master request to
@@ -712,7 +770,9 @@ module Tinkerforge
712
770
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST
713
771
  # callback with the Request ID as provided by the arguments of the callback.
714
772
  def modbus_slave_answer_write_single_coil_request(request_id)
715
- 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, ''
716
776
  end
717
777
 
718
778
  # In Modbus master mode this function can be used to write a single coil of a slave.
@@ -731,7 +791,9 @@ module Tinkerforge
731
791
  # with the Request ID returned from this function to verify that the callback is indeed for a
732
792
  # particular request.
733
793
  def modbus_master_write_single_coil(slave_address, coil_address, coil_value)
734
- 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'
735
797
  end
736
798
 
737
799
  # In Modbus slave mode this function can be used to answer a master request to
@@ -743,7 +805,9 @@ module Tinkerforge
743
805
  # callback with the Request ID, Register Address and Register Value as provided by
744
806
  # the arguments of the callback.
745
807
  def modbus_slave_answer_write_single_register_request(request_id)
746
- 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, ''
747
811
  end
748
812
 
749
813
  # In Modbus master mode this function can be used to write a single holding register of a
@@ -762,7 +826,9 @@ module Tinkerforge
762
826
  # with the Request ID returned from this function to verify that the callback is indeed for a
763
827
  # particular request.
764
828
  def modbus_master_write_single_register(slave_address, register_address, register_value)
765
- 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'
766
832
  end
767
833
 
768
834
  # In Modbus slave mode this function can be used to answer a master request to
@@ -773,7 +839,9 @@ module Tinkerforge
773
839
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST
774
840
  # callback with the Request ID of the callback.
775
841
  def modbus_slave_answer_write_multiple_coils_request(request_id)
776
- 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, ''
777
845
  end
778
846
 
779
847
  # In Modbus master mode this function can be used to write multiple coils of a slave.
@@ -791,7 +859,9 @@ module Tinkerforge
791
859
  # with the Request ID returned from this function to verify that the callback is indeed for a
792
860
  # particular request.
793
861
  def modbus_master_write_multiple_coils_low_level(slave_address, starting_address, coils_length, coils_chunk_offset, coils_chunk_data)
794
- 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'
795
865
  end
796
866
 
797
867
  # In Modbus slave mode this function can be used to answer a master request to
@@ -802,7 +872,9 @@ module Tinkerforge
802
872
  # This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST
803
873
  # callback with the Request ID of the callback.
804
874
  def modbus_slave_answer_write_multiple_registers_request(request_id)
805
- 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, ''
806
878
  end
807
879
 
808
880
  # In Modbus master mode this function can be used to write multiple registers of a slave.
@@ -820,7 +892,9 @@ module Tinkerforge
820
892
  # with the Request ID returned from this function to verify that the callback is indeed for a
821
893
  # particular request.
822
894
  def modbus_master_write_multiple_registers_low_level(slave_address, starting_address, registers_length, registers_chunk_offset, registers_chunk_data)
823
- 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'
824
898
  end
825
899
 
826
900
  # In Modbus slave mode this function can be used to answer a master request to
@@ -832,7 +906,9 @@ module Tinkerforge
832
906
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST
833
907
  # callback with the Request ID as provided by the argument of the callback.
834
908
  def modbus_slave_answer_read_discrete_inputs_request_low_level(request_id, discrete_inputs_length, discrete_inputs_chunk_offset, discrete_inputs_chunk_data)
835
- 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, ''
836
912
  end
837
913
 
838
914
  # In Modbus master mode this function can be used to read discrete inputs from a slave.
@@ -851,7 +927,9 @@ module Tinkerforge
851
927
  # with the Request ID returned from this function to verify that the callback is indeed for a
852
928
  # particular request.
853
929
  def modbus_master_read_discrete_inputs(slave_address, starting_address, count)
854
- 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'
855
933
  end
856
934
 
857
935
  # In Modbus slave mode this function can be used to answer a master request to
@@ -863,7 +941,9 @@ module Tinkerforge
863
941
  # This function must be called from the CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST callback
864
942
  # with the Request ID as provided by the argument of the callback.
865
943
  def modbus_slave_answer_read_input_registers_request_low_level(request_id, input_registers_length, input_registers_chunk_offset, input_registers_chunk_data)
866
- 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, ''
867
947
  end
868
948
 
869
949
  # In Modbus master mode this function can be used to read input registers from a slave.
@@ -882,7 +962,30 @@ module Tinkerforge
882
962
  # with the Request ID returned from this function to verify that the callback is indeed for a
883
963
  # particular request.
884
964
  def modbus_master_read_input_registers(slave_address, starting_address, count)
885
- 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'
886
989
  end
887
990
 
888
991
  # Returns the error count for the communication between Brick and Bricklet.
@@ -897,7 +1000,9 @@ module Tinkerforge
897
1000
  # The errors counts are for errors that occur on the Bricklet side. All
898
1001
  # Bricks have a similar function that returns the errors on the Brick side.
899
1002
  def get_spitfp_error_count
900
- 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'
901
1006
  end
902
1007
 
903
1008
  # Sets the bootloader mode and returns the status after the requested
@@ -910,12 +1015,16 @@ module Tinkerforge
910
1015
  # This function is used by Brick Viewer during flashing. It should not be
911
1016
  # necessary to call it in a normal user program.
912
1017
  def set_bootloader_mode(mode)
913
- 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'
914
1021
  end
915
1022
 
916
1023
  # Returns the current bootloader mode, see BrickletRS485#set_bootloader_mode.
917
1024
  def get_bootloader_mode
918
- send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
1025
+ check_validity
1026
+
1027
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
919
1028
  end
920
1029
 
921
1030
  # Sets the firmware pointer for BrickletRS485#write_firmware. The pointer has
@@ -925,7 +1034,9 @@ module Tinkerforge
925
1034
  # This function is used by Brick Viewer during flashing. It should not be
926
1035
  # necessary to call it in a normal user program.
927
1036
  def set_write_firmware_pointer(pointer)
928
- 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, ''
929
1040
  end
930
1041
 
931
1042
  # Writes 64 Bytes of firmware at the position as written by
@@ -937,7 +1048,9 @@ module Tinkerforge
937
1048
  # This function is used by Brick Viewer during flashing. It should not be
938
1049
  # necessary to call it in a normal user program.
939
1050
  def write_firmware(data)
940
- send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
1051
+ check_validity
1052
+
1053
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
941
1054
  end
942
1055
 
943
1056
  # Sets the status LED configuration. By default the LED shows
@@ -948,22 +1061,28 @@ module Tinkerforge
948
1061
  #
949
1062
  # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
950
1063
  def set_status_led_config(config)
951
- 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, ''
952
1067
  end
953
1068
 
954
1069
  # Returns the configuration as set by BrickletRS485#set_status_led_config
955
1070
  def get_status_led_config
956
- send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
1071
+ check_validity
1072
+
1073
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
957
1074
  end
958
1075
 
959
- # Returns the temperature in °C as measured inside the microcontroller. The
1076
+ # Returns the temperature as measured inside the microcontroller. The
960
1077
  # value returned is not the ambient temperature!
961
1078
  #
962
1079
  # The temperature is only proportional to the real temperature and it has bad
963
1080
  # accuracy. Practically it is only useful as an indicator for
964
1081
  # temperature changes.
965
1082
  def get_chip_temperature
966
- send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
1083
+ check_validity
1084
+
1085
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
967
1086
  end
968
1087
 
969
1088
  # Calling this function will reset the Bricklet. All configurations
@@ -973,7 +1092,9 @@ module Tinkerforge
973
1092
  # calling functions on the existing ones will result in
974
1093
  # undefined behavior!
975
1094
  def reset
976
- send_request FUNCTION_RESET, [], '', 0, ''
1095
+ check_validity
1096
+
1097
+ send_request FUNCTION_RESET, [], '', 8, ''
977
1098
  end
978
1099
 
979
1100
  # Writes a new UID into flash. If you want to set a new UID
@@ -982,25 +1103,31 @@ module Tinkerforge
982
1103
  #
983
1104
  # We recommend that you use Brick Viewer to change the UID.
984
1105
  def write_uid(uid)
985
- send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
1106
+ check_validity
1107
+
1108
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
986
1109
  end
987
1110
 
988
1111
  # Returns the current UID as an integer. Encode as
989
1112
  # Base58 to get the usual string version.
990
1113
  def read_uid
991
- send_request FUNCTION_READ_UID, [], '', 4, 'L'
1114
+ check_validity
1115
+
1116
+ send_request FUNCTION_READ_UID, [], '', 12, 'L'
992
1117
  end
993
1118
 
994
1119
  # Returns the UID, the UID where the Bricklet is connected to,
995
1120
  # the position, the hardware and firmware version as well as the
996
1121
  # device identifier.
997
1122
  #
998
- # 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'.
999
1126
  #
1000
1127
  # The device identifier numbers can be found :ref:`here <device_identifier>`.
1001
1128
  # |device_identifier_constant|
1002
1129
  def get_identity
1003
- 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'
1004
1131
  end
1005
1132
 
1006
1133
  # Writes characters to the RS485 interface. The characters can be binary data,