tinkerforge 2.1.24 → 2.1.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tinkerforge/brick_dc.rb +155 -74
- data/lib/tinkerforge/brick_hat.rb +70 -30
- data/lib/tinkerforge/brick_hat_zero.rb +56 -22
- data/lib/tinkerforge/brick_imu.rb +184 -77
- data/lib/tinkerforge/brick_imu_v2.rb +208 -105
- data/lib/tinkerforge/brick_master.rb +484 -182
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +185 -101
- data/lib/tinkerforge/brick_silent_stepper.rb +246 -166
- data/lib/tinkerforge/brick_stepper.rb +210 -98
- data/lib/tinkerforge/bricklet_accelerometer.rb +58 -23
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +105 -54
- data/lib/tinkerforge/bricklet_air_quality.rb +117 -59
- data/lib/tinkerforge/bricklet_ambient_light.rb +51 -21
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +40 -22
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -25
- data/lib/tinkerforge/bricklet_analog_in.rb +63 -25
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +67 -25
- data/lib/tinkerforge/bricklet_analog_out.rb +23 -9
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +20 -8
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +54 -20
- data/lib/tinkerforge/bricklet_barometer.rb +66 -26
- data/lib/tinkerforge/bricklet_barometer_v2.rb +99 -37
- data/lib/tinkerforge/bricklet_can.rb +83 -18
- data/lib/tinkerforge/bricklet_can_v2.rb +172 -38
- data/lib/tinkerforge/bricklet_co2.rb +34 -14
- data/lib/tinkerforge/bricklet_co2_v2.rb +97 -37
- data/lib/tinkerforge/bricklet_color.rb +69 -27
- data/lib/tinkerforge/bricklet_color_v2.rb +87 -33
- data/lib/tinkerforge/bricklet_compass.rb +78 -30
- data/lib/tinkerforge/bricklet_current12.rb +58 -24
- data/lib/tinkerforge/bricklet_current25.rb +58 -24
- data/lib/tinkerforge/bricklet_distance_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_distance_us.rb +40 -16
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_dmx.rb +88 -34
- data/lib/tinkerforge/bricklet_dual_button.rb +24 -10
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -24
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -11
- data/lib/tinkerforge/bricklet_dust_detector.rb +40 -16
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +88 -32
- data/lib/tinkerforge/bricklet_energy_monitor.rb +73 -27
- data/lib/tinkerforge/bricklet_gps.rb +64 -26
- data/lib/tinkerforge/bricklet_gps_v2.rb +117 -47
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -23
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_humidity.rb +51 -21
- data/lib/tinkerforge/bricklet_humidity_v2.rb +83 -31
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +38 -14
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +81 -29
- data/lib/tinkerforge/bricklet_industrial_counter.rb +101 -39
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +45 -17
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +77 -29
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +73 -27
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +40 -16
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +79 -29
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +49 -19
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +82 -30
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +61 -23
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -14
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -25
- data/lib/tinkerforge/bricklet_io16.rb +55 -21
- data/lib/tinkerforge/bricklet_io16_v2.rb +90 -34
- data/lib/tinkerforge/bricklet_io4.rb +55 -23
- data/lib/tinkerforge/bricklet_io4_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_isolator.rb +72 -28
- data/lib/tinkerforge/bricklet_joystick.rb +59 -25
- data/lib/tinkerforge/bricklet_joystick_v2.rb +68 -26
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +82 -32
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +96 -36
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +192 -70
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +45 -18
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +58 -23
- data/lib/tinkerforge/bricklet_led_strip.rb +60 -22
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +91 -46
- data/lib/tinkerforge/bricklet_line.rb +34 -14
- data/lib/tinkerforge/bricklet_linear_poti.rb +51 -21
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -21
- data/lib/tinkerforge/bricklet_load_cell.rb +61 -23
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +80 -30
- data/lib/tinkerforge/bricklet_moisture.rb +40 -16
- data/lib/tinkerforge/bricklet_motion_detector.rb +22 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -24
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -27
- data/lib/tinkerforge/bricklet_multi_touch.rb +31 -13
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +76 -28
- data/lib/tinkerforge/bricklet_nfc.rb +123 -58
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +33 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +29 -11
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +66 -24
- data/lib/tinkerforge/bricklet_oled_64x48.rb +29 -11
- data/lib/tinkerforge/bricklet_one_wire.rb +66 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +71 -27
- data/lib/tinkerforge/bricklet_particulate_matter.rb +75 -30
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -9
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -10
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +80 -42
- data/lib/tinkerforge/bricklet_ptc.rb +74 -42
- data/lib/tinkerforge/bricklet_ptc_v2.rb +95 -48
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -33
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -44
- data/lib/tinkerforge/bricklet_remote_switch.rb +39 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +87 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +18 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +62 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +79 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +52 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +39 -19
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -24
- data/lib/tinkerforge/bricklet_rotary_poti.rb +53 -28
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +57 -23
- data/lib/tinkerforge/bricklet_rs232.rb +90 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +118 -44
- data/lib/tinkerforge/bricklet_rs485.rb +223 -95
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +25 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -35
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +25 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +59 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +35 -18
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +72 -31
- data/lib/tinkerforge/bricklet_temperature.rb +40 -16
- data/lib/tinkerforge/bricklet_temperature_ir.rb +57 -23
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +71 -27
- data/lib/tinkerforge/bricklet_temperature_v2.rb +61 -25
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +105 -44
- data/lib/tinkerforge/bricklet_thermocouple.rb +45 -24
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -27
- data/lib/tinkerforge/bricklet_tilt.rb +24 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +36 -18
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +85 -37
- data/lib/tinkerforge/bricklet_voltage.rb +52 -28
- data/lib/tinkerforge/bricklet_voltage_current.rb +91 -73
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +90 -68
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +80 -30
- data/lib/tinkerforge/device_display_names.rb +163 -0
- data/lib/tinkerforge/ip_connection.rb +151 -32
- data/lib/tinkerforge/version.rb +1 -1
- metadata +3 -2
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2020-04-07. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
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 air pressure and altitude changes
|
14
16
|
class BrickletBarometerV2 < Device
|
@@ -96,7 +98,7 @@ module Tinkerforge
|
|
96
98
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
97
99
|
# the IP Connection <tt>ipcon</tt>.
|
98
100
|
def initialize(uid, ipcon)
|
99
|
-
super uid, ipcon
|
101
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
100
102
|
|
101
103
|
@api_version = [2, 0, 0]
|
102
104
|
|
@@ -130,10 +132,11 @@ module Tinkerforge
|
|
130
132
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
131
133
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
132
134
|
|
133
|
-
@callback_formats[CALLBACK_AIR_PRESSURE] = 'l'
|
134
|
-
@callback_formats[CALLBACK_ALTITUDE] = 'l'
|
135
|
-
@callback_formats[CALLBACK_TEMPERATURE] = 'l'
|
135
|
+
@callback_formats[CALLBACK_AIR_PRESSURE] = [12, 'l']
|
136
|
+
@callback_formats[CALLBACK_ALTITUDE] = [12, 'l']
|
137
|
+
@callback_formats[CALLBACK_TEMPERATURE] = [12, 'l']
|
136
138
|
|
139
|
+
@ipcon.add_device self
|
137
140
|
end
|
138
141
|
|
139
142
|
# Returns the measured air pressure.
|
@@ -143,7 +146,9 @@ module Tinkerforge
|
|
143
146
|
# CALLBACK_AIR_PRESSURE callback. You can set the callback configuration
|
144
147
|
# with BrickletBarometerV2#set_air_pressure_callback_configuration.
|
145
148
|
def get_air_pressure
|
146
|
-
|
149
|
+
check_validity
|
150
|
+
|
151
|
+
send_request FUNCTION_GET_AIR_PRESSURE, [], '', 12, 'l'
|
147
152
|
end
|
148
153
|
|
149
154
|
# The period is the period with which the CALLBACK_AIR_PRESSURE callback is triggered
|
@@ -172,12 +177,16 @@ module Tinkerforge
|
|
172
177
|
#
|
173
178
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
174
179
|
def set_air_pressure_callback_configuration(period, value_has_to_change, option, min, max)
|
175
|
-
|
180
|
+
check_validity
|
181
|
+
|
182
|
+
send_request FUNCTION_SET_AIR_PRESSURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
176
183
|
end
|
177
184
|
|
178
185
|
# Returns the callback configuration as set by BrickletBarometerV2#set_air_pressure_callback_configuration.
|
179
186
|
def get_air_pressure_callback_configuration
|
180
|
-
|
187
|
+
check_validity
|
188
|
+
|
189
|
+
send_request FUNCTION_GET_AIR_PRESSURE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
181
190
|
end
|
182
191
|
|
183
192
|
# Returns the relative altitude of the air pressure sensor. The value
|
@@ -190,7 +199,9 @@ module Tinkerforge
|
|
190
199
|
# CALLBACK_ALTITUDE callback. You can set the callback configuration
|
191
200
|
# with BrickletBarometerV2#set_altitude_callback_configuration.
|
192
201
|
def get_altitude
|
193
|
-
|
202
|
+
check_validity
|
203
|
+
|
204
|
+
send_request FUNCTION_GET_ALTITUDE, [], '', 12, 'l'
|
194
205
|
end
|
195
206
|
|
196
207
|
# The period is the period with which the CALLBACK_ALTITUDE callback is triggered
|
@@ -219,12 +230,16 @@ module Tinkerforge
|
|
219
230
|
#
|
220
231
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
221
232
|
def set_altitude_callback_configuration(period, value_has_to_change, option, min, max)
|
222
|
-
|
233
|
+
check_validity
|
234
|
+
|
235
|
+
send_request FUNCTION_SET_ALTITUDE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
223
236
|
end
|
224
237
|
|
225
238
|
# Returns the callback configuration as set by BrickletBarometerV2#set_altitude_callback_configuration.
|
226
239
|
def get_altitude_callback_configuration
|
227
|
-
|
240
|
+
check_validity
|
241
|
+
|
242
|
+
send_request FUNCTION_GET_ALTITUDE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
228
243
|
end
|
229
244
|
|
230
245
|
# Returns the temperature of the air pressure sensor.
|
@@ -239,7 +254,9 @@ module Tinkerforge
|
|
239
254
|
# CALLBACK_TEMPERATURE callback. You can set the callback configuration
|
240
255
|
# with BrickletBarometerV2#set_temperature_callback_configuration.
|
241
256
|
def get_temperature
|
242
|
-
|
257
|
+
check_validity
|
258
|
+
|
259
|
+
send_request FUNCTION_GET_TEMPERATURE, [], '', 12, 'l'
|
243
260
|
end
|
244
261
|
|
245
262
|
# The period is the period with which the CALLBACK_TEMPERATURE callback is triggered
|
@@ -268,12 +285,16 @@ module Tinkerforge
|
|
268
285
|
#
|
269
286
|
# If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
|
270
287
|
def set_temperature_callback_configuration(period, value_has_to_change, option, min, max)
|
271
|
-
|
288
|
+
check_validity
|
289
|
+
|
290
|
+
send_request FUNCTION_SET_TEMPERATURE_CALLBACK_CONFIGURATION, [period, value_has_to_change, option, min, max], 'L ? k l l', 8, ''
|
272
291
|
end
|
273
292
|
|
274
293
|
# Returns the callback configuration as set by BrickletBarometerV2#set_temperature_callback_configuration.
|
275
294
|
def get_temperature_callback_configuration
|
276
|
-
|
295
|
+
check_validity
|
296
|
+
|
297
|
+
send_request FUNCTION_GET_TEMPERATURE_CALLBACK_CONFIGURATION, [], '', 22, 'L ? k l l'
|
277
298
|
end
|
278
299
|
|
279
300
|
# Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
|
@@ -285,13 +306,17 @@ module Tinkerforge
|
|
285
306
|
# If you want to do long term measurements the longest moving average will give
|
286
307
|
# the cleanest results.
|
287
308
|
def set_moving_average_configuration(moving_average_length_air_pressure, moving_average_length_temperature)
|
288
|
-
|
309
|
+
check_validity
|
310
|
+
|
311
|
+
send_request FUNCTION_SET_MOVING_AVERAGE_CONFIGURATION, [moving_average_length_air_pressure, moving_average_length_temperature], 'S S', 8, ''
|
289
312
|
end
|
290
313
|
|
291
314
|
# Returns the moving average configuration as set by
|
292
315
|
# BrickletBarometerV2#set_moving_average_configuration.
|
293
316
|
def get_moving_average_configuration
|
294
|
-
|
317
|
+
check_validity
|
318
|
+
|
319
|
+
send_request FUNCTION_GET_MOVING_AVERAGE_CONFIGURATION, [], '', 12, 'S S'
|
295
320
|
end
|
296
321
|
|
297
322
|
# Sets the reference air pressure for the altitude calculation.
|
@@ -304,12 +329,16 @@ module Tinkerforge
|
|
304
329
|
# `QFE <https://en.wikipedia.org/wiki/Mean_sea_level_pressure#Mean_sea_level_pressure>`__
|
305
330
|
# used in aviation.
|
306
331
|
def set_reference_air_pressure(air_pressure)
|
307
|
-
|
332
|
+
check_validity
|
333
|
+
|
334
|
+
send_request FUNCTION_SET_REFERENCE_AIR_PRESSURE, [air_pressure], 'l', 8, ''
|
308
335
|
end
|
309
336
|
|
310
337
|
# Returns the reference air pressure as set by BrickletBarometerV2#set_reference_air_pressure.
|
311
338
|
def get_reference_air_pressure
|
312
|
-
|
339
|
+
check_validity
|
340
|
+
|
341
|
+
send_request FUNCTION_GET_REFERENCE_AIR_PRESSURE, [], '', 12, 'l'
|
313
342
|
end
|
314
343
|
|
315
344
|
# Sets the one point calibration (OPC) values for the air pressure measurement.
|
@@ -327,13 +356,17 @@ module Tinkerforge
|
|
327
356
|
# The calibration is saved in the EEPROM of the Bricklet and only needs to be
|
328
357
|
# configured once.
|
329
358
|
def set_calibration(measured_air_pressure, actual_air_pressure)
|
330
|
-
|
359
|
+
check_validity
|
360
|
+
|
361
|
+
send_request FUNCTION_SET_CALIBRATION, [measured_air_pressure, actual_air_pressure], 'l l', 8, ''
|
331
362
|
end
|
332
363
|
|
333
364
|
# Returns the air pressure one point calibration values as set by
|
334
365
|
# BrickletBarometerV2#set_calibration.
|
335
366
|
def get_calibration
|
336
|
-
|
367
|
+
check_validity
|
368
|
+
|
369
|
+
send_request FUNCTION_GET_CALIBRATION, [], '', 16, 'l l'
|
337
370
|
end
|
338
371
|
|
339
372
|
# Configures the data rate and air pressure low pass filter. The low pass filter
|
@@ -347,12 +380,16 @@ module Tinkerforge
|
|
347
380
|
# self-heating of the sensor. If the accuracy of the temperature reading is
|
348
381
|
# important to you, we would recommend the 1Hz data rate.
|
349
382
|
def set_sensor_configuration(data_rate, air_pressure_low_pass_filter)
|
350
|
-
|
383
|
+
check_validity
|
384
|
+
|
385
|
+
send_request FUNCTION_SET_SENSOR_CONFIGURATION, [data_rate, air_pressure_low_pass_filter], 'C C', 8, ''
|
351
386
|
end
|
352
387
|
|
353
388
|
# Returns the sensor configuration as set by BrickletBarometerV2#set_sensor_configuration.
|
354
389
|
def get_sensor_configuration
|
355
|
-
|
390
|
+
check_validity
|
391
|
+
|
392
|
+
send_request FUNCTION_GET_SENSOR_CONFIGURATION, [], '', 10, 'C C'
|
356
393
|
end
|
357
394
|
|
358
395
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -367,7 +404,9 @@ module Tinkerforge
|
|
367
404
|
# The errors counts are for errors that occur on the Bricklet side. All
|
368
405
|
# Bricks have a similar function that returns the errors on the Brick side.
|
369
406
|
def get_spitfp_error_count
|
370
|
-
|
407
|
+
check_validity
|
408
|
+
|
409
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
371
410
|
end
|
372
411
|
|
373
412
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -380,12 +419,16 @@ module Tinkerforge
|
|
380
419
|
# This function is used by Brick Viewer during flashing. It should not be
|
381
420
|
# necessary to call it in a normal user program.
|
382
421
|
def set_bootloader_mode(mode)
|
383
|
-
|
422
|
+
check_validity
|
423
|
+
|
424
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
384
425
|
end
|
385
426
|
|
386
427
|
# Returns the current bootloader mode, see BrickletBarometerV2#set_bootloader_mode.
|
387
428
|
def get_bootloader_mode
|
388
|
-
|
429
|
+
check_validity
|
430
|
+
|
431
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
389
432
|
end
|
390
433
|
|
391
434
|
# Sets the firmware pointer for BrickletBarometerV2#write_firmware. The pointer has
|
@@ -395,7 +438,9 @@ module Tinkerforge
|
|
395
438
|
# This function is used by Brick Viewer during flashing. It should not be
|
396
439
|
# necessary to call it in a normal user program.
|
397
440
|
def set_write_firmware_pointer(pointer)
|
398
|
-
|
441
|
+
check_validity
|
442
|
+
|
443
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
399
444
|
end
|
400
445
|
|
401
446
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -407,7 +452,9 @@ module Tinkerforge
|
|
407
452
|
# This function is used by Brick Viewer during flashing. It should not be
|
408
453
|
# necessary to call it in a normal user program.
|
409
454
|
def write_firmware(data)
|
410
|
-
|
455
|
+
check_validity
|
456
|
+
|
457
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
411
458
|
end
|
412
459
|
|
413
460
|
# Sets the status LED configuration. By default the LED shows
|
@@ -418,22 +465,28 @@ module Tinkerforge
|
|
418
465
|
#
|
419
466
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
420
467
|
def set_status_led_config(config)
|
421
|
-
|
468
|
+
check_validity
|
469
|
+
|
470
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
422
471
|
end
|
423
472
|
|
424
473
|
# Returns the configuration as set by BrickletBarometerV2#set_status_led_config
|
425
474
|
def get_status_led_config
|
426
|
-
|
475
|
+
check_validity
|
476
|
+
|
477
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
427
478
|
end
|
428
479
|
|
429
|
-
# Returns the temperature
|
480
|
+
# Returns the temperature as measured inside the microcontroller. The
|
430
481
|
# value returned is not the ambient temperature!
|
431
482
|
#
|
432
483
|
# The temperature is only proportional to the real temperature and it has bad
|
433
484
|
# accuracy. Practically it is only useful as an indicator for
|
434
485
|
# temperature changes.
|
435
486
|
def get_chip_temperature
|
436
|
-
|
487
|
+
check_validity
|
488
|
+
|
489
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
437
490
|
end
|
438
491
|
|
439
492
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -443,7 +496,9 @@ module Tinkerforge
|
|
443
496
|
# calling functions on the existing ones will result in
|
444
497
|
# undefined behavior!
|
445
498
|
def reset
|
446
|
-
|
499
|
+
check_validity
|
500
|
+
|
501
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
447
502
|
end
|
448
503
|
|
449
504
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -452,25 +507,32 @@ module Tinkerforge
|
|
452
507
|
#
|
453
508
|
# We recommend that you use Brick Viewer to change the UID.
|
454
509
|
def write_uid(uid)
|
455
|
-
|
510
|
+
check_validity
|
511
|
+
|
512
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
456
513
|
end
|
457
514
|
|
458
515
|
# Returns the current UID as an integer. Encode as
|
459
516
|
# Base58 to get the usual string version.
|
460
517
|
def read_uid
|
461
|
-
|
518
|
+
check_validity
|
519
|
+
|
520
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
462
521
|
end
|
463
522
|
|
464
523
|
# Returns the UID, the UID where the Bricklet is connected to,
|
465
524
|
# the position, the hardware and firmware version as well as the
|
466
525
|
# device identifier.
|
467
526
|
#
|
468
|
-
# The position can be 'a', 'b', 'c' or '
|
527
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
528
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
529
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
530
|
+
# position 'z'.
|
469
531
|
#
|
470
532
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
471
533
|
# |device_identifier_constant|
|
472
534
|
def get_identity
|
473
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
535
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
474
536
|
end
|
475
537
|
|
476
538
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
@@ -1,14 +1,16 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on
|
3
|
+
# This file was automatically generated on 2020-04-07. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.25 #
|
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 CAN bus devices
|
14
16
|
class BrickletCAN < Device
|
@@ -29,6 +31,20 @@ module Tinkerforge
|
|
29
31
|
# To enable this callback, use BrickletCAN#enable_frame_read_callback.
|
30
32
|
CALLBACK_FRAME_READ = 11
|
31
33
|
|
34
|
+
# This callback is triggered if a data or remote frame was received by the CAN
|
35
|
+
# transceiver. The received frame can be read with BrickletCAN#read_frame.
|
36
|
+
# If additional frames are received, but BrickletCAN#read_frame was not called yet, the callback
|
37
|
+
# will not trigger again.
|
38
|
+
#
|
39
|
+
# A configurable read filter can be used to define which frames should be
|
40
|
+
# received by the CAN transceiver and put into the read queue (see
|
41
|
+
# BrickletCAN#set_read_filter).
|
42
|
+
#
|
43
|
+
# To enable this callback, use BrickletCAN#set_frame_readable_callback_configuration.
|
44
|
+
#
|
45
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
46
|
+
CALLBACK_FRAME_READABLE = 14
|
47
|
+
|
32
48
|
FUNCTION_WRITE_FRAME = 1 # :nodoc:
|
33
49
|
FUNCTION_READ_FRAME = 2 # :nodoc:
|
34
50
|
FUNCTION_ENABLE_FRAME_READ_CALLBACK = 3 # :nodoc:
|
@@ -39,6 +55,8 @@ module Tinkerforge
|
|
39
55
|
FUNCTION_SET_READ_FILTER = 8 # :nodoc:
|
40
56
|
FUNCTION_GET_READ_FILTER = 9 # :nodoc:
|
41
57
|
FUNCTION_GET_ERROR_LOG = 10 # :nodoc:
|
58
|
+
FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION = 12 # :nodoc:
|
59
|
+
FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION = 13 # :nodoc:
|
42
60
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
43
61
|
|
44
62
|
FRAME_TYPE_STANDARD_DATA = 0 # :nodoc:
|
@@ -65,9 +83,9 @@ module Tinkerforge
|
|
65
83
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
66
84
|
# the IP Connection <tt>ipcon</tt>.
|
67
85
|
def initialize(uid, ipcon)
|
68
|
-
super uid, ipcon
|
86
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
69
87
|
|
70
|
-
@api_version = [2, 0,
|
88
|
+
@api_version = [2, 0, 1]
|
71
89
|
|
72
90
|
@response_expected[FUNCTION_WRITE_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
73
91
|
@response_expected[FUNCTION_READ_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -79,10 +97,14 @@ module Tinkerforge
|
|
79
97
|
@response_expected[FUNCTION_SET_READ_FILTER] = RESPONSE_EXPECTED_FALSE
|
80
98
|
@response_expected[FUNCTION_GET_READ_FILTER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
81
99
|
@response_expected[FUNCTION_GET_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
100
|
+
@response_expected[FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
101
|
+
@response_expected[FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
82
102
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
83
103
|
|
84
|
-
@callback_formats[CALLBACK_FRAME_READ] = 'C L C8 C'
|
104
|
+
@callback_formats[CALLBACK_FRAME_READ] = [22, 'C L C8 C']
|
105
|
+
@callback_formats[CALLBACK_FRAME_READABLE] = [8, '']
|
85
106
|
|
107
|
+
@ipcon.add_device self
|
86
108
|
end
|
87
109
|
|
88
110
|
# Writes a data or remote frame to the write buffer to be transmitted over the
|
@@ -107,7 +129,9 @@ module Tinkerforge
|
|
107
129
|
# arbitration or because the CAN transceiver is currently disabled due to a high
|
108
130
|
# write error level (see BrickletCAN#get_error_log).
|
109
131
|
def write_frame(frame_type, identifier, data, length)
|
110
|
-
|
132
|
+
check_validity
|
133
|
+
|
134
|
+
send_request FUNCTION_WRITE_FRAME, [frame_type, identifier, data, length], 'C L C8 C', 9, '?'
|
111
135
|
end
|
112
136
|
|
113
137
|
# Tries to read the next data or remote frame from the read buffer and return it.
|
@@ -128,26 +152,34 @@ module Tinkerforge
|
|
128
152
|
# Instead of polling with this function, you can also use callbacks. See the
|
129
153
|
# BrickletCAN#enable_frame_read_callback function and the CALLBACK_FRAME_READ callback.
|
130
154
|
def read_frame
|
131
|
-
|
155
|
+
check_validity
|
156
|
+
|
157
|
+
send_request FUNCTION_READ_FRAME, [], '', 23, '? C L C8 C'
|
132
158
|
end
|
133
159
|
|
134
160
|
# Enables the CALLBACK_FRAME_READ callback.
|
135
161
|
#
|
136
|
-
# By default the callback is disabled.
|
162
|
+
# By default the callback is disabled. Enabling this callback will disable the CALLBACK_FRAME_READABLE callback.
|
137
163
|
def enable_frame_read_callback
|
138
|
-
|
164
|
+
check_validity
|
165
|
+
|
166
|
+
send_request FUNCTION_ENABLE_FRAME_READ_CALLBACK, [], '', 8, ''
|
139
167
|
end
|
140
168
|
|
141
169
|
# Disables the CALLBACK_FRAME_READ callback.
|
142
170
|
#
|
143
171
|
# By default the callback is disabled.
|
144
172
|
def disable_frame_read_callback
|
145
|
-
|
173
|
+
check_validity
|
174
|
+
|
175
|
+
send_request FUNCTION_DISABLE_FRAME_READ_CALLBACK, [], '', 8, ''
|
146
176
|
end
|
147
177
|
|
148
178
|
# Returns *true* if the CALLBACK_FRAME_READ callback is enabled, *false* otherwise.
|
149
179
|
def is_frame_read_callback_enabled
|
150
|
-
|
180
|
+
check_validity
|
181
|
+
|
182
|
+
send_request FUNCTION_IS_FRAME_READ_CALLBACK_ENABLED, [], '', 9, '?'
|
151
183
|
end
|
152
184
|
|
153
185
|
# Sets the configuration for the CAN bus communication.
|
@@ -175,12 +207,16 @@ module Tinkerforge
|
|
175
207
|
# If the frame could not be transmitted successfully after the configured
|
176
208
|
# number of milliseconds then the frame is discarded.
|
177
209
|
def set_configuration(baud_rate, transceiver_mode, write_timeout)
|
178
|
-
|
210
|
+
check_validity
|
211
|
+
|
212
|
+
send_request FUNCTION_SET_CONFIGURATION, [baud_rate, transceiver_mode, write_timeout], 'C C l', 8, ''
|
179
213
|
end
|
180
214
|
|
181
215
|
# Returns the configuration as set by BrickletCAN#set_configuration.
|
182
216
|
def get_configuration
|
183
|
-
|
217
|
+
check_validity
|
218
|
+
|
219
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 14, 'C C l'
|
184
220
|
end
|
185
221
|
|
186
222
|
# Set the read filter configuration. This can be used to define which frames
|
@@ -234,12 +270,16 @@ module Tinkerforge
|
|
234
270
|
# To accept identifier 0x123 and identifier 0x456 at the same time, just set
|
235
271
|
# filter 2 to 0x456 and keep mask and filter 1 unchanged.
|
236
272
|
def set_read_filter(mode, mask, filter1, filter2)
|
237
|
-
|
273
|
+
check_validity
|
274
|
+
|
275
|
+
send_request FUNCTION_SET_READ_FILTER, [mode, mask, filter1, filter2], 'C L L L', 8, ''
|
238
276
|
end
|
239
277
|
|
240
278
|
# Returns the read filter as set by BrickletCAN#set_read_filter.
|
241
279
|
def get_read_filter
|
242
|
-
|
280
|
+
check_validity
|
281
|
+
|
282
|
+
send_request FUNCTION_GET_READ_FILTER, [], '', 21, 'C L L L'
|
243
283
|
end
|
244
284
|
|
245
285
|
# Returns information about different kinds of errors.
|
@@ -276,19 +316,44 @@ module Tinkerforge
|
|
276
316
|
# function. Using the CALLBACK_FRAME_READ callback ensures that the read buffer
|
277
317
|
# can not overflow.
|
278
318
|
def get_error_log
|
279
|
-
|
319
|
+
check_validity
|
320
|
+
|
321
|
+
send_request FUNCTION_GET_ERROR_LOG, [], '', 23, 'C C ? L L L'
|
322
|
+
end
|
323
|
+
|
324
|
+
# Enables/disables the CALLBACK_FRAME_READABLE callback.
|
325
|
+
#
|
326
|
+
# By default the callback is disabled. Enabling this callback will disable the CALLBACK_FRAME_READ callback.
|
327
|
+
#
|
328
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
329
|
+
def set_frame_readable_callback_configuration(enabled)
|
330
|
+
check_validity
|
331
|
+
|
332
|
+
send_request FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION, [enabled], '?', 8, ''
|
333
|
+
end
|
334
|
+
|
335
|
+
# Returns *true* if the CALLBACK_FRAME_READABLE callback is enabled, *false* otherwise.
|
336
|
+
#
|
337
|
+
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
338
|
+
def get_frame_readable_callback_configuration
|
339
|
+
check_validity
|
340
|
+
|
341
|
+
send_request FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION, [], '', 9, '?'
|
280
342
|
end
|
281
343
|
|
282
344
|
# Returns the UID, the UID where the Bricklet is connected to,
|
283
345
|
# the position, the hardware and firmware version as well as the
|
284
346
|
# device identifier.
|
285
347
|
#
|
286
|
-
# The position can be 'a', 'b', 'c' or '
|
348
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
349
|
+
# The Raspberry Pi HAT (Zero) Brick is always at position 'i' and the Bricklet
|
350
|
+
# connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always as
|
351
|
+
# position 'z'.
|
287
352
|
#
|
288
353
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
289
354
|
# |device_identifier_constant|
|
290
355
|
def get_identity
|
291
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
356
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
292
357
|
end
|
293
358
|
|
294
359
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|