tinkerforge 2.1.16 → 2.1.17
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 +4 -4
- data/lib/tinkerforge/brick_dc.rb +3 -3
- data/lib/tinkerforge/brick_imu.rb +3 -3
- data/lib/tinkerforge/brick_imu_v2.rb +3 -3
- data/lib/tinkerforge/brick_master.rb +3 -3
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +3 -3
- data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
- data/lib/tinkerforge/brick_stepper.rb +3 -3
- data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
- data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
- data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_barometer.rb +2 -2
- data/lib/tinkerforge/bricklet_can.rb +3 -3
- data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
- data/lib/tinkerforge/bricklet_co2.rb +2 -2
- data/lib/tinkerforge/bricklet_color.rb +2 -2
- data/lib/tinkerforge/bricklet_current12.rb +2 -2
- data/lib/tinkerforge/bricklet_current25.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
- data/lib/tinkerforge/bricklet_dmx.rb +3 -3
- data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
- data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_gps.rb +2 -2
- data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
- data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
- data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
- data/lib/tinkerforge/bricklet_io16.rb +2 -2
- data/lib/tinkerforge/bricklet_io4.rb +2 -2
- data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
- data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
- data/lib/tinkerforge/bricklet_line.rb +2 -2
- data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
- data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
- data/lib/tinkerforge/bricklet_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
- data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
- data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
- data/lib/tinkerforge/bricklet_nfc.rb +39 -3
- data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
- data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
- data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
- data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
- data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc.rb +33 -3
- data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
- data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232.rb +3 -3
- data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
- data/lib/tinkerforge/bricklet_rs485.rb +6 -6
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
- data/lib/tinkerforge/bricklet_temperature.rb +3 -3
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
- data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
- data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
- data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
- data/lib/tinkerforge/bricklet_tilt.rb +2 -2
- data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
- data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
- data/lib/tinkerforge/ip_connection.rb +4 -4
- data/lib/tinkerforge/version.rb +1 -1
- metadata +17 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
|
2
2
|
#############################################################
|
|
3
|
-
# This file was automatically generated on 2018-
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
4
|
# #
|
|
5
|
-
# Ruby Bindings Version 2.1.
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
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 #
|
|
@@ -144,7 +144,7 @@ module Tinkerforge
|
|
|
144
144
|
# * Parity of none, odd, even or forced parity.
|
|
145
145
|
# * Stopbits can be 1 or 2.
|
|
146
146
|
# * Word length of 5 to 8.
|
|
147
|
-
# * Hard-/Software flow control can
|
|
147
|
+
# * Hard-/Software flow control can either be on or off but not both simultaneously on.
|
|
148
148
|
#
|
|
149
149
|
# The default is: 115200 baud, parity none, 1 stop bit, word length 8, hard-/software flow control off.
|
|
150
150
|
def set_configuration(baudrate, parity, stopbits, wordlength, hardware_flowcontrol, software_flowcontrol)
|
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
|
2
|
+
#############################################################
|
|
3
|
+
# This file was automatically generated on 2018-06-08. #
|
|
4
|
+
# #
|
|
5
|
+
# Ruby Bindings Version 2.1.17 #
|
|
6
|
+
# #
|
|
7
|
+
# If you have a bugfix for this file and want to commit it, #
|
|
8
|
+
# please fix the bug in the generator. You can find a link #
|
|
9
|
+
# to the generators git repository on tinkerforge.com #
|
|
10
|
+
#############################################################
|
|
11
|
+
|
|
12
|
+
module Tinkerforge
|
|
13
|
+
# Communicates with RS232 devices
|
|
14
|
+
class BrickletRS232V2 < Device
|
|
15
|
+
DEVICE_IDENTIFIER = 2108 # :nodoc:
|
|
16
|
+
DEVICE_DISPLAY_NAME = 'RS232 Bricklet 2.0' # :nodoc:
|
|
17
|
+
|
|
18
|
+
# This callback is called if new data is available.
|
|
19
|
+
#
|
|
20
|
+
# To enable this callback, use BrickletRS232V2#enable_read_callback.
|
|
21
|
+
CALLBACK_READ_LOW_LEVEL = 12
|
|
22
|
+
|
|
23
|
+
# This callback is called if a new error occurs. It returns
|
|
24
|
+
# the current overrun and parity error count.
|
|
25
|
+
CALLBACK_ERROR_COUNT = 13
|
|
26
|
+
|
|
27
|
+
# This callback is called if new data is available.
|
|
28
|
+
#
|
|
29
|
+
# To enable this callback, use BrickletRS232V2#enable_read_callback.
|
|
30
|
+
CALLBACK_READ = -12
|
|
31
|
+
|
|
32
|
+
FUNCTION_WRITE_LOW_LEVEL = 1 # :nodoc:
|
|
33
|
+
FUNCTION_READ_LOW_LEVEL = 2 # :nodoc:
|
|
34
|
+
FUNCTION_ENABLE_READ_CALLBACK = 3 # :nodoc:
|
|
35
|
+
FUNCTION_DISABLE_READ_CALLBACK = 4 # :nodoc:
|
|
36
|
+
FUNCTION_IS_READ_CALLBACK_ENABLED = 5 # :nodoc:
|
|
37
|
+
FUNCTION_SET_CONFIGURATION = 6 # :nodoc:
|
|
38
|
+
FUNCTION_GET_CONFIGURATION = 7 # :nodoc:
|
|
39
|
+
FUNCTION_SET_BUFFER_CONFIG = 8 # :nodoc:
|
|
40
|
+
FUNCTION_GET_BUFFER_CONFIG = 9 # :nodoc:
|
|
41
|
+
FUNCTION_GET_BUFFER_STATUS = 10 # :nodoc:
|
|
42
|
+
FUNCTION_GET_ERROR_COUNT = 11 # :nodoc:
|
|
43
|
+
FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
|
|
44
|
+
FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
|
|
45
|
+
FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
|
|
46
|
+
FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
|
|
47
|
+
FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
|
|
48
|
+
FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
|
|
49
|
+
FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
|
|
50
|
+
FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
|
|
51
|
+
FUNCTION_RESET = 243 # :nodoc:
|
|
52
|
+
FUNCTION_WRITE_UID = 248 # :nodoc:
|
|
53
|
+
FUNCTION_READ_UID = 249 # :nodoc:
|
|
54
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
|
55
|
+
|
|
56
|
+
PARITY_NONE = 0 # :nodoc:
|
|
57
|
+
PARITY_ODD = 1 # :nodoc:
|
|
58
|
+
PARITY_EVEN = 2 # :nodoc:
|
|
59
|
+
STOPBITS_1 = 1 # :nodoc:
|
|
60
|
+
STOPBITS_2 = 2 # :nodoc:
|
|
61
|
+
WORDLENGTH_5 = 5 # :nodoc:
|
|
62
|
+
WORDLENGTH_6 = 6 # :nodoc:
|
|
63
|
+
WORDLENGTH_7 = 7 # :nodoc:
|
|
64
|
+
WORDLENGTH_8 = 8 # :nodoc:
|
|
65
|
+
FLOWCONTROL_OFF = 0 # :nodoc:
|
|
66
|
+
FLOWCONTROL_SOFTWARE = 1 # :nodoc:
|
|
67
|
+
FLOWCONTROL_HARDWARE = 2 # :nodoc:
|
|
68
|
+
BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
|
|
69
|
+
BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
|
|
70
|
+
BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
|
|
71
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
|
|
72
|
+
BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
|
|
73
|
+
BOOTLOADER_STATUS_OK = 0 # :nodoc:
|
|
74
|
+
BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
|
|
75
|
+
BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
|
|
76
|
+
BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
|
|
77
|
+
BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
|
|
78
|
+
BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
|
|
79
|
+
STATUS_LED_CONFIG_OFF = 0 # :nodoc:
|
|
80
|
+
STATUS_LED_CONFIG_ON = 1 # :nodoc:
|
|
81
|
+
STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
|
|
82
|
+
STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
|
|
83
|
+
|
|
84
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
|
85
|
+
# the IP Connection <tt>ipcon</tt>.
|
|
86
|
+
def initialize(uid, ipcon)
|
|
87
|
+
super uid, ipcon
|
|
88
|
+
|
|
89
|
+
@api_version = [2, 0, 0]
|
|
90
|
+
|
|
91
|
+
@response_expected[FUNCTION_WRITE_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
92
|
+
@response_expected[FUNCTION_READ_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
93
|
+
@response_expected[FUNCTION_ENABLE_READ_CALLBACK] = RESPONSE_EXPECTED_TRUE
|
|
94
|
+
@response_expected[FUNCTION_DISABLE_READ_CALLBACK] = RESPONSE_EXPECTED_TRUE
|
|
95
|
+
@response_expected[FUNCTION_IS_READ_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
96
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
|
97
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
98
|
+
@response_expected[FUNCTION_SET_BUFFER_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
99
|
+
@response_expected[FUNCTION_GET_BUFFER_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
100
|
+
@response_expected[FUNCTION_GET_BUFFER_STATUS] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
101
|
+
@response_expected[FUNCTION_GET_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
102
|
+
@response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
103
|
+
@response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
104
|
+
@response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
105
|
+
@response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
|
|
106
|
+
@response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
107
|
+
@response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
|
|
108
|
+
@response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
109
|
+
@response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
110
|
+
@response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
|
|
111
|
+
@response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
|
|
112
|
+
@response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
113
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
|
114
|
+
|
|
115
|
+
@callback_formats[CALLBACK_READ_LOW_LEVEL] = 'S S k60'
|
|
116
|
+
@callback_formats[CALLBACK_ERROR_COUNT] = 'L L'
|
|
117
|
+
|
|
118
|
+
@high_level_callbacks[CALLBACK_READ] = [['stream_length', 'stream_chunk_offset', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => false}, nil]
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
# Writes characters to the RS232 interface. The characters can be binary data,
|
|
122
|
+
# ASCII or similar is not necessary.
|
|
123
|
+
#
|
|
124
|
+
# The return value is the number of characters that were written.
|
|
125
|
+
#
|
|
126
|
+
# See BrickletRS232V2#set_configuration for configuration possibilities
|
|
127
|
+
# regarding baud rate, parity and so on.
|
|
128
|
+
def write_low_level(message_length, message_chunk_offset, message_chunk_data)
|
|
129
|
+
send_request FUNCTION_WRITE_LOW_LEVEL, [message_length, message_chunk_offset, message_chunk_data], 'S S k60', 1, 'C'
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Returns up to *length* characters from receive buffer.
|
|
133
|
+
#
|
|
134
|
+
# Instead of polling with this function, you can also use
|
|
135
|
+
# callbacks. But note that this function will return available
|
|
136
|
+
# data only when the read callback is disabled.
|
|
137
|
+
# See BrickletRS232V2#enable_read_callback and CALLBACK_READ callback.
|
|
138
|
+
def read_low_level(length)
|
|
139
|
+
send_request FUNCTION_READ_LOW_LEVEL, [length], 'S', 64, 'S S k60'
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# Enables the CALLBACK_READ callback.
|
|
143
|
+
#
|
|
144
|
+
# By default the callback is disabled.
|
|
145
|
+
def enable_read_callback
|
|
146
|
+
send_request FUNCTION_ENABLE_READ_CALLBACK, [], '', 0, ''
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# Disables the CALLBACK_READ callback.
|
|
150
|
+
#
|
|
151
|
+
# By default the callback is disabled.
|
|
152
|
+
def disable_read_callback
|
|
153
|
+
send_request FUNCTION_DISABLE_READ_CALLBACK, [], '', 0, ''
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
# Returns *true* if the CALLBACK_READ callback is enabled,
|
|
157
|
+
# *false* otherwise.
|
|
158
|
+
def is_read_callback_enabled
|
|
159
|
+
send_request FUNCTION_IS_READ_CALLBACK_ENABLED, [], '', 1, '?'
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Sets the configuration for the RS232 communication. Available options:
|
|
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.
|
|
171
|
+
def set_configuration(baudrate, parity, stopbits, wordlength, flowcontrol)
|
|
172
|
+
send_request FUNCTION_SET_CONFIGURATION, [baudrate, parity, stopbits, wordlength, flowcontrol], 'L C C C C', 0, ''
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
# Returns the configuration as set by BrickletRS232V2#set_configuration.
|
|
176
|
+
def get_configuration
|
|
177
|
+
send_request FUNCTION_GET_CONFIGURATION, [], '', 8, 'L C C C C'
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Sets the send and receive buffer size in byte. In sum there is
|
|
181
|
+
# 10240 byte (10kb) buffer available and the minimum buffer size
|
|
182
|
+
# is 1024 byte (1kb) for both.
|
|
183
|
+
#
|
|
184
|
+
# The current buffer content is lost if this function is called.
|
|
185
|
+
#
|
|
186
|
+
# The send buffer holds data that is given by BrickletRS232V2#write and
|
|
187
|
+
# can not be written yet. The receive buffer holds data that is
|
|
188
|
+
# received through RS232 but could not yet be send to the
|
|
189
|
+
# user, either by BrickletRS232V2#read or through CALLBACK_READ callback.
|
|
190
|
+
#
|
|
191
|
+
# The default configuration is 5120 byte (5kb) per buffer.
|
|
192
|
+
def set_buffer_config(send_buffer_size, receive_buffer_size)
|
|
193
|
+
send_request FUNCTION_SET_BUFFER_CONFIG, [send_buffer_size, receive_buffer_size], 'S S', 0, ''
|
|
194
|
+
end
|
|
195
|
+
|
|
196
|
+
# Returns the buffer configuration as set by BrickletRS232V2#set_buffer_config.
|
|
197
|
+
def get_buffer_config
|
|
198
|
+
send_request FUNCTION_GET_BUFFER_CONFIG, [], '', 4, 'S S'
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# Returns the currently used bytes for the send and received buffer.
|
|
202
|
+
#
|
|
203
|
+
# See BrickletRS232V2#set_buffer_config for buffer size configuration.
|
|
204
|
+
def get_buffer_status
|
|
205
|
+
send_request FUNCTION_GET_BUFFER_STATUS, [], '', 4, 'S S'
|
|
206
|
+
end
|
|
207
|
+
|
|
208
|
+
# Returns the current number of overrun and parity errors.
|
|
209
|
+
def get_error_count
|
|
210
|
+
send_request FUNCTION_GET_ERROR_COUNT, [], '', 8, 'L L'
|
|
211
|
+
end
|
|
212
|
+
|
|
213
|
+
# Returns the error count for the communication between Brick and Bricklet.
|
|
214
|
+
#
|
|
215
|
+
# The errors are divided into
|
|
216
|
+
#
|
|
217
|
+
# * ack checksum errors,
|
|
218
|
+
# * message checksum errors,
|
|
219
|
+
# * frameing errors and
|
|
220
|
+
# * overflow errors.
|
|
221
|
+
#
|
|
222
|
+
# The errors counts are for errors that occur on the Bricklet side. All
|
|
223
|
+
# Bricks have a similar function that returns the errors on the Brick side.
|
|
224
|
+
def get_spitfp_error_count
|
|
225
|
+
send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
|
|
226
|
+
end
|
|
227
|
+
|
|
228
|
+
# Sets the bootloader mode and returns the status after the requested
|
|
229
|
+
# mode change was instigated.
|
|
230
|
+
#
|
|
231
|
+
# You can change from bootloader mode to firmware mode and vice versa. A change
|
|
232
|
+
# from bootloader mode to firmware mode will only take place if the entry function,
|
|
233
|
+
# device identifier und crc are present and correct.
|
|
234
|
+
#
|
|
235
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
236
|
+
# necessary to call it in a normal user program.
|
|
237
|
+
def set_bootloader_mode(mode)
|
|
238
|
+
send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
|
|
239
|
+
end
|
|
240
|
+
|
|
241
|
+
# Returns the current bootloader mode, see BrickletRS232V2#set_bootloader_mode.
|
|
242
|
+
def get_bootloader_mode
|
|
243
|
+
send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
|
|
244
|
+
end
|
|
245
|
+
|
|
246
|
+
# Sets the firmware pointer for BrickletRS232V2#write_firmware. The pointer has
|
|
247
|
+
# to be increased by chunks of size 64. The data is written to flash
|
|
248
|
+
# every 4 chunks (which equals to one page of size 256).
|
|
249
|
+
#
|
|
250
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
251
|
+
# necessary to call it in a normal user program.
|
|
252
|
+
def set_write_firmware_pointer(pointer)
|
|
253
|
+
send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# Writes 64 Bytes of firmware at the position as written by
|
|
257
|
+
# BrickletRS232V2#set_write_firmware_pointer before. The firmware is written
|
|
258
|
+
# to flash every 4 chunks.
|
|
259
|
+
#
|
|
260
|
+
# You can only write firmware in bootloader mode.
|
|
261
|
+
#
|
|
262
|
+
# This function is used by Brick Viewer during flashing. It should not be
|
|
263
|
+
# necessary to call it in a normal user program.
|
|
264
|
+
def write_firmware(data)
|
|
265
|
+
send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# Sets the status LED configuration. By default the LED shows
|
|
269
|
+
# communication traffic between Brick and Bricklet, it flickers once
|
|
270
|
+
# for every 10 received data packets.
|
|
271
|
+
#
|
|
272
|
+
# You can also turn the LED permanently on/off or show a heartbeat.
|
|
273
|
+
#
|
|
274
|
+
# If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
|
|
275
|
+
def set_status_led_config(config)
|
|
276
|
+
send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
# Returns the configuration as set by BrickletRS232V2#set_status_led_config
|
|
280
|
+
def get_status_led_config
|
|
281
|
+
send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
|
|
282
|
+
end
|
|
283
|
+
|
|
284
|
+
# Returns the temperature in °C as measured inside the microcontroller. The
|
|
285
|
+
# value returned is not the ambient temperature!
|
|
286
|
+
#
|
|
287
|
+
# The temperature is only proportional to the real temperature and it has bad
|
|
288
|
+
# accuracy. Practically it is only useful as an indicator for
|
|
289
|
+
# temperature changes.
|
|
290
|
+
def get_chip_temperature
|
|
291
|
+
send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
|
|
292
|
+
end
|
|
293
|
+
|
|
294
|
+
# Calling this function will reset the Bricklet. All configurations
|
|
295
|
+
# will be lost.
|
|
296
|
+
#
|
|
297
|
+
# After a reset you have to create new device objects,
|
|
298
|
+
# calling functions on the existing ones will result in
|
|
299
|
+
# undefined behavior!
|
|
300
|
+
def reset
|
|
301
|
+
send_request FUNCTION_RESET, [], '', 0, ''
|
|
302
|
+
end
|
|
303
|
+
|
|
304
|
+
# Writes a new UID into flash. If you want to set a new UID
|
|
305
|
+
# you have to decode the Base58 encoded UID string into an
|
|
306
|
+
# integer first.
|
|
307
|
+
#
|
|
308
|
+
# We recommend that you use Brick Viewer to change the UID.
|
|
309
|
+
def write_uid(uid)
|
|
310
|
+
send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Returns the current UID as an integer. Encode as
|
|
314
|
+
# Base58 to get the usual string version.
|
|
315
|
+
def read_uid
|
|
316
|
+
send_request FUNCTION_READ_UID, [], '', 4, 'L'
|
|
317
|
+
end
|
|
318
|
+
|
|
319
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
|
320
|
+
# the position, the hardware and firmware version as well as the
|
|
321
|
+
# device identifier.
|
|
322
|
+
#
|
|
323
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
|
324
|
+
#
|
|
325
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
|
326
|
+
# |device_identifier_constant|
|
|
327
|
+
def get_identity
|
|
328
|
+
send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
|
|
329
|
+
end
|
|
330
|
+
|
|
331
|
+
# Writes characters to the RS232 interface. The characters can be binary data,
|
|
332
|
+
# ASCII or similar is not necessary.
|
|
333
|
+
#
|
|
334
|
+
# The return value is the number of characters that were written.
|
|
335
|
+
#
|
|
336
|
+
# See BrickletRS232V2#set_configuration for configuration possibilities
|
|
337
|
+
# regarding baud rate, parity and so on.
|
|
338
|
+
def write(message)
|
|
339
|
+
if message.length > 65535
|
|
340
|
+
raise ArgumentError, 'Message can be at most 65535 items long'
|
|
341
|
+
end
|
|
342
|
+
|
|
343
|
+
message_length = message.length
|
|
344
|
+
message_chunk_offset = 0
|
|
345
|
+
|
|
346
|
+
if message_length == 0
|
|
347
|
+
message_chunk_data = ['\0'] * 60
|
|
348
|
+
ret = write_low_level message_length, message_chunk_offset, message_chunk_data
|
|
349
|
+
message_written = ret
|
|
350
|
+
else
|
|
351
|
+
message_written = 0 # assigned in block
|
|
352
|
+
|
|
353
|
+
@stream_mutex.synchronize {
|
|
354
|
+
while message_chunk_offset < message_length
|
|
355
|
+
message_chunk_data = message[message_chunk_offset, 60]
|
|
356
|
+
|
|
357
|
+
if message_chunk_data.length < 60
|
|
358
|
+
message_chunk_data += ['\0'] * (60 - message_chunk_data.length)
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
ret = write_low_level message_length, message_chunk_offset, message_chunk_data
|
|
362
|
+
message_written += ret
|
|
363
|
+
|
|
364
|
+
if ret < 60
|
|
365
|
+
break # either last chunk or short write
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
message_chunk_offset += 60
|
|
369
|
+
end
|
|
370
|
+
}
|
|
371
|
+
end
|
|
372
|
+
|
|
373
|
+
message_written
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
# Returns up to *length* characters from receive buffer.
|
|
377
|
+
#
|
|
378
|
+
# Instead of polling with this function, you can also use
|
|
379
|
+
# callbacks. But note that this function will return available
|
|
380
|
+
# data only when the read callback is disabled.
|
|
381
|
+
# See BrickletRS232V2#enable_read_callback and CALLBACK_READ callback.
|
|
382
|
+
def read(length)
|
|
383
|
+
message_length = nil # assigned in block
|
|
384
|
+
message_data = nil # assigned in block
|
|
385
|
+
|
|
386
|
+
@stream_mutex.synchronize {
|
|
387
|
+
ret = read_low_level length
|
|
388
|
+
message_length = ret[0]
|
|
389
|
+
message_chunk_offset = ret[1]
|
|
390
|
+
message_out_of_sync = message_chunk_offset != 0
|
|
391
|
+
message_data = ret[2]
|
|
392
|
+
|
|
393
|
+
while not message_out_of_sync and message_data.length < message_length
|
|
394
|
+
ret = read_low_level length
|
|
395
|
+
message_length = ret[0]
|
|
396
|
+
message_chunk_offset = ret[1]
|
|
397
|
+
message_out_of_sync = message_chunk_offset != message_data.length
|
|
398
|
+
message_data += ret[2]
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
if message_out_of_sync # discard remaining stream to bring it back in-sync
|
|
402
|
+
while message_chunk_offset + 60 < message_length
|
|
403
|
+
ret = read_low_level length
|
|
404
|
+
message_length = ret[0]
|
|
405
|
+
message_chunk_offset = ret[1]
|
|
406
|
+
end
|
|
407
|
+
|
|
408
|
+
raise StreamOutOfSyncException, 'Message stream is out-of-sync'
|
|
409
|
+
end
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
message_data[0, message_length]
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
|
416
|
+
def register_callback(id, &block)
|
|
417
|
+
callback = block
|
|
418
|
+
@registered_callbacks[id] = callback
|
|
419
|
+
end
|
|
420
|
+
end
|
|
421
|
+
end
|