tinkerforge 2.1.22 → 2.1.27
Sign up to get free protection for your applications and to get access to all the features.
- 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,23 +1,23 @@
|
|
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 RS485/Modbus devices with full- or half-duplex
|
14
16
|
class BrickletRS485 < Device
|
15
17
|
DEVICE_IDENTIFIER = 277 # :nodoc:
|
16
18
|
DEVICE_DISPLAY_NAME = 'RS485 Bricklet' # :nodoc:
|
17
19
|
|
18
|
-
#
|
19
|
-
#
|
20
|
-
# To enable this callback, use BrickletRS485#enable_read_callback.
|
20
|
+
# See CALLBACK_READ
|
21
21
|
CALLBACK_READ_LOW_LEVEL = 41
|
22
22
|
|
23
23
|
# This callback is called if a new error occurs. It returns
|
@@ -26,54 +26,33 @@ module Tinkerforge
|
|
26
26
|
|
27
27
|
# This callback is called only in Modbus slave mode when the slave receives a
|
28
28
|
# valid request from a Modbus master to read coils. The parameters are
|
29
|
-
# request ID of the request, the
|
30
|
-
# be read as received by the request.
|
29
|
+
# request ID of the request, the number of the first coil to be read and the number of coils to
|
30
|
+
# be read as received by the request. The number of the first coil is called starting address for backwards compatibility reasons.
|
31
|
+
# It is not an address, but instead a coil number in the range of 1 to 65536.
|
31
32
|
#
|
32
33
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_read_coils_request.
|
33
34
|
CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST = 43
|
34
35
|
|
35
|
-
#
|
36
|
-
# valid response of a request to read coils.
|
37
|
-
#
|
38
|
-
# The parameters are request ID
|
39
|
-
# of the request, exception code of the response and the data as received by the
|
40
|
-
# response.
|
41
|
-
#
|
42
|
-
# Any non-zero exception code indicates a problem. If the exception code
|
43
|
-
# is greater than zero then the number represents a Modbus exception code. If it is
|
44
|
-
# less than zero then it represents other errors. For example, -1 indicates that
|
45
|
-
# the request timed out or that the master did not receive any valid response of the
|
46
|
-
# request within the master request timeout period as set by
|
47
|
-
# BrickletRS485#set_modbus_configuration.
|
36
|
+
# See CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE
|
48
37
|
CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL = 44
|
49
38
|
|
50
39
|
# This callback is called only in Modbus slave mode when the slave receives a
|
51
40
|
# valid request from a Modbus master to read holding registers. The parameters
|
52
|
-
# are request ID of the request, the
|
53
|
-
# registers to be read as received by the request.
|
41
|
+
# are request ID of the request, the number of the first holding register to be read and the number of holding
|
42
|
+
# registers to be read as received by the request. The number of the first holding register is called starting address for backwards compatibility reasons.
|
43
|
+
# It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is omitted.
|
54
44
|
#
|
55
45
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_read_holding_registers_request.
|
56
46
|
CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST = 45
|
57
47
|
|
58
|
-
#
|
59
|
-
# valid response of a request to read holding registers.
|
60
|
-
#
|
61
|
-
# The parameters are
|
62
|
-
# request ID of the request, exception code of the response and the data as received
|
63
|
-
# by the response.
|
64
|
-
#
|
65
|
-
# Any non-zero exception code indicates a problem. If the exception
|
66
|
-
# code is greater than zero then the number represents a Modbus exception code. If
|
67
|
-
# it is less than zero then it represents other errors. For example, -1 indicates that
|
68
|
-
# the request timed out or that the master did not receive any valid response of the
|
69
|
-
# request within the master request timeout period as set by
|
70
|
-
# BrickletRS485#set_modbus_configuration.
|
48
|
+
# See CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE
|
71
49
|
CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL = 46
|
72
50
|
|
73
51
|
# This callback is called only in Modbus slave mode when the slave receives a
|
74
52
|
# valid request from a Modbus master to write a single coil. The parameters
|
75
|
-
# are request ID of the request, the coil
|
76
|
-
# written as received by the request.
|
53
|
+
# are request ID of the request, the number of the coil and the value of coil to be
|
54
|
+
# written as received by the request. The number of the coil is called coil address for backwards compatibility reasons.
|
55
|
+
# It is not an address, but instead a coil number in the range of 1 to 65536.
|
77
56
|
#
|
78
57
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_single_coil_request.
|
79
58
|
CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST = 47
|
@@ -85,17 +64,18 @@ module Tinkerforge
|
|
85
64
|
# request ID of the request and exception code of the response.
|
86
65
|
#
|
87
66
|
# Any non-zero exception code indicates a problem.
|
88
|
-
# If the exception code is greater than
|
89
|
-
# exception code. If it is less than
|
67
|
+
# If the exception code is greater than 0 then the number represents a Modbus
|
68
|
+
# exception code. If it is less than 0 then it represents other errors. For
|
90
69
|
# example, -1 indicates that the request timed out or that the master did not receive
|
91
70
|
# any valid response of the request within the master request timeout period as set
|
92
71
|
# by BrickletRS485#set_modbus_configuration.
|
93
72
|
CALLBACK_MODBUS_MASTER_WRITE_SINGLE_COIL_RESPONSE = 48
|
94
73
|
|
95
74
|
# This callback is called only in Modbus slave mode when the slave receives a
|
96
|
-
# valid request from a Modbus master to write a single register. The parameters
|
97
|
-
# are request ID of the request, the register
|
98
|
-
# be written as received by the request.
|
75
|
+
# valid request from a Modbus master to write a single holding register. The parameters
|
76
|
+
# are request ID of the request, the number of the holding register and the register value to
|
77
|
+
# be written as received by the request. The number of the holding register is called starting address for backwards compatibility reasons.
|
78
|
+
# It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is omitted.
|
99
79
|
#
|
100
80
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_single_register_request.
|
101
81
|
CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_REGISTER_REQUEST = 49
|
@@ -107,19 +87,14 @@ module Tinkerforge
|
|
107
87
|
# request ID of the request and exception code of the response.
|
108
88
|
#
|
109
89
|
# Any non-zero exception code
|
110
|
-
# indicates a problem. If the exception code is greater than
|
111
|
-
# represents a Modbus exception code. If it is less than
|
90
|
+
# indicates a problem. If the exception code is greater than 0 then the number
|
91
|
+
# represents a Modbus exception code. If it is less than 0 then it represents
|
112
92
|
# other errors. For example, -1 indicates that the request timed out or that the
|
113
93
|
# master did not receive any valid response of the request within the master request
|
114
94
|
# timeout period as set by BrickletRS485#set_modbus_configuration.
|
115
95
|
CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE = 50
|
116
96
|
|
117
|
-
#
|
118
|
-
# valid request from a Modbus master to write multiple coils. The parameters
|
119
|
-
# are request ID of the request, the starting address and the data to be written as
|
120
|
-
# received by the request.
|
121
|
-
#
|
122
|
-
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_coils_request.
|
97
|
+
# See CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST
|
123
98
|
CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL = 51
|
124
99
|
|
125
100
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -129,19 +104,14 @@ module Tinkerforge
|
|
129
104
|
# request ID of the request and exception code of the response.
|
130
105
|
#
|
131
106
|
# Any non-zero exception code
|
132
|
-
# indicates a problem. If the exception code is greater than
|
133
|
-
# represents a Modbus exception code. If it is less than
|
107
|
+
# indicates a problem. If the exception code is greater than 0 then the number
|
108
|
+
# represents a Modbus exception code. If it is less than 0 then it represents
|
134
109
|
# other errors. For example, -1 indicates that the request timedout or that the
|
135
110
|
# master did not receive any valid response of the request within the master request
|
136
111
|
# timeout period as set by BrickletRS485#set_modbus_configuration.
|
137
112
|
CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE = 52
|
138
113
|
|
139
|
-
#
|
140
|
-
# valid request from a Modbus master to write multiple registers. The parameters
|
141
|
-
# are request ID of the request, the starting address and the data to be written as
|
142
|
-
# received by the request.
|
143
|
-
#
|
144
|
-
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_registers_request.
|
114
|
+
# See CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST
|
145
115
|
CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL = 53
|
146
116
|
|
147
117
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -151,8 +121,8 @@ module Tinkerforge
|
|
151
121
|
# are request ID of the request and exception code of the response.
|
152
122
|
#
|
153
123
|
# Any non-zero
|
154
|
-
# exception code indicates a problem. If the exception code is greater than
|
155
|
-
# the number represents a Modbus exception code. If it is less than
|
124
|
+
# exception code indicates a problem. If the exception code is greater than 0 then
|
125
|
+
# the number represents a Modbus exception code. If it is less than 0 then it
|
156
126
|
# represents other errors. For example, -1 indicates that the request timedout or
|
157
127
|
# that the master did not receive any valid response of the request within the master
|
158
128
|
# request timeout period as set by BrickletRS485#set_modbus_configuration.
|
@@ -160,53 +130,42 @@ module Tinkerforge
|
|
160
130
|
|
161
131
|
# This callback is called only in Modbus slave mode when the slave receives a
|
162
132
|
# valid request from a Modbus master to read discrete inputs. The parameters
|
163
|
-
# are request ID of the request, the
|
164
|
-
# inputs to be read as received by the request.
|
133
|
+
# are request ID of the request, the number of the first discrete input and the number of discrete
|
134
|
+
# inputs to be read as received by the request. The number of the first discrete input is called starting address for backwards compatibility reasons.
|
135
|
+
# It is not an address, but instead a discrete input number in the range of 1 to 65536. The prefix digit 1 (for discrete input) is omitted.
|
165
136
|
#
|
166
137
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_read_discrete_inputs_request.
|
167
138
|
CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST = 55
|
168
139
|
|
169
|
-
#
|
170
|
-
# valid response of a request to read discrete inputs.
|
171
|
-
#
|
172
|
-
# The parameters are
|
173
|
-
# request ID of the request, exception code of the response and the data as received
|
174
|
-
# by the response.
|
175
|
-
#
|
176
|
-
# Any non-zero exception code indicates a problem. If the exception
|
177
|
-
# code is greater than zero then the number represents a Modbus exception code. If
|
178
|
-
# it is less than zero then it represents other errors. For example, -1 indicates that
|
179
|
-
# the request timedout or that the master did not receive any valid response of the
|
180
|
-
# request within the master request timeout period as set by
|
181
|
-
# BrickletRS485#set_modbus_configuration.
|
140
|
+
# See CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE
|
182
141
|
CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL = 56
|
183
142
|
|
184
143
|
# This callback is called only in Modbus slave mode when the slave receives a
|
185
144
|
# valid request from a Modbus master to read input registers. The parameters
|
186
|
-
# are request ID of the request, the
|
187
|
-
# registers to be read as received by the request.
|
145
|
+
# are request ID of the request, the number of the first input register and the number of input
|
146
|
+
# registers to be read as received by the request. The number of the first input register is called starting address for backwards compatibility reasons.
|
147
|
+
# It is not an address, but instead a input register number in the range of 1 to 65536. The prefix digit 3 (for input register) is omitted.
|
188
148
|
#
|
189
149
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_read_input_registers_request.
|
190
150
|
CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST = 57
|
191
151
|
|
192
|
-
#
|
193
|
-
# valid response of a request to read input registers.
|
194
|
-
#
|
195
|
-
# The parameters are
|
196
|
-
# request ID of the request, exception code of the response and the data as received
|
197
|
-
# by the response.
|
198
|
-
#
|
199
|
-
# Any non-zero exception code indicates a problem. If the exception
|
200
|
-
# code is greater than zero then the number represents a Modbus exception code. If
|
201
|
-
# it is less than zero then it represents other errors. For example, -1 indicates that
|
202
|
-
# the request timedout or that the master did not receive any valid response of the
|
203
|
-
# request within the master request timeout period as set by
|
204
|
-
# BrickletRS485#set_modbus_configuration.
|
152
|
+
# See CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE
|
205
153
|
CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE_LOW_LEVEL = 58
|
206
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
|
+
|
207
163
|
# This callback is called if new data is available.
|
208
164
|
#
|
209
165
|
# To enable this callback, use BrickletRS485#enable_read_callback.
|
166
|
+
#
|
167
|
+
# .. note::
|
168
|
+
# If reconstructing the value fails, the callback is triggered with nil for message.
|
210
169
|
CALLBACK_READ = -41
|
211
170
|
|
212
171
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -217,11 +176,14 @@ module Tinkerforge
|
|
217
176
|
# response.
|
218
177
|
#
|
219
178
|
# Any non-zero exception code indicates a problem. If the exception code
|
220
|
-
# is greater than
|
221
|
-
# less than
|
179
|
+
# is greater than 0 then the number represents a Modbus exception code. If it is
|
180
|
+
# less than 0 then it represents other errors. For example, -1 indicates that
|
222
181
|
# the request timed out or that the master did not receive any valid response of the
|
223
182
|
# request within the master request timeout period as set by
|
224
183
|
# BrickletRS485#set_modbus_configuration.
|
184
|
+
#
|
185
|
+
# .. note::
|
186
|
+
# If reconstructing the value fails, the callback is triggered with nil for coils.
|
225
187
|
CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE = -44
|
226
188
|
|
227
189
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -232,27 +194,38 @@ module Tinkerforge
|
|
232
194
|
# by the response.
|
233
195
|
#
|
234
196
|
# Any non-zero exception code indicates a problem. If the exception
|
235
|
-
# code is greater than
|
236
|
-
# it is less than
|
197
|
+
# code is greater than 0 then the number represents a Modbus exception code. If
|
198
|
+
# it is less than 0 then it represents other errors. For example, -1 indicates that
|
237
199
|
# the request timed out or that the master did not receive any valid response of the
|
238
200
|
# request within the master request timeout period as set by
|
239
201
|
# BrickletRS485#set_modbus_configuration.
|
202
|
+
#
|
203
|
+
# .. note::
|
204
|
+
# If reconstructing the value fails, the callback is triggered with nil for holding_registers.
|
240
205
|
CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE = -46
|
241
206
|
|
242
207
|
# This callback is called only in Modbus slave mode when the slave receives a
|
243
208
|
# valid request from a Modbus master to write multiple coils. The parameters
|
244
|
-
# are request ID of the request, the
|
245
|
-
# received by the request.
|
209
|
+
# are request ID of the request, the number of the first coil and the data to be written as
|
210
|
+
# received by the request. The number of the first coil is called starting address for backwards compatibility reasons.
|
211
|
+
# It is not an address, but instead a coil number in the range of 1 to 65536.
|
246
212
|
#
|
247
213
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_coils_request.
|
214
|
+
#
|
215
|
+
# .. note::
|
216
|
+
# If reconstructing the value fails, the callback is triggered with nil for coils.
|
248
217
|
CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST = -51
|
249
218
|
|
250
219
|
# This callback is called only in Modbus slave mode when the slave receives a
|
251
|
-
# valid request from a Modbus master to write multiple registers. The parameters
|
252
|
-
# are request ID of the request, the
|
253
|
-
# received by the request.
|
220
|
+
# valid request from a Modbus master to write multiple holding registers. The parameters
|
221
|
+
# are request ID of the request, the number of the first holding register and the data to be written as
|
222
|
+
# received by the request. The number of the first holding register is called starting address for backwards compatibility reasons.
|
223
|
+
# It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is omitted.
|
254
224
|
#
|
255
225
|
# To send a response of this request use BrickletRS485#modbus_slave_answer_write_multiple_registers_request.
|
226
|
+
#
|
227
|
+
# .. note::
|
228
|
+
# If reconstructing the value fails, the callback is triggered with nil for registers.
|
256
229
|
CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST = -53
|
257
230
|
|
258
231
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -263,11 +236,14 @@ module Tinkerforge
|
|
263
236
|
# by the response.
|
264
237
|
#
|
265
238
|
# Any non-zero exception code indicates a problem. If the exception
|
266
|
-
# code is greater than
|
267
|
-
# it is less than
|
239
|
+
# code is greater than 0 then the number represents a Modbus exception code. If
|
240
|
+
# it is less than 0 then it represents other errors. For example, -1 indicates that
|
268
241
|
# the request timedout or that the master did not receive any valid response of the
|
269
242
|
# request within the master request timeout period as set by
|
270
243
|
# BrickletRS485#set_modbus_configuration.
|
244
|
+
#
|
245
|
+
# .. note::
|
246
|
+
# If reconstructing the value fails, the callback is triggered with nil for discrete_inputs.
|
271
247
|
CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE = -56
|
272
248
|
|
273
249
|
# This callback is called only in Modbus master mode when the master receives a
|
@@ -278,11 +254,14 @@ module Tinkerforge
|
|
278
254
|
# by the response.
|
279
255
|
#
|
280
256
|
# Any non-zero exception code indicates a problem. If the exception
|
281
|
-
# code is greater than
|
282
|
-
# it is less than
|
257
|
+
# code is greater than 0 then the number represents a Modbus exception code. If
|
258
|
+
# it is less than 0 then it represents other errors. For example, -1 indicates that
|
283
259
|
# the request timedout or that the master did not receive any valid response of the
|
284
260
|
# request within the master request timeout period as set by
|
285
261
|
# BrickletRS485#set_modbus_configuration.
|
262
|
+
#
|
263
|
+
# .. note::
|
264
|
+
# If reconstructing the value fails, the callback is triggered with nil for input_registers.
|
286
265
|
CALLBACK_MODBUS_MASTER_READ_INPUT_REGISTERS_RESPONSE = -58
|
287
266
|
|
288
267
|
FUNCTION_WRITE_LOW_LEVEL = 1 # :nodoc:
|
@@ -325,6 +304,8 @@ module Tinkerforge
|
|
325
304
|
FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS = 38 # :nodoc:
|
326
305
|
FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL = 39 # :nodoc:
|
327
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:
|
328
309
|
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
329
310
|
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
330
311
|
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
@@ -390,9 +371,9 @@ module Tinkerforge
|
|
390
371
|
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
391
372
|
# the IP Connection <tt>ipcon</tt>.
|
392
373
|
def initialize(uid, ipcon)
|
393
|
-
super uid, ipcon
|
374
|
+
super uid, ipcon, DEVICE_IDENTIFIER, DEVICE_DISPLAY_NAME
|
394
375
|
|
395
|
-
@api_version = [2, 0,
|
376
|
+
@api_version = [2, 0, 1]
|
396
377
|
|
397
378
|
@response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
398
379
|
@response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -434,6 +415,8 @@ module Tinkerforge
|
|
434
415
|
@response_expected[FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
435
416
|
@response_expected[FUNCTION_MODBUS_SLAVE_ANSWER_READ_INPUT_REGISTERS_REQUEST_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
|
436
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
|
437
420
|
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
438
421
|
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
439
422
|
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
@@ -447,24 +430,25 @@ module Tinkerforge
|
|
447
430
|
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
448
431
|
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
449
432
|
|
450
|
-
@callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
|
451
|
-
@callback_formats[CALLBACK_ERROR_COUNT] = 'L L'
|
452
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST] = 'C L S'
|
453
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_READ_COILS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
|
454
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST] = 'C L S'
|
455
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_READ_HOLDING_REGISTERS_RESPONSE_LOW_LEVEL] = 'C c S S S29'
|
456
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST] = 'C L ?'
|
457
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_COIL_RESPONSE] = 'C c'
|
458
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_REGISTER_REQUEST] = 'C L S'
|
459
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_WRITE_SINGLE_REGISTER_RESPONSE] = 'C c'
|
460
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST_LOW_LEVEL] = 'C L S S ?440'
|
461
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_COILS_RESPONSE] = 'C c'
|
462
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST_LOW_LEVEL] = 'C L S S S27'
|
463
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_WRITE_MULTIPLE_REGISTERS_RESPONSE] = 'C c'
|
464
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST] = 'C L S'
|
465
|
-
@callback_formats[CALLBACK_MODBUS_MASTER_READ_DISCRETE_INPUTS_RESPONSE_LOW_LEVEL] = 'C c S S ?464'
|
466
|
-
@callback_formats[CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST] = 'C L S'
|
467
|
-
@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']
|
468
452
|
|
469
453
|
@high_level_callbacks[CALLBACK_READ] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
|
470
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]
|
@@ -473,6 +457,7 @@ module Tinkerforge
|
|
473
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]
|
474
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]
|
475
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
|
476
461
|
end
|
477
462
|
|
478
463
|
# Writes characters to the RS485 interface. The characters can be binary data,
|
@@ -483,7 +468,9 @@ module Tinkerforge
|
|
483
468
|
# See BrickletRS485#set_rs485_configuration for configuration possibilities
|
484
469
|
# regarding baudrate, parity and so on.
|
485
470
|
def write_low_level(message_length, message_chunk_offset, message_chunk_data)
|
486
|
-
|
471
|
+
check_validity
|
472
|
+
|
473
|
+
send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 9, 'C'
|
487
474
|
end
|
488
475
|
|
489
476
|
# Returns up to *length* characters from receive buffer.
|
@@ -493,60 +480,66 @@ module Tinkerforge
|
|
493
480
|
# data only when the read callback is disabled.
|
494
481
|
# See BrickletRS485#enable_read_callback and CALLBACK_READ callback.
|
495
482
|
def read_low_level(length)
|
496
|
-
|
483
|
+
check_validity
|
484
|
+
|
485
|
+
send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 72, 'S S k60'
|
497
486
|
end
|
498
487
|
|
499
|
-
# Enables the CALLBACK_READ callback.
|
488
|
+
# Enables the CALLBACK_READ callback. This will disable the CALLBACK_FRAME_READABLE callback.
|
500
489
|
#
|
501
490
|
# By default the callback is disabled.
|
502
491
|
def enable_read_callback
|
503
|
-
|
492
|
+
check_validity
|
493
|
+
|
494
|
+
send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 8, ''
|
504
495
|
end
|
505
496
|
|
506
497
|
# Disables the CALLBACK_READ callback.
|
507
498
|
#
|
508
499
|
# By default the callback is disabled.
|
509
500
|
def disable_read_callback
|
510
|
-
|
501
|
+
check_validity
|
502
|
+
|
503
|
+
send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 8, ''
|
511
504
|
end
|
512
505
|
|
513
506
|
# Returns *true* if the CALLBACK_READ callback is enabled,
|
514
507
|
# *false* otherwise.
|
515
508
|
def is_read_callback_enabled
|
516
|
-
|
509
|
+
check_validity
|
510
|
+
|
511
|
+
send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 9, '?'
|
517
512
|
end
|
518
513
|
|
519
|
-
# Sets the configuration for the RS485 communication.
|
520
|
-
#
|
521
|
-
# * Baudrate between 100 and 2000000 baud.
|
522
|
-
# * Parity of none, odd or even.
|
523
|
-
# * Stopbits can be 1 or 2.
|
524
|
-
# * Word length of 5 to 8.
|
525
|
-
# * Half- or Full-Duplex.
|
526
|
-
#
|
527
|
-
# The default is: 115200 baud, parity none, 1 stop bit, word length 8, half duplex.
|
514
|
+
# Sets the configuration for the RS485 communication.
|
528
515
|
def set_rs485_configuration(baudrate, parity, stopbits, wordlength, duplex)
|
529
|
-
|
516
|
+
check_validity
|
517
|
+
|
518
|
+
send_request FUNCTION_SET_RS485_CONFIGURATION, [baudrate, parity, stopbits, wordlength, duplex], 'L C C C C', 8, ''
|
530
519
|
end
|
531
520
|
|
532
521
|
# Returns the configuration as set by BrickletRS485#set_rs485_configuration.
|
533
522
|
def get_rs485_configuration
|
534
|
-
|
523
|
+
check_validity
|
524
|
+
|
525
|
+
send_request FUNCTION_GET_RS485_CONFIGURATION, [], '', 16, 'L C C C C'
|
535
526
|
end
|
536
527
|
|
537
528
|
# Sets the configuration for the RS485 Modbus communication. Available options:
|
538
529
|
#
|
539
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.
|
540
|
-
# * Master Request Timeout: Specifies how long the master should wait for a response from a slave
|
541
|
-
#
|
542
|
-
# 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.
|
543
532
|
def set_modbus_configuration(slave_address, master_request_timeout)
|
544
|
-
|
533
|
+
check_validity
|
534
|
+
|
535
|
+
send_request FUNCTION_SET_MODBUS_CONFIGURATION, [slave_address, master_request_timeout], 'C L', 8, ''
|
545
536
|
end
|
546
537
|
|
547
538
|
# Returns the configuration as set by BrickletRS485#set_modbus_configuration.
|
548
539
|
def get_modbus_configuration
|
549
|
-
|
540
|
+
check_validity
|
541
|
+
|
542
|
+
send_request FUNCTION_GET_MODBUS_CONFIGURATION, [], '', 13, 'C L'
|
550
543
|
end
|
551
544
|
|
552
545
|
# Sets the mode of the Bricklet in which it operates. Available options are
|
@@ -554,15 +547,17 @@ module Tinkerforge
|
|
554
547
|
# * RS485,
|
555
548
|
# * Modbus Master RTU and
|
556
549
|
# * Modbus Slave RTU.
|
557
|
-
#
|
558
|
-
# The default is: RS485 mode.
|
559
550
|
def set_mode(mode)
|
560
|
-
|
551
|
+
check_validity
|
552
|
+
|
553
|
+
send_request FUNCTION_SET_MODE, [mode], 'C', 8, ''
|
561
554
|
end
|
562
555
|
|
563
556
|
# Returns the configuration as set by BrickletRS485#set_mode.
|
564
557
|
def get_mode
|
565
|
-
|
558
|
+
check_validity
|
559
|
+
|
560
|
+
send_request FUNCTION_GET_MODE, [], '', 9, 'C'
|
566
561
|
end
|
567
562
|
|
568
563
|
# Sets the communication LED configuration. By default the LED shows RS485
|
@@ -572,12 +567,16 @@ module Tinkerforge
|
|
572
567
|
#
|
573
568
|
# If the Bricklet is in bootloader mode, the LED is off.
|
574
569
|
def set_communication_led_config(config)
|
575
|
-
|
570
|
+
check_validity
|
571
|
+
|
572
|
+
send_request FUNCTION_SET_COMMUNICATION_LED_CONFIG, [config], 'C', 8, ''
|
576
573
|
end
|
577
574
|
|
578
575
|
# Returns the configuration as set by BrickletRS485#set_communication_led_config
|
579
576
|
def get_communication_led_config
|
580
|
-
|
577
|
+
check_validity
|
578
|
+
|
579
|
+
send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 9, 'C'
|
581
580
|
end
|
582
581
|
|
583
582
|
# Sets the error LED configuration.
|
@@ -590,17 +589,21 @@ module Tinkerforge
|
|
590
589
|
#
|
591
590
|
# If the Bricklet is in bootloader mode, the LED is off.
|
592
591
|
def set_error_led_config(config)
|
593
|
-
|
592
|
+
check_validity
|
593
|
+
|
594
|
+
send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 8, ''
|
594
595
|
end
|
595
596
|
|
596
597
|
# Returns the configuration as set by BrickletRS485#set_error_led_config.
|
597
598
|
def get_error_led_config
|
598
|
-
|
599
|
+
check_validity
|
600
|
+
|
601
|
+
send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 9, 'C'
|
599
602
|
end
|
600
603
|
|
601
604
|
# Sets the send and receive buffer size in byte. In sum there is
|
602
|
-
# 10240 byte (
|
603
|
-
# is 1024 byte (
|
605
|
+
# 10240 byte (10KiB) buffer available and the minimum buffer size
|
606
|
+
# is 1024 byte (1KiB) for both.
|
604
607
|
#
|
605
608
|
# The current buffer content is lost if this function is called.
|
606
609
|
#
|
@@ -608,47 +611,59 @@ module Tinkerforge
|
|
608
611
|
# could not be written yet. The receive buffer holds data that is
|
609
612
|
# received through RS485 but could not yet be send to the
|
610
613
|
# user, either by BrickletRS485#read or through CALLBACK_READ callback.
|
611
|
-
#
|
612
|
-
# The default configuration is 5120 byte (5kb) per buffer.
|
613
614
|
def set_buffer_config(send_buffer_size, receive_buffer_size)
|
614
|
-
|
615
|
+
check_validity
|
616
|
+
|
617
|
+
send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 8, ''
|
615
618
|
end
|
616
619
|
|
617
620
|
# Returns the buffer configuration as set by BrickletRS485#set_buffer_config.
|
618
621
|
def get_buffer_config
|
619
|
-
|
622
|
+
check_validity
|
623
|
+
|
624
|
+
send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 12, 'S S'
|
620
625
|
end
|
621
626
|
|
622
627
|
# Returns the currently used bytes for the send and received buffer.
|
623
628
|
#
|
624
629
|
# See BrickletRS485#set_buffer_config for buffer size configuration.
|
625
630
|
def get_buffer_status
|
626
|
-
|
631
|
+
check_validity
|
632
|
+
|
633
|
+
send_request FUNCTION_GET_BUFFER_STATUS, [], '', 12, 'S S'
|
627
634
|
end
|
628
635
|
|
629
636
|
# Enables the CALLBACK_ERROR_COUNT callback.
|
630
637
|
#
|
631
638
|
# By default the callback is disabled.
|
632
639
|
def enable_error_count_callback
|
633
|
-
|
640
|
+
check_validity
|
641
|
+
|
642
|
+
send_request FUNCTION_ENABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
|
634
643
|
end
|
635
644
|
|
636
645
|
# Disables the CALLBACK_ERROR_COUNT callback.
|
637
646
|
#
|
638
647
|
# By default the callback is disabled.
|
639
648
|
def disable_error_count_callback
|
640
|
-
|
649
|
+
check_validity
|
650
|
+
|
651
|
+
send_request FUNCTION_DISABLE_ERROR_COUNT_CALLBACK, [], '', 8, ''
|
641
652
|
end
|
642
653
|
|
643
654
|
# Returns *true* if the CALLBACK_ERROR_COUNT callback is enabled,
|
644
655
|
# *false* otherwise.
|
645
656
|
def is_error_count_callback_enabled
|
646
|
-
|
657
|
+
check_validity
|
658
|
+
|
659
|
+
send_request FUNCTION_IS_ERROR_COUNT_CALLBACK_ENABLED, [], '', 9, '?'
|
647
660
|
end
|
648
661
|
|
649
662
|
# Returns the current number of overrun and parity errors.
|
650
663
|
def get_error_count
|
651
|
-
|
664
|
+
check_validity
|
665
|
+
|
666
|
+
send_request FUNCTION_GET_ERROR_COUNT, [], '', 16, 'L L'
|
652
667
|
end
|
653
668
|
|
654
669
|
# Returns the current number of errors occurred in Modbus mode.
|
@@ -661,7 +676,9 @@ module Tinkerforge
|
|
661
676
|
# * Illegal Data Value Error Count: Number of errors due to invalid data value. This corresponds to Modbus exception code 3.
|
662
677
|
# * Slave Device Failure Error Count: Number of errors occurred on the slave device which were unrecoverable. This corresponds to Modbus exception code 4.
|
663
678
|
def get_modbus_common_error_count
|
664
|
-
|
679
|
+
check_validity
|
680
|
+
|
681
|
+
send_request FUNCTION_GET_MODBUS_COMMON_ERROR_COUNT, [], '', 36, 'L L L L L L L'
|
665
682
|
end
|
666
683
|
|
667
684
|
# In Modbus slave mode this function can be used to report a Modbus exception for
|
@@ -670,7 +687,9 @@ module Tinkerforge
|
|
670
687
|
# * Request ID: Request ID of the request received by the slave.
|
671
688
|
# * Exception Code: Modbus exception code to report to the Modbus master.
|
672
689
|
def modbus_slave_report_exception(request_id, exception_code)
|
673
|
-
|
690
|
+
check_validity
|
691
|
+
|
692
|
+
send_request FUNCTION_MODBUS_SLAVE_REPORT_EXCEPTION, [request_id, exception_code], 'C c', 8, ''
|
674
693
|
end
|
675
694
|
|
676
695
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -682,14 +701,16 @@ module Tinkerforge
|
|
682
701
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_READ_COILS_REQUEST callback
|
683
702
|
# with the Request ID as provided by the argument of the callback.
|
684
703
|
def modbus_slave_answer_read_coils_request_low_level(request_id, coils_length, coils_chunk_offset, coils_chunk_data)
|
685
|
-
|
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, ''
|
686
707
|
end
|
687
708
|
|
688
709
|
# In Modbus master mode this function can be used to read coils from a slave. This
|
689
710
|
# function creates a Modbus function code 1 request.
|
690
711
|
#
|
691
712
|
# * Slave Address: Address of the target Modbus slave.
|
692
|
-
# * Starting Address: Starting address
|
713
|
+
# * Starting Address: Number of the first coil to read. For backwards compatibility reasons this parameter is called Starting Address. It is not an address, but instead a coil number in the range of 1 to 65536.
|
693
714
|
# * Count: Number of coils to read.
|
694
715
|
#
|
695
716
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -701,7 +722,9 @@ module Tinkerforge
|
|
701
722
|
# matched with the Request ID returned from this function to verify that the callback
|
702
723
|
# is indeed for a particular request.
|
703
724
|
def modbus_master_read_coils(slave_address, starting_address, count)
|
704
|
-
|
725
|
+
check_validity
|
726
|
+
|
727
|
+
send_request FUNCTION_MODBUS_MASTER_READ_COILS, [slave_address, starting_address, count], 'C L S', 9, 'C'
|
705
728
|
end
|
706
729
|
|
707
730
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -713,14 +736,16 @@ module Tinkerforge
|
|
713
736
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_READ_HOLDING_REGISTERS_REQUEST
|
714
737
|
# callback with the Request ID as provided by the argument of the callback.
|
715
738
|
def modbus_slave_answer_read_holding_registers_request_low_level(request_id, holding_registers_length, holding_registers_chunk_offset, holding_registers_chunk_data)
|
716
|
-
|
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, ''
|
717
742
|
end
|
718
743
|
|
719
744
|
# In Modbus master mode this function can be used to read holding registers from a slave.
|
720
745
|
# This function creates a Modbus function code 3 request.
|
721
746
|
#
|
722
747
|
# * Slave Address: Address of the target Modbus slave.
|
723
|
-
# * Starting Address: Starting address
|
748
|
+
# * Starting Address: Number of the first holding register to read. For backwards compatibility reasons this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted.
|
724
749
|
# * Count: Number of holding registers to read.
|
725
750
|
#
|
726
751
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -732,7 +757,9 @@ module Tinkerforge
|
|
732
757
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
733
758
|
# particular request.
|
734
759
|
def modbus_master_read_holding_registers(slave_address, starting_address, count)
|
735
|
-
|
760
|
+
check_validity
|
761
|
+
|
762
|
+
send_request FUNCTION_MODBUS_MASTER_READ_HOLDING_REGISTERS, [slave_address, starting_address, count], 'C L S', 9, 'C'
|
736
763
|
end
|
737
764
|
|
738
765
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -743,14 +770,16 @@ module Tinkerforge
|
|
743
770
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_SINGLE_COIL_REQUEST
|
744
771
|
# callback with the Request ID as provided by the arguments of the callback.
|
745
772
|
def modbus_slave_answer_write_single_coil_request(request_id)
|
746
|
-
|
773
|
+
check_validity
|
774
|
+
|
775
|
+
send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_COIL_REQUEST, [request_id], 'C', 8, ''
|
747
776
|
end
|
748
777
|
|
749
778
|
# In Modbus master mode this function can be used to write a single coil of a slave.
|
750
779
|
# This function creates a Modbus function code 5 request.
|
751
780
|
#
|
752
781
|
# * Slave Address: Address of the target Modbus slave.
|
753
|
-
# * Coil Address:
|
782
|
+
# * Coil Address: Number of the coil to be written. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a coil number in the range of 1 to 65536.
|
754
783
|
# * Coil Value: Value to be written.
|
755
784
|
#
|
756
785
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -762,7 +791,9 @@ module Tinkerforge
|
|
762
791
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
763
792
|
# particular request.
|
764
793
|
def modbus_master_write_single_coil(slave_address, coil_address, coil_value)
|
765
|
-
|
794
|
+
check_validity
|
795
|
+
|
796
|
+
send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_COIL, [slave_address, coil_address, coil_value], 'C L ?', 9, 'C'
|
766
797
|
end
|
767
798
|
|
768
799
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -774,14 +805,16 @@ module Tinkerforge
|
|
774
805
|
# callback with the Request ID, Register Address and Register Value as provided by
|
775
806
|
# the arguments of the callback.
|
776
807
|
def modbus_slave_answer_write_single_register_request(request_id)
|
777
|
-
|
808
|
+
check_validity
|
809
|
+
|
810
|
+
send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_SINGLE_REGISTER_REQUEST, [request_id], 'C', 8, ''
|
778
811
|
end
|
779
812
|
|
780
|
-
# In Modbus master mode this function can be used to write a single register of a
|
813
|
+
# In Modbus master mode this function can be used to write a single holding register of a
|
781
814
|
# slave. This function creates a Modbus function code 6 request.
|
782
815
|
#
|
783
816
|
# * Slave Address: Address of the target Modbus slave.
|
784
|
-
# * Register Address:
|
817
|
+
# * Register Address: Number of the holding register to be written. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted.
|
785
818
|
# * Register Value: Value to be written.
|
786
819
|
#
|
787
820
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -793,7 +826,9 @@ module Tinkerforge
|
|
793
826
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
794
827
|
# particular request.
|
795
828
|
def modbus_master_write_single_register(slave_address, register_address, register_value)
|
796
|
-
|
829
|
+
check_validity
|
830
|
+
|
831
|
+
send_request FUNCTION_MODBUS_MASTER_WRITE_SINGLE_REGISTER, [slave_address, register_address, register_value], 'C L S', 9, 'C'
|
797
832
|
end
|
798
833
|
|
799
834
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -804,14 +839,16 @@ module Tinkerforge
|
|
804
839
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_COILS_REQUEST
|
805
840
|
# callback with the Request ID of the callback.
|
806
841
|
def modbus_slave_answer_write_multiple_coils_request(request_id)
|
807
|
-
|
842
|
+
check_validity
|
843
|
+
|
844
|
+
send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_COILS_REQUEST, [request_id], 'C', 8, ''
|
808
845
|
end
|
809
846
|
|
810
847
|
# In Modbus master mode this function can be used to write multiple coils of a slave.
|
811
848
|
# This function creates a Modbus function code 15 request.
|
812
849
|
#
|
813
850
|
# * Slave Address: Address of the target Modbus slave.
|
814
|
-
# * Starting Address: Starting address
|
851
|
+
# * Starting Address: Number of the first coil to write. For backwards compatibility reasons, this parameter is called Starting Address.It is not an address, but instead a coil number in the range of 1 to 65536.
|
815
852
|
#
|
816
853
|
# Upon success the function will return a non-zero request ID which will represent
|
817
854
|
# the current request initiated by the Modbus master. In case of failure the returned
|
@@ -822,7 +859,9 @@ module Tinkerforge
|
|
822
859
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
823
860
|
# particular request.
|
824
861
|
def modbus_master_write_multiple_coils_low_level(slave_address, starting_address, coils_length, coils_chunk_offset, coils_chunk_data)
|
825
|
-
|
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'
|
826
865
|
end
|
827
866
|
|
828
867
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -833,14 +872,16 @@ module Tinkerforge
|
|
833
872
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_WRITE_MULTIPLE_REGISTERS_REQUEST
|
834
873
|
# callback with the Request ID of the callback.
|
835
874
|
def modbus_slave_answer_write_multiple_registers_request(request_id)
|
836
|
-
|
875
|
+
check_validity
|
876
|
+
|
877
|
+
send_request FUNCTION_MODBUS_SLAVE_ANSWER_WRITE_MULTIPLE_REGISTERS_REQUEST, [request_id], 'C', 8, ''
|
837
878
|
end
|
838
879
|
|
839
880
|
# In Modbus master mode this function can be used to write multiple registers of a slave.
|
840
881
|
# This function creates a Modbus function code 16 request.
|
841
882
|
#
|
842
883
|
# * Slave Address: Address of the target Modbus slave.
|
843
|
-
# * Starting Address: Starting Address
|
884
|
+
# * Starting Address: Number of the first holding register to write. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted.
|
844
885
|
#
|
845
886
|
# Upon success the function will return a non-zero request ID which will represent
|
846
887
|
# the current request initiated by the Modbus master. In case of failure the returned
|
@@ -851,7 +892,9 @@ module Tinkerforge
|
|
851
892
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
852
893
|
# particular request.
|
853
894
|
def modbus_master_write_multiple_registers_low_level(slave_address, starting_address, registers_length, registers_chunk_offset, registers_chunk_data)
|
854
|
-
|
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'
|
855
898
|
end
|
856
899
|
|
857
900
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -863,14 +906,16 @@ module Tinkerforge
|
|
863
906
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_READ_DISCRETE_INPUTS_REQUEST
|
864
907
|
# callback with the Request ID as provided by the argument of the callback.
|
865
908
|
def modbus_slave_answer_read_discrete_inputs_request_low_level(request_id, discrete_inputs_length, discrete_inputs_chunk_offset, discrete_inputs_chunk_data)
|
866
|
-
|
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, ''
|
867
912
|
end
|
868
913
|
|
869
914
|
# In Modbus master mode this function can be used to read discrete inputs from a slave.
|
870
915
|
# This function creates a Modbus function code 2 request.
|
871
916
|
#
|
872
917
|
# * Slave Address: Address of the target Modbus slave.
|
873
|
-
# * Starting Address: Starting address
|
918
|
+
# * Starting Address: Number of the first discrete input to read. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a discrete input number in the range of 1 to 65536. The prefix digit 1 (for discrete input) is implicit and must be omitted.
|
874
919
|
# * Count: Number of discrete inputs to read.
|
875
920
|
#
|
876
921
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -882,7 +927,9 @@ module Tinkerforge
|
|
882
927
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
883
928
|
# particular request.
|
884
929
|
def modbus_master_read_discrete_inputs(slave_address, starting_address, count)
|
885
|
-
|
930
|
+
check_validity
|
931
|
+
|
932
|
+
send_request FUNCTION_MODBUS_MASTER_READ_DISCRETE_INPUTS, [slave_address, starting_address, count], 'C L S', 9, 'C'
|
886
933
|
end
|
887
934
|
|
888
935
|
# In Modbus slave mode this function can be used to answer a master request to
|
@@ -894,14 +941,16 @@ module Tinkerforge
|
|
894
941
|
# This function must be called from the CALLBACK_MODBUS_SLAVE_READ_INPUT_REGISTERS_REQUEST callback
|
895
942
|
# with the Request ID as provided by the argument of the callback.
|
896
943
|
def modbus_slave_answer_read_input_registers_request_low_level(request_id, input_registers_length, input_registers_chunk_offset, input_registers_chunk_data)
|
897
|
-
|
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, ''
|
898
947
|
end
|
899
948
|
|
900
949
|
# In Modbus master mode this function can be used to read input registers from a slave.
|
901
950
|
# This function creates a Modbus function code 4 request.
|
902
951
|
#
|
903
952
|
# * Slave Address: Address of the target Modbus slave.
|
904
|
-
# * Starting Address: Starting address
|
953
|
+
# * Starting Address: Number of the first input register to read. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead an input register number in the range of 1 to 65536. The prefix digit 3 (for input register) is implicit and must be omitted.
|
905
954
|
# * Count: Number of input registers to read.
|
906
955
|
#
|
907
956
|
# Upon success the function will return a non-zero request ID which will represent
|
@@ -913,7 +962,30 @@ module Tinkerforge
|
|
913
962
|
# with the Request ID returned from this function to verify that the callback is indeed for a
|
914
963
|
# particular request.
|
915
964
|
def modbus_master_read_input_registers(slave_address, starting_address, count)
|
916
|
-
|
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'
|
917
989
|
end
|
918
990
|
|
919
991
|
# Returns the error count for the communication between Brick and Bricklet.
|
@@ -928,7 +1000,9 @@ module Tinkerforge
|
|
928
1000
|
# The errors counts are for errors that occur on the Bricklet side. All
|
929
1001
|
# Bricks have a similar function that returns the errors on the Brick side.
|
930
1002
|
def get_spitfp_error_count
|
931
|
-
|
1003
|
+
check_validity
|
1004
|
+
|
1005
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 24, 'L L L L'
|
932
1006
|
end
|
933
1007
|
|
934
1008
|
# Sets the bootloader mode and returns the status after the requested
|
@@ -941,12 +1015,16 @@ module Tinkerforge
|
|
941
1015
|
# This function is used by Brick Viewer during flashing. It should not be
|
942
1016
|
# necessary to call it in a normal user program.
|
943
1017
|
def set_bootloader_mode(mode)
|
944
|
-
|
1018
|
+
check_validity
|
1019
|
+
|
1020
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 9, 'C'
|
945
1021
|
end
|
946
1022
|
|
947
1023
|
# Returns the current bootloader mode, see BrickletRS485#set_bootloader_mode.
|
948
1024
|
def get_bootloader_mode
|
949
|
-
|
1025
|
+
check_validity
|
1026
|
+
|
1027
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 9, 'C'
|
950
1028
|
end
|
951
1029
|
|
952
1030
|
# Sets the firmware pointer for BrickletRS485#write_firmware. The pointer has
|
@@ -956,7 +1034,9 @@ module Tinkerforge
|
|
956
1034
|
# This function is used by Brick Viewer during flashing. It should not be
|
957
1035
|
# necessary to call it in a normal user program.
|
958
1036
|
def set_write_firmware_pointer(pointer)
|
959
|
-
|
1037
|
+
check_validity
|
1038
|
+
|
1039
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 8, ''
|
960
1040
|
end
|
961
1041
|
|
962
1042
|
# Writes 64 Bytes of firmware at the position as written by
|
@@ -968,7 +1048,9 @@ module Tinkerforge
|
|
968
1048
|
# This function is used by Brick Viewer during flashing. It should not be
|
969
1049
|
# necessary to call it in a normal user program.
|
970
1050
|
def write_firmware(data)
|
971
|
-
|
1051
|
+
check_validity
|
1052
|
+
|
1053
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 9, 'C'
|
972
1054
|
end
|
973
1055
|
|
974
1056
|
# Sets the status LED configuration. By default the LED shows
|
@@ -979,22 +1061,28 @@ module Tinkerforge
|
|
979
1061
|
#
|
980
1062
|
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
981
1063
|
def set_status_led_config(config)
|
982
|
-
|
1064
|
+
check_validity
|
1065
|
+
|
1066
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 8, ''
|
983
1067
|
end
|
984
1068
|
|
985
1069
|
# Returns the configuration as set by BrickletRS485#set_status_led_config
|
986
1070
|
def get_status_led_config
|
987
|
-
|
1071
|
+
check_validity
|
1072
|
+
|
1073
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 9, 'C'
|
988
1074
|
end
|
989
1075
|
|
990
|
-
# Returns the temperature
|
1076
|
+
# Returns the temperature as measured inside the microcontroller. The
|
991
1077
|
# value returned is not the ambient temperature!
|
992
1078
|
#
|
993
1079
|
# The temperature is only proportional to the real temperature and it has bad
|
994
1080
|
# accuracy. Practically it is only useful as an indicator for
|
995
1081
|
# temperature changes.
|
996
1082
|
def get_chip_temperature
|
997
|
-
|
1083
|
+
check_validity
|
1084
|
+
|
1085
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 10, 's'
|
998
1086
|
end
|
999
1087
|
|
1000
1088
|
# Calling this function will reset the Bricklet. All configurations
|
@@ -1004,7 +1092,9 @@ module Tinkerforge
|
|
1004
1092
|
# calling functions on the existing ones will result in
|
1005
1093
|
# undefined behavior!
|
1006
1094
|
def reset
|
1007
|
-
|
1095
|
+
check_validity
|
1096
|
+
|
1097
|
+
send_request FUNCTION_RESET, [], '', 8, ''
|
1008
1098
|
end
|
1009
1099
|
|
1010
1100
|
# Writes a new UID into flash. If you want to set a new UID
|
@@ -1013,25 +1103,31 @@ module Tinkerforge
|
|
1013
1103
|
#
|
1014
1104
|
# We recommend that you use Brick Viewer to change the UID.
|
1015
1105
|
def write_uid(uid)
|
1016
|
-
|
1106
|
+
check_validity
|
1107
|
+
|
1108
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 8, ''
|
1017
1109
|
end
|
1018
1110
|
|
1019
1111
|
# Returns the current UID as an integer. Encode as
|
1020
1112
|
# Base58 to get the usual string version.
|
1021
1113
|
def read_uid
|
1022
|
-
|
1114
|
+
check_validity
|
1115
|
+
|
1116
|
+
send_request FUNCTION_READ_UID, [], '', 12, 'L'
|
1023
1117
|
end
|
1024
1118
|
|
1025
1119
|
# Returns the UID, the UID where the Bricklet is connected to,
|
1026
1120
|
# the position, the hardware and firmware version as well as the
|
1027
1121
|
# device identifier.
|
1028
1122
|
#
|
1029
|
-
# The position can be 'a', 'b', 'c' or '
|
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'.
|
1030
1126
|
#
|
1031
1127
|
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
1032
1128
|
# |device_identifier_constant|
|
1033
1129
|
def get_identity
|
1034
|
-
send_request FUNCTION_GET_IDENTITY, [], '',
|
1130
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 33, 'Z8 Z8 k C3 C3 S'
|
1035
1131
|
end
|
1036
1132
|
|
1037
1133
|
# Writes characters to the RS485 interface. The characters can be binary data,
|
@@ -1200,7 +1296,7 @@ module Tinkerforge
|
|
1200
1296
|
# This function creates a Modbus function code 15 request.
|
1201
1297
|
#
|
1202
1298
|
# * Slave Address: Address of the target Modbus slave.
|
1203
|
-
# * Starting Address: Starting address
|
1299
|
+
# * Starting Address: Number of the first coil to write. For backwards compatibility reasons, this parameter is called Starting Address.It is not an address, but instead a coil number in the range of 1 to 65536.
|
1204
1300
|
#
|
1205
1301
|
# Upon success the function will return a non-zero request ID which will represent
|
1206
1302
|
# the current request initiated by the Modbus master. In case of failure the returned
|
@@ -1245,7 +1341,7 @@ module Tinkerforge
|
|
1245
1341
|
# This function creates a Modbus function code 16 request.
|
1246
1342
|
#
|
1247
1343
|
# * Slave Address: Address of the target Modbus slave.
|
1248
|
-
# * Starting Address: Starting Address
|
1344
|
+
# * Starting Address: Number of the first holding register to write. For backwards compatibility reasons, this parameter is called Starting Address. It is not an address, but instead a holding register number in the range of 1 to 65536. The prefix digit 4 (for holding register) is implicit and must be omitted.
|
1249
1345
|
#
|
1250
1346
|
# Upon success the function will return a non-zero request ID which will represent
|
1251
1347
|
# the current request initiated by the Modbus master. In case of failure the returned
|