tinkerforge 2.1.22 → 2.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/lib/tinkerforge/brick_dc.rb +157 -76
- data/lib/tinkerforge/brick_hat.rb +115 -32
- data/lib/tinkerforge/brick_hat_zero.rb +119 -21
- data/lib/tinkerforge/brick_imu.rb +192 -87
- data/lib/tinkerforge/brick_imu_v2.rb +220 -119
- data/lib/tinkerforge/brick_master.rb +498 -198
- data/lib/tinkerforge/brick_red.rb +197 -74
- data/lib/tinkerforge/brick_servo.rb +187 -103
- data/lib/tinkerforge/brick_silent_stepper.rb +249 -169
- data/lib/tinkerforge/brick_stepper.rb +214 -102
- data/lib/tinkerforge/bricklet_accelerometer.rb +61 -36
- data/lib/tinkerforge/bricklet_accelerometer_v2.rb +167 -48
- data/lib/tinkerforge/bricklet_air_quality.rb +123 -76
- data/lib/tinkerforge/bricklet_ambient_light.rb +62 -46
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +41 -28
- data/lib/tinkerforge/bricklet_ambient_light_v3.rb +61 -28
- data/lib/tinkerforge/bricklet_analog_in.rb +66 -45
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +60 -43
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +68 -32
- data/lib/tinkerforge/bricklet_analog_out.rb +25 -16
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +21 -10
- data/lib/tinkerforge/bricklet_analog_out_v3.rb +55 -22
- data/lib/tinkerforge/bricklet_barometer.rb +108 -58
- data/lib/tinkerforge/bricklet_barometer_v2.rb +109 -67
- data/lib/tinkerforge/bricklet_can.rb +84 -24
- data/lib/tinkerforge/bricklet_can_v2.rb +173 -72
- data/lib/tinkerforge/bricklet_co2.rb +36 -25
- data/lib/tinkerforge/bricklet_co2_v2.rb +119 -60
- data/lib/tinkerforge/bricklet_color.rb +77 -49
- data/lib/tinkerforge/bricklet_color_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_compass.rb +397 -0
- data/lib/tinkerforge/bricklet_current12.rb +61 -40
- data/lib/tinkerforge/bricklet_current25.rb +61 -40
- data/lib/tinkerforge/bricklet_distance_ir.rb +60 -38
- data/lib/tinkerforge/bricklet_distance_ir_v2.rb +85 -45
- data/lib/tinkerforge/bricklet_distance_us.rb +43 -30
- data/lib/tinkerforge/bricklet_distance_us_v2.rb +335 -0
- data/lib/tinkerforge/bricklet_dmx.rb +92 -48
- data/lib/tinkerforge/bricklet_dual_button.rb +23 -12
- data/lib/tinkerforge/bricklet_dual_button_v2.rb +64 -29
- data/lib/tinkerforge/bricklet_dual_relay.rb +27 -14
- data/lib/tinkerforge/bricklet_dust_detector.rb +43 -30
- data/lib/tinkerforge/bricklet_e_paper_296x128.rb +115 -63
- data/lib/tinkerforge/bricklet_energy_monitor.rb +416 -0
- data/lib/tinkerforge/bricklet_gps.rb +72 -48
- data/lib/tinkerforge/bricklet_gps_v2.rb +124 -73
- data/lib/tinkerforge/bricklet_hall_effect.rb +43 -28
- data/lib/tinkerforge/bricklet_hall_effect_v2.rb +76 -44
- data/lib/tinkerforge/bricklet_humidity.rb +54 -38
- data/lib/tinkerforge/bricklet_humidity_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_imu_v3.rb +784 -0
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +41 -18
- data/lib/tinkerforge/bricklet_industrial_analog_out_v2.rb +84 -40
- data/lib/tinkerforge/bricklet_industrial_counter.rb +102 -59
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +51 -24
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +79 -40
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_digital_out_4_v2.rb +75 -33
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +43 -29
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma_v2.rb +81 -44
- data/lib/tinkerforge/bricklet_industrial_dual_ac_relay.rb +325 -0
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +51 -30
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in_v2.rb +139 -40
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +63 -28
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +36 -15
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +67 -28
- data/lib/tinkerforge/bricklet_io16.rb +57 -32
- data/lib/tinkerforge/bricklet_io16_v2.rb +93 -48
- data/lib/tinkerforge/bricklet_io4.rb +56 -31
- data/lib/tinkerforge/bricklet_io4_v2.rb +109 -57
- data/lib/tinkerforge/bricklet_isolator.rb +111 -35
- data/lib/tinkerforge/bricklet_joystick.rb +63 -42
- data/lib/tinkerforge/bricklet_joystick_v2.rb +71 -35
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +87 -59
- data/lib/tinkerforge/bricklet_laser_range_finder_v2.rb +101 -53
- data/lib/tinkerforge/bricklet_lcd_128x64.rb +241 -131
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +49 -25
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +59 -29
- data/lib/tinkerforge/bricklet_led_strip.rb +69 -47
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +105 -48
- data/lib/tinkerforge/bricklet_line.rb +35 -22
- data/lib/tinkerforge/bricklet_linear_poti.rb +53 -35
- data/lib/tinkerforge/bricklet_linear_poti_v2.rb +55 -24
- data/lib/tinkerforge/bricklet_load_cell.rb +64 -40
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +81 -41
- data/lib/tinkerforge/bricklet_moisture.rb +43 -30
- data/lib/tinkerforge/bricklet_motion_detector.rb +21 -10
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +62 -29
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +71 -32
- data/lib/tinkerforge/bricklet_multi_touch.rb +30 -17
- data/lib/tinkerforge/bricklet_multi_touch_v2.rb +371 -0
- data/lib/tinkerforge/bricklet_nfc.rb +130 -80
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +32 -13
- data/lib/tinkerforge/bricklet_oled_128x64.rb +30 -17
- data/lib/tinkerforge/bricklet_oled_128x64_v2.rb +97 -40
- data/lib/tinkerforge/bricklet_oled_64x48.rb +30 -17
- data/lib/tinkerforge/bricklet_one_wire.rb +65 -24
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +84 -41
- data/lib/tinkerforge/bricklet_particulate_matter.rb +85 -37
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +19 -13
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +22 -19
- data/lib/tinkerforge/bricklet_piezo_speaker_v2.rb +84 -57
- data/lib/tinkerforge/bricklet_ptc.rb +76 -51
- data/lib/tinkerforge/bricklet_ptc_v2.rb +96 -54
- data/lib/tinkerforge/bricklet_real_time_clock.rb +45 -36
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +78 -47
- data/lib/tinkerforge/bricklet_remote_switch.rb +38 -29
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +86 -49
- data/lib/tinkerforge/bricklet_rgb_led.rb +17 -8
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +61 -30
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +78 -33
- data/lib/tinkerforge/bricklet_rgb_led_v2.rb +51 -20
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +40 -25
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +60 -27
- data/lib/tinkerforge/bricklet_rotary_poti.rb +55 -37
- data/lib/tinkerforge/bricklet_rotary_poti_v2.rb +290 -0
- data/lib/tinkerforge/bricklet_rs232.rb +89 -28
- data/lib/tinkerforge/bricklet_rs232_v2.rb +121 -47
- data/lib/tinkerforge/bricklet_rs485.rb +303 -207
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +24 -14
- data/lib/tinkerforge/bricklet_segment_display_4x7_v2.rb +75 -36
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +24 -13
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +58 -25
- data/lib/tinkerforge/bricklet_sound_intensity.rb +36 -24
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +77 -41
- data/lib/tinkerforge/bricklet_temperature.rb +43 -28
- data/lib/tinkerforge/bricklet_temperature_ir.rb +63 -47
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +75 -53
- data/lib/tinkerforge/bricklet_temperature_v2.rb +62 -31
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +118 -68
- data/lib/tinkerforge/bricklet_thermocouple.rb +46 -30
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +65 -30
- data/lib/tinkerforge/bricklet_tilt.rb +23 -10
- data/lib/tinkerforge/bricklet_uv_light.rb +37 -24
- data/lib/tinkerforge/bricklet_uv_light_v2.rb +87 -46
- data/lib/tinkerforge/bricklet_voltage.rb +54 -37
- data/lib/tinkerforge/bricklet_voltage_current.rb +94 -85
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +103 -77
- data/lib/tinkerforge/bricklet_xmc1400_breakout.rb +410 -0
- data/lib/tinkerforge/device_display_names.rb +165 -0
- data/lib/tinkerforge/ip_connection.rb +155 -33
- data/lib/tinkerforge/version.rb +1 -1
- metadata +14 -4
|
@@ -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-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Communicates with RS232 devices
|
|
14
16
|
class BrickletRS232 < Device
|
|
@@ -28,6 +30,14 @@ module Tinkerforge
|
|
|
28
30
|
# .. versionadded:: 2.0.1$nbsp;(Plugin)
|
|
29
31
|
CALLBACK_ERROR = 9
|
|
30
32
|
|
|
33
|
+
# This callback is called if at least one frame of data is readable. The frame size is configured with BrickletRS232#set_frame_readable_callback_configuration.
|
|
34
|
+
# The frame count parameter is the number of frames that can be read.
|
|
35
|
+
# This callback is triggered only once until BrickletRS232#read or BrickletRS232#read_frame is called. This means, that if you have configured a frame size of X bytes,
|
|
36
|
+
# you can read exactly X bytes using the BrickletRS232#read_frame function, every time the callback triggers without checking the frame count parameter.
|
|
37
|
+
#
|
|
38
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
39
|
+
CALLBACK_FRAME_READABLE = 13
|
|
40
|
+
|
|
31
41
|
CALLBACK_READ_CALLBACK = 8 # :nodoc: for backward compatibility
|
|
32
42
|
CALLBACK_ERROR_CALLBACK = 9 # :nodoc: for backward compatibility
|
|
33
43
|
|
|
@@ -39,6 +49,9 @@ module Tinkerforge
|
|
|
39
49
|
FUNCTION_SET_CONFIGURATION = 6 # :nodoc:
|
|
40
50
|
FUNCTION_GET_CONFIGURATION = 7 # :nodoc:
|
|
41
51
|
FUNCTION_SET_BREAK_CONDITION = 10 # :nodoc:
|
|
52
|
+
FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION = 11 # :nodoc:
|
|
53
|
+
FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION = 12 # :nodoc:
|
|
54
|
+
FUNCTION_READ_FRAME = 14 # :nodoc:
|
|
42
55
|
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
43
56
|
|
|
44
57
|
BAUDRATE_300 = 0 # :nodoc:
|
|
@@ -76,9 +89,9 @@ module Tinkerforge
|
|
|
76
89
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
77
90
|
# the IP Connection <tt>ipcon</tt>.
|
|
78
91
|
def initialize(uid, ipcon)
|
|
79
|
-
super uid, ipcon
|
|
92
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
80
93
|
|
|
81
|
-
@api_version = [2, 0,
|
|
94
|
+
@api_version = [2, 0, 3]
|
|
82
95
|
|
|
83
96
|
@response_expected[FUNCTION_WRITE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
84
97
|
@response_expected[FUNCTION_READ] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -88,11 +101,16 @@ module Tinkerforge
|
|
|
88
101
|
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
89
102
|
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
90
103
|
@response_expected[FUNCTION_SET_BREAK_CONDITION] = RESPONSE_EXPECTED_FALSE
|
|
104
|
+
@response_expected[FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
|
|
105
|
+
@response_expected[FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
106
|
+
@response_expected[FUNCTION_READ_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
91
107
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
108
|
|
|
93
|
-
@callback_formats[CALLBACK_READ] = 'k60 C'
|
|
94
|
-
@callback_formats[CALLBACK_ERROR] = 'C'
|
|
109
|
+
@callback_formats[CALLBACK_READ] = [69, 'k60 C']
|
|
110
|
+
@callback_formats[CALLBACK_ERROR] = [9, 'C']
|
|
111
|
+
@callback_formats[CALLBACK_FRAME_READABLE] = [9, 'C']
|
|
95
112
|
|
|
113
|
+
@ipcon.add_device self
|
|
96
114
|
end
|
|
97
115
|
|
|
98
116
|
# Writes a string of up to 60 characters to the RS232 interface. The string
|
|
@@ -105,75 +123,118 @@ module Tinkerforge
|
|
|
105
123
|
# See BrickletRS232#set_configuration for configuration possibilities
|
|
106
124
|
# regarding baudrate, parity and so on.
|
|
107
125
|
def write(message, length)
|
|
108
|
-
|
|
126
|
+
check_validity
|
|
127
|
+
|
|
128
|
+
send_request FUNCTION_WRITE, [message, length], 'k60 C', 9, 'C'
|
|
109
129
|
end
|
|
110
130
|
|
|
111
131
|
# Returns the currently buffered message. The maximum length
|
|
112
|
-
# of message is 60. If the length is
|
|
113
|
-
# new data available.
|
|
132
|
+
# of message is 60. If the returned length is 0, no new data was available.
|
|
114
133
|
#
|
|
115
134
|
# Instead of polling with this function, you can also use
|
|
116
135
|
# callbacks. See BrickletRS232#enable_read_callback and CALLBACK_READ callback.
|
|
117
136
|
def read
|
|
118
|
-
|
|
137
|
+
check_validity
|
|
138
|
+
|
|
139
|
+
send_request FUNCTION_READ, [], '', 69, 'k60 C'
|
|
119
140
|
end
|
|
120
141
|
|
|
121
|
-
# Enables the CALLBACK_READ callback.
|
|
142
|
+
# Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
|
|
122
143
|
#
|
|
123
144
|
# By default the callback is disabled.
|
|
124
145
|
def enable_read_callback
|
|
125
|
-
|
|
146
|
+
check_validity
|
|
147
|
+
|
|
148
|
+
send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
|
|
126
149
|
end
|
|
127
150
|
|
|
128
151
|
# Disables the CALLBACK_READ callback.
|
|
129
152
|
#
|
|
130
153
|
# By default the callback is disabled.
|
|
131
154
|
def disable_read_callback
|
|
132
|
-
|
|
155
|
+
check_validity
|
|
156
|
+
|
|
157
|
+
send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
|
|
133
158
|
end
|
|
134
159
|
|
|
135
160
|
# Returns *true* if the CALLBACK_READ callback is enabled,
|
|
136
161
|
# *false* otherwise.
|
|
137
162
|
def is_read_callback_enabled
|
|
138
|
-
|
|
163
|
+
check_validity
|
|
164
|
+
|
|
165
|
+
send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
|
|
139
166
|
end
|
|
140
167
|
|
|
141
|
-
# Sets the configuration for the RS232 communication.
|
|
142
|
-
#
|
|
143
|
-
# * Baudrate between 300 and 230400 baud.
|
|
144
|
-
# * Parity of none, odd, even or forced parity.
|
|
145
|
-
# * Stopbits can be 1 or 2.
|
|
146
|
-
# * Word length of 5 to 8.
|
|
147
|
-
# * Hard-/Software flow control can either be on or off but not both simultaneously on.
|
|
168
|
+
# Sets the configuration for the RS232 communication.
|
|
148
169
|
#
|
|
149
|
-
#
|
|
170
|
+
# Hard-/Software flow control can either be on or off but not both simultaneously on.
|
|
150
171
|
def set_configuration(baudrate, parity, stopbits, wordlength, hardware_flowcontrol, software_flowcontrol)
|
|
151
|
-
|
|
172
|
+
check_validity
|
|
173
|
+
|
|
174
|
+
send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, hardware_flowcontrol, software_flowcontrol], 'C C C C C C', 8, ''
|
|
152
175
|
end
|
|
153
176
|
|
|
154
177
|
# Returns the configuration as set by BrickletRS232#set_configuration.
|
|
155
178
|
def get_configuration
|
|
156
|
-
|
|
179
|
+
check_validity
|
|
180
|
+
|
|
181
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 14, 'C C C C C C'
|
|
157
182
|
end
|
|
158
183
|
|
|
159
184
|
# Sets a break condition (the TX output is forced to a logic 0 state).
|
|
160
|
-
# The parameter sets the hold-time of the break condition
|
|
185
|
+
# The parameter sets the hold-time of the break condition.
|
|
161
186
|
#
|
|
162
187
|
# .. versionadded:: 2.0.2$nbsp;(Plugin)
|
|
163
188
|
def set_break_condition(break_time)
|
|
164
|
-
|
|
189
|
+
check_validity
|
|
190
|
+
|
|
191
|
+
send_request FUNCTION_SET_BREAK_CONDITION, [break_time], 'S', 8, ''
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
# Configures the CALLBACK_FRAME_READABLE callback. The frame size is the number of bytes, that have to be readable to trigger the callback.
|
|
195
|
+
# A frame size of 0 disables the callback. A frame size greater than 0 enables the callback and disables the CALLBACK_READ callback.
|
|
196
|
+
#
|
|
197
|
+
# By default the callback is disabled.
|
|
198
|
+
#
|
|
199
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
200
|
+
def set_frame_readable_callback_configuration(frame_size)
|
|
201
|
+
check_validity
|
|
202
|
+
|
|
203
|
+
send_request FUNCTION_SET_FRAME_READABLE_CALLBACK_CONFIGURATION, [frame_size], 'C', 8, ''
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# Returns the callback configuration as set by BrickletRS232#set_frame_readable_callback_configuration.
|
|
207
|
+
#
|
|
208
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
209
|
+
def get_frame_readable_callback_configuration
|
|
210
|
+
check_validity
|
|
211
|
+
|
|
212
|
+
send_request FUNCTION_GET_FRAME_READABLE_CALLBACK_CONFIGURATION, [], '', 9, 'C'
|
|
213
|
+
end
|
|
214
|
+
|
|
215
|
+
# Returns up to one frame of bytes from the read buffer.
|
|
216
|
+
# The frame size is configured with BrickletRS232#set_frame_readable_callback_configuration.
|
|
217
|
+
# If the returned length is 0, no new data was available.
|
|
218
|
+
#
|
|
219
|
+
# .. versionadded:: 2.0.4$nbsp;(Plugin)
|
|
220
|
+
def read_frame
|
|
221
|
+
check_validity
|
|
222
|
+
|
|
223
|
+
send_request FUNCTION_READ_FRAME, [], '', 69, 'k60 C'
|
|
165
224
|
end
|
|
166
225
|
|
|
167
226
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
168
227
|
# the position, the hardware and firmware version as well as the
|
|
169
228
|
# device identifier.
|
|
170
229
|
#
|
|
171
|
-
# The position can be 'a', 'b', 'c' or '
|
|
230
|
+
# The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port).
|
|
231
|
+
# A Bricklet connected to an :ref:`Isolator Bricklet <isolator_bricklet>` is always at
|
|
232
|
+
# position 'z'.
|
|
172
233
|
#
|
|
173
234
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
174
235
|
# |device_identifier_constant|
|
|
175
236
|
def get_identity
|
|
176
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
237
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
177
238
|
end
|
|
178
239
|
|
|
179
240
|
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
@@ -1,32 +1,43 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on
|
|
3
|
+
# This file was automatically generated on 2020-11-02. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.27 #
|
|
6
6
|
# #
|
|
7
7
|
# If you have a bugfix for this file and want to commit it, #
|
|
8
8
|
# please fix the bug in the generator. You can find a link #
|
|
9
9
|
# to the generators git repository on tinkerforge.com #
|
|
10
10
|
#############################################################
|
|
11
11
|
|
|
12
|
+
require_relative './ip_connection'
|
|
13
|
+
|
|
12
14
|
module Tinkerforge
|
|
13
15
|
# Communicates with RS232 devices
|
|
14
16
|
class BrickletRS232V2 < Device
|
|
15
17
|
DEVICE_IDENTIFIER = 2108 # :nodoc:
|
|
16
18
|
DEVICE_DISPLAY_NAME = 'RS232 Bricklet 2.0' # :nodoc:
|
|
17
19
|
|
|
18
|
-
#
|
|
19
|
-
#
|
|
20
|
-
# To enable this callback, use BrickletRS232V2#enable_read_callback.
|
|
20
|
+
# See CALLBACK_READ
|
|
21
21
|
CALLBACK_READ_LOW_LEVEL = 12
|
|
22
22
|
|
|
23
23
|
# This callback is called if a new error occurs. It returns
|
|
24
24
|
# the current overrun and parity error count.
|
|
25
25
|
CALLBACK_ERROR_COUNT = 13
|
|
26
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
|
+
|
|
27
35
|
# This callback is called if new data is available.
|
|
28
36
|
#
|
|
29
37
|
# To enable this callback, use BrickletRS232V2#enable_read_callback.
|
|
38
|
+
#
|
|
39
|
+
# .. note::
|
|
40
|
+
# If reconstructing the value fails, the callback is triggered with nil for message.
|
|
30
41
|
CALLBACK_READ = -12
|
|
31
42
|
|
|
32
43
|
FUNCTION_WRITE_LOW_LEVEL = 1 # :nodoc:
|
|
@@ -40,6 +51,8 @@ module Tinkerforge
|
|
|
40
51
|
FUNCTION_GET_BUFFER_CONFIG = 9 # :nodoc:
|
|
41
52
|
FUNCTION_GET_BUFFER_STATUS = 10 # :nodoc:
|
|
42
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:
|
|
43
56
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
44
57
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
45
58
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
@@ -84,9 +97,9 @@ module Tinkerforge
|
|
|
84
97
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
98
|
# the IP Connection <tt>ipcon</tt>.
|
|
86
99
|
def initialize(uid, ipcon)
|
|
87
|
-
super uid, ipcon
|
|
100
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
|
88
101
|
|
|
89
|
-
@api_version = [2, 0,
|
|
102
|
+
@api_version = [2, 0, 1]
|
|
90
103
|
|
|
91
104
|
@response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
105
|
@response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -99,6 +112,8 @@ module Tinkerforge
|
|
|
99
112
|
@response_expected[FUNCTION_GET_BUFFER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
100
113
|
@response_expected[FUNCTION_GET_BUFFER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
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
|
|
102
117
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
118
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
119
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
@@ -112,10 +127,12 @@ module Tinkerforge
|
|
|
112
127
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
128
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
129
|
|
|
115
|
-
@callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
|
|
116
|
-
@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']
|
|
117
133
|
|
|
118
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
|
|
119
136
|
end
|
|
120
137
|
|
|
121
138
|
# Writes characters to the RS232 interface. The characters can be binary data,
|
|
@@ -126,7 +143,9 @@ module Tinkerforge
|
|
|
126
143
|
# See BrickletRS232V2#set_configuration for configuration possibilities
|
|
127
144
|
# regarding baud rate, parity and so on.
|
|
128
145
|
def write_low_level(message_length, message_chunk_offset, message_chunk_data)
|
|
129
|
-
|
|
146
|
+
check_validity
|
|
147
|
+
|
|
148
|
+
send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 9, 'C'
|
|
130
149
|
end
|
|
131
150
|
|
|
132
151
|
# Returns up to *length* characters from receive buffer.
|
|
@@ -136,49 +155,53 @@ module Tinkerforge
|
|
|
136
155
|
# data only when the read callback is disabled.
|
|
137
156
|
# See BrickletRS232V2#enable_read_callback and CALLBACK_READ callback.
|
|
138
157
|
def read_low_level(length)
|
|
139
|
-
|
|
158
|
+
check_validity
|
|
159
|
+
|
|
160
|
+
send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 72, 'S S k60'
|
|
140
161
|
end
|
|
141
162
|
|
|
142
|
-
# Enables the CALLBACK_READ callback.
|
|
163
|
+
# Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
|
|
143
164
|
#
|
|
144
165
|
# By default the callback is disabled.
|
|
145
166
|
def enable_read_callback
|
|
146
|
-
|
|
167
|
+
check_validity
|
|
168
|
+
|
|
169
|
+
send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
|
|
147
170
|
end
|
|
148
171
|
|
|
149
172
|
# Disables the CALLBACK_READ callback.
|
|
150
173
|
#
|
|
151
174
|
# By default the callback is disabled.
|
|
152
175
|
def disable_read_callback
|
|
153
|
-
|
|
176
|
+
check_validity
|
|
177
|
+
|
|
178
|
+
send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
|
|
154
179
|
end
|
|
155
180
|
|
|
156
181
|
# Returns *true* if the CALLBACK_READ callback is enabled,
|
|
157
182
|
# *false* otherwise.
|
|
158
183
|
def is_read_callback_enabled
|
|
159
|
-
|
|
184
|
+
check_validity
|
|
185
|
+
|
|
186
|
+
send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
|
|
160
187
|
end
|
|
161
188
|
|
|
162
|
-
# Sets the configuration for the RS232 communication.
|
|
163
|
-
#
|
|
164
|
-
# * Baud rate between 100 and 2000000 baud.
|
|
165
|
-
# * Parity of none, odd or even.
|
|
166
|
-
# * Stop bits can be 1 or 2.
|
|
167
|
-
# * Word length of 5 to 8.
|
|
168
|
-
# * Flow control can be off, software or hardware.
|
|
169
|
-
#
|
|
170
|
-
# The default is: 115200 baud, parity none, 1 stop bit, word length 8.
|
|
189
|
+
# Sets the configuration for the RS232 communication.
|
|
171
190
|
def set_configuration(baudrate, parity, stopbits, wordlength, flowcontrol)
|
|
172
|
-
|
|
191
|
+
check_validity
|
|
192
|
+
|
|
193
|
+
send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, flowcontrol], 'L C C C C', 8, ''
|
|
173
194
|
end
|
|
174
195
|
|
|
175
196
|
# Returns the configuration as set by BrickletRS232V2#set_configuration.
|
|
176
197
|
def get_configuration
|
|
177
|
-
|
|
198
|
+
check_validity
|
|
199
|
+
|
|
200
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 16, 'L C C C C'
|
|
178
201
|
end
|
|
179
202
|
|
|
180
203
|
# Sets the send and receive buffer size in byte. In total the buffers have to be
|
|
181
|
-
# 10240 byte (
|
|
204
|
+
# 10240 byte (10KiB) in size, the minimum buffer size is 1024 byte (1KiB) for each.
|
|
182
205
|
#
|
|
183
206
|
# The current buffer content is lost if this function is called.
|
|
184
207
|
#
|
|
@@ -186,27 +209,54 @@ module Tinkerforge
|
|
|
186
209
|
# can not be written yet. The receive buffer holds data that is
|
|
187
210
|
# received through RS232 but could not yet be send to the
|
|
188
211
|
# user, either by BrickletRS232V2#read or through CALLBACK_READ callback.
|
|
189
|
-
#
|
|
190
|
-
# The default configuration is 5120 byte (5kb) per buffer.
|
|
191
212
|
def set_buffer_config(send_buffer_size, receive_buffer_size)
|
|
192
|
-
|
|
213
|
+
check_validity
|
|
214
|
+
|
|
215
|
+
send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 8, ''
|
|
193
216
|
end
|
|
194
217
|
|
|
195
218
|
# Returns the buffer configuration as set by BrickletRS232V2#set_buffer_config.
|
|
196
219
|
def get_buffer_config
|
|
197
|
-
|
|
220
|
+
check_validity
|
|
221
|
+
|
|
222
|
+
send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 12, 'S S'
|
|
198
223
|
end
|
|
199
224
|
|
|
200
225
|
# Returns the currently used bytes for the send and received buffer.
|
|
201
226
|
#
|
|
202
227
|
# See BrickletRS232V2#set_buffer_config for buffer size configuration.
|
|
203
228
|
def get_buffer_status
|
|
204
|
-
|
|
229
|
+
check_validity
|
|
230
|
+
|
|
231
|
+
send_request FUNCTION_GET_BUFFER_STATUS, [], '', 12, 'S S'
|
|
205
232
|
end
|
|
206
233
|
|
|
207
234
|
# Returns the current number of overrun and parity errors.
|
|
208
235
|
def get_error_count
|
|
209
|
-
|
|
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'
|
|
210
260
|
end
|
|
211
261
|
|
|
212
262
|
# Returns the error count for the communication between Brick and Bricklet.
|
|
@@ -221,7 +271,9 @@ module Tinkerforge
|
|
|
221
271
|
# The errors counts are for errors that occur on the Bricklet side. All
|
|
222
272
|
# Bricks have a similar function that returns the errors on the Brick side.
|
|
223
273
|
def get_spitfp_error_count
|
|
224
|
-
|
|
274
|
+
check_validity
|
|
275
|
+
|
|
276
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
|
225
277
|
end
|
|
226
278
|
|
|
227
279
|
# Sets the bootloader mode and returns the status after the requested
|
|
@@ -234,12 +286,16 @@ module Tinkerforge
|
|
|
234
286
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
235
287
|
# necessary to call it in a normal user program.
|
|
236
288
|
def set_bootloader_mode(mode)
|
|
237
|
-
|
|
289
|
+
check_validity
|
|
290
|
+
|
|
291
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
|
238
292
|
end
|
|
239
293
|
|
|
240
294
|
# Returns the current bootloader mode, see BrickletRS232V2#set_bootloader_mode.
|
|
241
295
|
def get_bootloader_mode
|
|
242
|
-
|
|
296
|
+
check_validity
|
|
297
|
+
|
|
298
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
|
243
299
|
end
|
|
244
300
|
|
|
245
301
|
# Sets the firmware pointer for BrickletRS232V2#write_firmware. The pointer has
|
|
@@ -249,7 +305,9 @@ module Tinkerforge
|
|
|
249
305
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
250
306
|
# necessary to call it in a normal user program.
|
|
251
307
|
def set_write_firmware_pointer(pointer)
|
|
252
|
-
|
|
308
|
+
check_validity
|
|
309
|
+
|
|
310
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
|
253
311
|
end
|
|
254
312
|
|
|
255
313
|
# Writes 64 Bytes of firmware at the position as written by
|
|
@@ -261,7 +319,9 @@ module Tinkerforge
|
|
|
261
319
|
# This function is used by Brick Viewer during flashing. It should not be
|
|
262
320
|
# necessary to call it in a normal user program.
|
|
263
321
|
def write_firmware(data)
|
|
264
|
-
|
|
322
|
+
check_validity
|
|
323
|
+
|
|
324
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
|
265
325
|
end
|
|
266
326
|
|
|
267
327
|
# Sets the status LED configuration. By default the LED shows
|
|
@@ -272,22 +332,28 @@ module Tinkerforge
|
|
|
272
332
|
#
|
|
273
333
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
274
334
|
def set_status_led_config(config)
|
|
275
|
-
|
|
335
|
+
check_validity
|
|
336
|
+
|
|
337
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
|
276
338
|
end
|
|
277
339
|
|
|
278
340
|
# Returns the configuration as set by BrickletRS232V2#set_status_led_config
|
|
279
341
|
def get_status_led_config
|
|
280
|
-
|
|
342
|
+
check_validity
|
|
343
|
+
|
|
344
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
|
281
345
|
end
|
|
282
346
|
|
|
283
|
-
# Returns the temperature
|
|
347
|
+
# Returns the temperature as measured inside the microcontroller. The
|
|
284
348
|
# value returned is not the ambient temperature!
|
|
285
349
|
#
|
|
286
350
|
# The temperature is only proportional to the real temperature and it has bad
|
|
287
351
|
# accuracy. Practically it is only useful as an indicator for
|
|
288
352
|
# temperature changes.
|
|
289
353
|
def get_chip_temperature
|
|
290
|
-
|
|
354
|
+
check_validity
|
|
355
|
+
|
|
356
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
|
291
357
|
end
|
|
292
358
|
|
|
293
359
|
# Calling this function will reset the Bricklet. All configurations
|
|
@@ -297,7 +363,9 @@ module Tinkerforge
|
|
|
297
363
|
# calling functions on the existing ones will result in
|
|
298
364
|
# undefined behavior!
|
|
299
365
|
def reset
|
|
300
|
-
|
|
366
|
+
check_validity
|
|
367
|
+
|
|
368
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
|
301
369
|
end
|
|
302
370
|
|
|
303
371
|
# Writes a new UID into flash. If you want to set a new UID
|
|
@@ -306,25 +374,31 @@ module Tinkerforge
|
|
|
306
374
|
#
|
|
307
375
|
# We recommend that you use Brick Viewer to change the UID.
|
|
308
376
|
def write_uid(uid)
|
|
309
|
-
|
|
377
|
+
check_validity
|
|
378
|
+
|
|
379
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
|
310
380
|
end
|
|
311
381
|
|
|
312
382
|
# Returns the current UID as an integer. Encode as
|
|
313
383
|
# Base58 to get the usual string version.
|
|
314
384
|
def read_uid
|
|
315
|
-
|
|
385
|
+
check_validity
|
|
386
|
+
|
|
387
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
|
316
388
|
end
|
|
317
389
|
|
|
318
390
|
# Returns the UID, the UID where the Bricklet is connected to,
|
|
319
391
|
# the position, the hardware and firmware version as well as the
|
|
320
392
|
# device identifier.
|
|
321
393
|
#
|
|
322
|
-
# The position can be 'a', 'b', 'c' or '
|
|
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'.
|
|
323
397
|
#
|
|
324
398
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
325
399
|
# |device_identifier_constant|
|
|
326
400
|
def get_identity
|
|
327
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
|
401
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
|
328
402
|
end
|
|
329
403
|
|
|
330
404
|
# Writes characters to the RS232 interface. The characters can be binary data,
|