tinkerforge 2.1.8 → 2.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/tinkerforge/brick_dc.rb +2 -2
- data/lib/tinkerforge/brick_imu.rb +2 -2
- data/lib/tinkerforge/brick_imu_v2.rb +2 -2
- data/lib/tinkerforge/brick_master.rb +410 -20
- data/lib/tinkerforge/brick_red.rb +2 -2
- data/lib/tinkerforge/brick_servo.rb +2 -2
- data/lib/tinkerforge/brick_stepper.rb +2 -2
- 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_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 +289 -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_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_hall_effect.rb +2 -2
- data/lib/tinkerforge/bricklet_humidity.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
- data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
- 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_quad_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_io16.rb +3 -3
- data/lib/tinkerforge/bricklet_io4.rb +2 -2
- data/lib/tinkerforge/bricklet_joystick.rb +2 -2
- data/lib/tinkerforge/bricklet_laser_range_finder.rb +3 -3
- data/lib/tinkerforge/bricklet_lcd_16x2.rb +2 -2
- data/lib/tinkerforge/bricklet_lcd_20x4.rb +2 -2
- data/lib/tinkerforge/bricklet_led_strip.rb +3 -3
- 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_moisture.rb +2 -2
- data/lib/tinkerforge/bricklet_motion_detector.rb +2 -2
- data/lib/tinkerforge/bricklet_multi_touch.rb +3 -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_piezo_buzzer.rb +2 -2
- data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
- data/lib/tinkerforge/bricklet_ptc.rb +2 -2
- data/lib/tinkerforge/bricklet_real_time_clock.rb +96 -3
- data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
- data/lib/tinkerforge/bricklet_rgb_led.rb +59 -0
- data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
- data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
- data/lib/tinkerforge/bricklet_rs232.rb +2 -2
- data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
- data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
- data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature.rb +2 -2
- data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
- data/lib/tinkerforge/bricklet_thermocouple.rb +2 -2
- 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/version.rb +1 -1
- metadata +4 -2
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 #
|
@@ -0,0 +1,289 @@
|
|
1
|
+
# -*- ruby encoding: utf-8 -*-
|
2
|
+
#############################################################
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
|
+
# #
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 CAN bus devices
|
14
|
+
class BrickletCAN < Device
|
15
|
+
DEVICE_IDENTIFIER = 270 # :nodoc:
|
16
|
+
DEVICE_DISPLAY_NAME = 'CAN Bricklet' # :nodoc:
|
17
|
+
|
18
|
+
# This callback is triggered if a data or remote frame was received by the CAN
|
19
|
+
# transceiver.
|
20
|
+
#
|
21
|
+
# For remote frames the ``data`` return value always contains invalid values.
|
22
|
+
#
|
23
|
+
# A configurable read filter can be used to define which frames should be
|
24
|
+
# received by the CAN transceiver at all (see BrickletCAN#set_read_filter).
|
25
|
+
#
|
26
|
+
# To enable this callback, use BrickletCAN#enable_frame_read_callback.
|
27
|
+
CALLBACK_FRAME_READ = 11
|
28
|
+
|
29
|
+
FUNCTION_WRITE_FRAME = 1 # :nodoc:
|
30
|
+
FUNCTION_READ_FRAME = 2 # :nodoc:
|
31
|
+
FUNCTION_ENABLE_FRAME_READ_CALLBACK = 3 # :nodoc:
|
32
|
+
FUNCTION_DISABLE_FRAME_READ_CALLBACK = 4 # :nodoc:
|
33
|
+
FUNCTION_IS_FRAME_READ_CALLBACK_ENABLED = 5 # :nodoc:
|
34
|
+
FUNCTION_SET_CONFIGURATION = 6 # :nodoc:
|
35
|
+
FUNCTION_GET_CONFIGURATION = 7 # :nodoc:
|
36
|
+
FUNCTION_SET_READ_FILTER = 8 # :nodoc:
|
37
|
+
FUNCTION_GET_READ_FILTER = 9 # :nodoc:
|
38
|
+
FUNCTION_GET_ERROR_LOG = 10 # :nodoc:
|
39
|
+
FUNCTION_GET_IDENTITY = 255 # :nodoc:
|
40
|
+
|
41
|
+
FRAME_TYPE_STANDARD_DATA = 0 # :nodoc:
|
42
|
+
FRAME_TYPE_STANDARD_REMOTE = 1 # :nodoc:
|
43
|
+
FRAME_TYPE_EXTENDED_DATA = 2 # :nodoc:
|
44
|
+
FRAME_TYPE_EXTENDED_REMOTE = 3 # :nodoc:
|
45
|
+
BAUD_RATE_10KBPS = 0 # :nodoc:
|
46
|
+
BAUD_RATE_20KBPS = 1 # :nodoc:
|
47
|
+
BAUD_RATE_50KBPS = 2 # :nodoc:
|
48
|
+
BAUD_RATE_125KBPS = 3 # :nodoc:
|
49
|
+
BAUD_RATE_250KBPS = 4 # :nodoc:
|
50
|
+
BAUD_RATE_500KBPS = 5 # :nodoc:
|
51
|
+
BAUD_RATE_800KBPS = 6 # :nodoc:
|
52
|
+
BAUD_RATE_1000KBPS = 7 # :nodoc:
|
53
|
+
TRANSCEIVER_MODE_NORMAL = 0 # :nodoc:
|
54
|
+
TRANSCEIVER_MODE_LOOPBACK = 1 # :nodoc:
|
55
|
+
TRANSCEIVER_MODE_READ_ONLY = 2 # :nodoc:
|
56
|
+
FILTER_MODE_DISABLED = 0 # :nodoc:
|
57
|
+
FILTER_MODE_ACCEPT_ALL = 1 # :nodoc:
|
58
|
+
FILTER_MODE_MATCH_STANDARD = 2 # :nodoc:
|
59
|
+
FILTER_MODE_MATCH_STANDARD_AND_DATA = 3 # :nodoc:
|
60
|
+
FILTER_MODE_MATCH_EXTENDED = 4 # :nodoc:
|
61
|
+
|
62
|
+
# Creates an object with the unique device ID <tt>uid</tt> and adds it to
|
63
|
+
# the IP Connection <tt>ipcon</tt>.
|
64
|
+
def initialize(uid, ipcon)
|
65
|
+
super uid, ipcon
|
66
|
+
|
67
|
+
@api_version = [2, 0, 0]
|
68
|
+
|
69
|
+
@response_expected[FUNCTION_WRITE_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
70
|
+
@response_expected[FUNCTION_READ_FRAME] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
71
|
+
@response_expected[FUNCTION_ENABLE_FRAME_READ_CALLBACK] = RESPONSE_EXPECTED_TRUE
|
72
|
+
@response_expected[FUNCTION_DISABLE_FRAME_READ_CALLBACK] = RESPONSE_EXPECTED_TRUE
|
73
|
+
@response_expected[FUNCTION_IS_FRAME_READ_CALLBACK_ENABLED] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
74
|
+
@response_expected[FUNCTION_SET_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
|
75
|
+
@response_expected[FUNCTION_GET_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
76
|
+
@response_expected[FUNCTION_SET_READ_FILTER] = RESPONSE_EXPECTED_FALSE
|
77
|
+
@response_expected[FUNCTION_GET_READ_FILTER] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
78
|
+
@response_expected[FUNCTION_GET_ERROR_LOG] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
79
|
+
@response_expected[CALLBACK_FRAME_READ] = RESPONSE_EXPECTED_ALWAYS_FALSE
|
80
|
+
@response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
|
81
|
+
|
82
|
+
@callback_formats[CALLBACK_FRAME_READ] = 'C L C8 C'
|
83
|
+
end
|
84
|
+
|
85
|
+
# Writes a data or remote frame to the write buffer to be transmitted over the
|
86
|
+
# CAN transceiver.
|
87
|
+
#
|
88
|
+
# The Bricklet supports the standard 11-bit (CAN 2.0A) and the extended 29-bit
|
89
|
+
# (CAN 2.0B) identifiers. For remote frames the ``data`` parameter is ignored.
|
90
|
+
#
|
91
|
+
# Returns *true* if the frame was successfully added to the write buffer. Returns
|
92
|
+
# *false* if the frame could not be added because write buffer is already full.
|
93
|
+
#
|
94
|
+
# The write buffer can overflow if frames are written to it at a higher rate
|
95
|
+
# than the Bricklet can transmitted them over the CAN transceiver. This may
|
96
|
+
# happen if the CAN transceiver is configured as read-only or is using a low baud
|
97
|
+
# rate (see BrickletCAN#set_configuration). It can also happen if the CAN bus is
|
98
|
+
# congested and the frame cannot be transmitted because it constantly loses
|
99
|
+
# arbitration or because the CAN transceiver is currently disabled due to a high
|
100
|
+
# write error level (see BrickletCAN#get_error_log).
|
101
|
+
def write_frame(frame_type, identifier, data, length)
|
102
|
+
send_request(FUNCTION_WRITE_FRAME, [frame_type, identifier, data, length], 'C L C8 C', 1, '?')
|
103
|
+
end
|
104
|
+
|
105
|
+
# Tries to read the next data or remote frame from the read buffer and return it.
|
106
|
+
# If a frame was successfully read, then the ``success`` return value is set to
|
107
|
+
# *true* and the other return values contain the frame. If the read buffer is
|
108
|
+
# empty and no frame could be read, then the ``success`` return value is set to
|
109
|
+
# *false* and the other return values contain invalid data.
|
110
|
+
#
|
111
|
+
# For remote frames the ``data`` return value always contains invalid data.
|
112
|
+
#
|
113
|
+
# A configurable read filter can be used to define which frames should be
|
114
|
+
# received by the CAN transceiver and put into the read buffer (see
|
115
|
+
# BrickletCAN#set_read_filter).
|
116
|
+
#
|
117
|
+
# Instead of polling with this function, you can also use callbacks. See the
|
118
|
+
# BrickletCAN#enable_frame_read_callback function and the CALLBACK_FRAME_READ callback.
|
119
|
+
def read_frame
|
120
|
+
send_request(FUNCTION_READ_FRAME, [], '', 15, '? C L C8 C')
|
121
|
+
end
|
122
|
+
|
123
|
+
# Enables the CALLBACK_FRAME_READ callback.
|
124
|
+
#
|
125
|
+
# By default the callback is disabled.
|
126
|
+
def enable_frame_read_callback
|
127
|
+
send_request(FUNCTION_ENABLE_FRAME_READ_CALLBACK, [], '', 0, '')
|
128
|
+
end
|
129
|
+
|
130
|
+
# Disables the CALLBACK_FRAME_READ callback.
|
131
|
+
#
|
132
|
+
# By default the callback is disabled.
|
133
|
+
def disable_frame_read_callback
|
134
|
+
send_request(FUNCTION_DISABLE_FRAME_READ_CALLBACK, [], '', 0, '')
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns *true* if the CALLBACK_FRAME_READ callback is enabled, *false* otherwise.
|
138
|
+
def is_frame_read_callback_enabled
|
139
|
+
send_request(FUNCTION_IS_FRAME_READ_CALLBACK_ENABLED, [], '', 1, '?')
|
140
|
+
end
|
141
|
+
|
142
|
+
# Sets the configuration for the CAN bus communication.
|
143
|
+
#
|
144
|
+
# The baud rate can be configured in steps between 10 and 1000 kbit/s.
|
145
|
+
#
|
146
|
+
# The CAN transceiver has three different modes:
|
147
|
+
#
|
148
|
+
# * Normal: Reads from and writes and to the CAN bus and performs active bus
|
149
|
+
# error detection and acknowledgement.
|
150
|
+
# * Loopback: All reads and writes are performed internally. The transceiver
|
151
|
+
# is disconnected from the actual CAN bus.
|
152
|
+
# * Read-Only: Only reads from the CAN bus, but does neither active bus error
|
153
|
+
# detection nor acknowledgement. Only the receiving part of the transceiver
|
154
|
+
# is connected to the CAN bus.
|
155
|
+
#
|
156
|
+
# The write timeout has three different modes that define how a failed frame
|
157
|
+
# transmission should be handled:
|
158
|
+
#
|
159
|
+
# * One-Shot (< 0): Only one transmission attempt will be made. If the
|
160
|
+
# transmission fails then the frame is discarded.
|
161
|
+
# * Infinite (= 0): Infinite transmission attempts will be made. The frame will
|
162
|
+
# never be discarded.
|
163
|
+
# * Milliseconds (> 0): A limited number of transmission attempts will be made.
|
164
|
+
# If the frame could not be transmitted successfully after the configured
|
165
|
+
# number of milliseconds then the frame is discarded.
|
166
|
+
#
|
167
|
+
# The default is: 125 kbit/s, normal transceiver mode and infinite write timeout.
|
168
|
+
def set_configuration(baud_rate, transceiver_mode, write_timeout)
|
169
|
+
send_request(FUNCTION_SET_CONFIGURATION, [baud_rate, transceiver_mode, write_timeout], 'C C l', 0, '')
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the configuration as set by BrickletCAN#set_configuration.
|
173
|
+
def get_configuration
|
174
|
+
send_request(FUNCTION_GET_CONFIGURATION, [], '', 6, 'C C l')
|
175
|
+
end
|
176
|
+
|
177
|
+
# Set the read filter configuration. This can be used to define which frames
|
178
|
+
# should be received by the CAN transceiver and put into the read buffer.
|
179
|
+
#
|
180
|
+
# The read filter has five different modes that define if and how the mask and
|
181
|
+
# the two filters are applied:
|
182
|
+
#
|
183
|
+
# * Disabled: No filtering is applied at all. All frames are received even
|
184
|
+
# incomplete and defective frames. This mode should be used for debugging only.
|
185
|
+
# * Accept-All: All complete and error-free frames are received.
|
186
|
+
# * Match-Standard: Only standard frames with a matching identifier are received.
|
187
|
+
# * Match-Standard-and-Data: Only standard frames with matching identifier and
|
188
|
+
# data bytes are received.
|
189
|
+
# * Match-Extended: Only extended frames with a matching identifier are received.
|
190
|
+
#
|
191
|
+
# The mask and filters are used as bit masks. Their usage depends on the mode:
|
192
|
+
#
|
193
|
+
# * Disabled: Mask and filters are ignored.
|
194
|
+
# * Accept-All: Mask and filters are ignored.
|
195
|
+
# * Match-Standard: Bit 0 to 10 (11 bits) of mask and filters are used to match
|
196
|
+
# the 11-bit identifier of standard frames.
|
197
|
+
# * Match-Standard-and-Data: Bit 0 to 10 (11 bits) of mask and filters are used
|
198
|
+
# to match the 11-bit identifier of standard frames. Bit 11 to 18 (8 bits) and
|
199
|
+
# bit 19 to 26 (8 bits) of mask and filters are used to match the first and
|
200
|
+
# second data byte (if present) of standard frames.
|
201
|
+
# * Match-Extended: Bit 0 to 28 (29 bits) of mask and filters are used to match
|
202
|
+
# the 29-bit identifier of extended frames.
|
203
|
+
#
|
204
|
+
# The mask and filters are applied in this way: The mask is used to select the
|
205
|
+
# identifier and data bits that should be compared to the corresponding filter
|
206
|
+
# bits. All unselected bits are automatically accepted. All selected bits have
|
207
|
+
# to match one of the filters to be accepted. If all bits for the selected mode
|
208
|
+
# are accepted then the frame is accepted and is added to the read buffer.
|
209
|
+
#
|
210
|
+
# "Mask Bit", "Filter Bit", "Identifier/Data Bit", "Result"
|
211
|
+
#
|
212
|
+
# 0, X, X, Accept
|
213
|
+
# 1, 0, 0, Accept
|
214
|
+
# 1, 0, 1, Reject
|
215
|
+
# 1, 1, 0, Reject
|
216
|
+
# 1, 1, 1, Accept
|
217
|
+
#
|
218
|
+
# For example, to receive standard frames with identifier 0x123 only the mode can
|
219
|
+
# be set to Match-Standard with 0x7FF as mask and 0x123 as filter 1 and filter 2.
|
220
|
+
# The mask of 0x7FF selects all 11 identifier bits for matching so that the
|
221
|
+
# identifier has to be exactly 0x123 to be accepted.
|
222
|
+
#
|
223
|
+
# To accept identifier 0x123 and identifier 0x456 at the same time, just set
|
224
|
+
# filter 2 to 0x456 and keep mask and filter 1 unchanged.
|
225
|
+
#
|
226
|
+
# The default mode is accept-all.
|
227
|
+
def set_read_filter(mode, mask, filter1, filter2)
|
228
|
+
send_request(FUNCTION_SET_READ_FILTER, [mode, mask, filter1, filter2], 'C L L L', 0, '')
|
229
|
+
end
|
230
|
+
|
231
|
+
# Returns the read filter as set by BrickletCAN#set_read_filter.
|
232
|
+
def get_read_filter
|
233
|
+
send_request(FUNCTION_GET_READ_FILTER, [], '', 13, 'C L L L')
|
234
|
+
end
|
235
|
+
|
236
|
+
# Returns information about different kinds of errors.
|
237
|
+
#
|
238
|
+
# The write and read error levels indicate the current level of checksum,
|
239
|
+
# acknowledgement, form, bit and stuffing errors during CAN bus write and read
|
240
|
+
# operations.
|
241
|
+
#
|
242
|
+
# When the write error level extends 255 then the CAN transceiver gets disabled
|
243
|
+
# and no frames can be transmitted or received anymore. The CAN transceiver will
|
244
|
+
# automatically be activated again after the CAN bus is idle for a while.
|
245
|
+
#
|
246
|
+
# The write and read error levels are not available in read-only transceiver mode
|
247
|
+
# (see BrickletCAN#set_configuration) and are reset to 0 as a side effect of changing
|
248
|
+
# the configuration or the read filter.
|
249
|
+
#
|
250
|
+
# The write timeout, read register and buffer overflow counts represents the
|
251
|
+
# number of these errors:
|
252
|
+
#
|
253
|
+
# * A write timeout occurs if a frame could not be transmitted before the
|
254
|
+
# configured write timeout expired (see BrickletCAN#set_configuration).
|
255
|
+
# * A read register overflow occurs if the read register of the CAN transceiver
|
256
|
+
# still contains the last received frame when the next frame arrives. In this
|
257
|
+
# case the newly arrived frame is lost. This happens if the CAN transceiver
|
258
|
+
# receives more frames than the Bricklet can handle. Using the read filter
|
259
|
+
# (see BrickletCAN#set_read_filter) can help to reduce the amount of received frames.
|
260
|
+
# * A read buffer overflow occurs if the read buffer of the Bricklet is already
|
261
|
+
# full when the next frame should be read from the read register of the CAN
|
262
|
+
# transceiver. In this case the frame in the read register is lost. This
|
263
|
+
# happens if the CAN transceiver receives more frames to be added to the read
|
264
|
+
# buffer than are removed from the read buffer using the BrickletCAN#read_frame
|
265
|
+
# function. Using the CALLBACK_FRAME_READ callback ensures that the read buffer
|
266
|
+
# can not overflow.
|
267
|
+
def get_error_log
|
268
|
+
send_request(FUNCTION_GET_ERROR_LOG, [], '', 15, 'C C ? L L L')
|
269
|
+
end
|
270
|
+
|
271
|
+
# Returns the UID, the UID where the Bricklet is connected to,
|
272
|
+
# the position, the hardware and firmware version as well as the
|
273
|
+
# device identifier.
|
274
|
+
#
|
275
|
+
# The position can be 'a', 'b', 'c' or 'd'.
|
276
|
+
#
|
277
|
+
# The device identifier numbers can be found :ref:`here <device_identifier>`.
|
278
|
+
# |device_identifier_constant|
|
279
|
+
def get_identity
|
280
|
+
send_request(FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S')
|
281
|
+
end
|
282
|
+
|
283
|
+
# Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
|
284
|
+
def register_callback(id, &block)
|
285
|
+
callback = block
|
286
|
+
@registered_callbacks[id] = callback
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
# -*- ruby encoding: utf-8 -*-
|
2
2
|
#############################################################
|
3
|
-
# This file was automatically generated on 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 2016-
|
3
|
+
# This file was automatically generated on 2016-06-30. #
|
4
4
|
# #
|
5
|
-
# Ruby Bindings Version 2.1.
|
5
|
+
# Ruby Bindings Version 2.1.9 #
|
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 #
|