tinkerforge 2.1.16 → 2.1.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tinkerforge/brick_dc.rb +3 -3
  3. data/lib/tinkerforge/brick_imu.rb +3 -3
  4. data/lib/tinkerforge/brick_imu_v2.rb +3 -3
  5. data/lib/tinkerforge/brick_master.rb +3 -3
  6. data/lib/tinkerforge/brick_red.rb +2 -2
  7. data/lib/tinkerforge/brick_servo.rb +3 -3
  8. data/lib/tinkerforge/brick_silent_stepper.rb +3 -3
  9. data/lib/tinkerforge/brick_stepper.rb +3 -3
  10. data/lib/tinkerforge/bricklet_accelerometer.rb +2 -2
  11. data/lib/tinkerforge/bricklet_ambient_light.rb +2 -2
  12. data/lib/tinkerforge/bricklet_ambient_light_v2.rb +2 -2
  13. data/lib/tinkerforge/bricklet_analog_in.rb +2 -2
  14. data/lib/tinkerforge/bricklet_analog_in_v2.rb +2 -2
  15. data/lib/tinkerforge/bricklet_analog_in_v3.rb +5 -6
  16. data/lib/tinkerforge/bricklet_analog_out.rb +2 -2
  17. data/lib/tinkerforge/bricklet_analog_out_v2.rb +2 -2
  18. data/lib/tinkerforge/bricklet_barometer.rb +2 -2
  19. data/lib/tinkerforge/bricklet_can.rb +3 -3
  20. data/lib/tinkerforge/bricklet_can_v2.rb +770 -0
  21. data/lib/tinkerforge/bricklet_co2.rb +2 -2
  22. data/lib/tinkerforge/bricklet_color.rb +2 -2
  23. data/lib/tinkerforge/bricklet_current12.rb +2 -2
  24. data/lib/tinkerforge/bricklet_current25.rb +2 -2
  25. data/lib/tinkerforge/bricklet_distance_ir.rb +2 -2
  26. data/lib/tinkerforge/bricklet_distance_us.rb +2 -2
  27. data/lib/tinkerforge/bricklet_dmx.rb +3 -3
  28. data/lib/tinkerforge/bricklet_dual_button.rb +2 -2
  29. data/lib/tinkerforge/bricklet_dual_relay.rb +2 -2
  30. data/lib/tinkerforge/bricklet_dust_detector.rb +2 -2
  31. data/lib/tinkerforge/bricklet_gps.rb +2 -2
  32. data/lib/tinkerforge/bricklet_gps_v2.rb +3 -3
  33. data/lib/tinkerforge/bricklet_hall_effect.rb +2 -2
  34. data/lib/tinkerforge/bricklet_humidity.rb +2 -2
  35. data/lib/tinkerforge/bricklet_humidity_v2.rb +11 -13
  36. data/lib/tinkerforge/bricklet_industrial_analog_out.rb +2 -2
  37. data/lib/tinkerforge/bricklet_industrial_counter.rb +445 -0
  38. data/lib/tinkerforge/bricklet_industrial_digital_in_4.rb +2 -2
  39. data/lib/tinkerforge/bricklet_industrial_digital_in_4_v2.rb +342 -0
  40. data/lib/tinkerforge/bricklet_industrial_digital_out_4.rb +2 -2
  41. data/lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb +2 -2
  42. data/lib/tinkerforge/bricklet_industrial_dual_analog_in.rb +2 -2
  43. data/lib/tinkerforge/bricklet_industrial_dual_relay.rb +263 -0
  44. data/lib/tinkerforge/bricklet_industrial_quad_relay.rb +2 -2
  45. data/lib/tinkerforge/bricklet_industrial_quad_relay_v2.rb +281 -0
  46. data/lib/tinkerforge/bricklet_io16.rb +2 -2
  47. data/lib/tinkerforge/bricklet_io4.rb +2 -2
  48. data/lib/tinkerforge/bricklet_io4_v2.rb +437 -0
  49. data/lib/tinkerforge/bricklet_joystick.rb +2 -2
  50. data/lib/tinkerforge/bricklet_laser_range_finder.rb +2 -2
  51. data/lib/tinkerforge/bricklet_lcd_16x2.rb +3 -3
  52. data/lib/tinkerforge/bricklet_lcd_20x4.rb +3 -3
  53. data/lib/tinkerforge/bricklet_led_strip.rb +2 -2
  54. data/lib/tinkerforge/bricklet_led_strip_v2.rb +493 -0
  55. data/lib/tinkerforge/bricklet_line.rb +2 -2
  56. data/lib/tinkerforge/bricklet_linear_poti.rb +2 -2
  57. data/lib/tinkerforge/bricklet_load_cell.rb +2 -2
  58. data/lib/tinkerforge/bricklet_load_cell_v2.rb +354 -0
  59. data/lib/tinkerforge/bricklet_moisture.rb +2 -2
  60. data/lib/tinkerforge/bricklet_motion_detector.rb +3 -3
  61. data/lib/tinkerforge/bricklet_motion_detector_v2.rb +2 -2
  62. data/lib/tinkerforge/bricklet_motorized_linear_poti.rb +5 -6
  63. data/lib/tinkerforge/bricklet_multi_touch.rb +2 -2
  64. data/lib/tinkerforge/bricklet_nfc.rb +39 -3
  65. data/lib/tinkerforge/bricklet_nfc_rfid.rb +2 -2
  66. data/lib/tinkerforge/bricklet_oled_128x64.rb +2 -2
  67. data/lib/tinkerforge/bricklet_oled_64x48.rb +2 -2
  68. data/lib/tinkerforge/bricklet_outdoor_weather.rb +2 -2
  69. data/lib/tinkerforge/bricklet_particulate_matter.rb +320 -0
  70. data/lib/tinkerforge/bricklet_piezo_buzzer.rb +2 -2
  71. data/lib/tinkerforge/bricklet_piezo_speaker.rb +2 -2
  72. data/lib/tinkerforge/bricklet_ptc.rb +33 -3
  73. data/lib/tinkerforge/bricklet_ptc_v2.rb +433 -0
  74. data/lib/tinkerforge/bricklet_real_time_clock.rb +2 -2
  75. data/lib/tinkerforge/bricklet_real_time_clock_v2.rb +353 -0
  76. data/lib/tinkerforge/bricklet_remote_switch.rb +2 -2
  77. data/lib/tinkerforge/bricklet_remote_switch_v2.rb +2 -2
  78. data/lib/tinkerforge/bricklet_rgb_led.rb +2 -2
  79. data/lib/tinkerforge/bricklet_rgb_led_button.rb +2 -2
  80. data/lib/tinkerforge/bricklet_rgb_led_matrix.rb +2 -2
  81. data/lib/tinkerforge/bricklet_rotary_encoder.rb +2 -2
  82. data/lib/tinkerforge/bricklet_rotary_encoder_v2.rb +8 -9
  83. data/lib/tinkerforge/bricklet_rotary_poti.rb +2 -2
  84. data/lib/tinkerforge/bricklet_rs232.rb +3 -3
  85. data/lib/tinkerforge/bricklet_rs232_v2.rb +421 -0
  86. data/lib/tinkerforge/bricklet_rs485.rb +6 -6
  87. data/lib/tinkerforge/bricklet_segment_display_4x7.rb +2 -2
  88. data/lib/tinkerforge/bricklet_solid_state_relay.rb +2 -2
  89. data/lib/tinkerforge/bricklet_solid_state_relay_v2.rb +3 -3
  90. data/lib/tinkerforge/bricklet_sound_intensity.rb +2 -2
  91. data/lib/tinkerforge/bricklet_sound_pressure_level.rb +420 -0
  92. data/lib/tinkerforge/bricklet_temperature.rb +3 -3
  93. data/lib/tinkerforge/bricklet_temperature_ir.rb +2 -2
  94. data/lib/tinkerforge/bricklet_temperature_ir_v2.rb +13 -15
  95. data/lib/tinkerforge/bricklet_thermal_imaging.rb +2 -2
  96. data/lib/tinkerforge/bricklet_thermocouple.rb +4 -4
  97. data/lib/tinkerforge/bricklet_thermocouple_v2.rb +340 -0
  98. data/lib/tinkerforge/bricklet_tilt.rb +2 -2
  99. data/lib/tinkerforge/bricklet_uv_light.rb +2 -2
  100. data/lib/tinkerforge/bricklet_voltage.rb +2 -2
  101. data/lib/tinkerforge/bricklet_voltage_current.rb +2 -2
  102. data/lib/tinkerforge/bricklet_voltage_current_v2.rb +453 -0
  103. data/lib/tinkerforge/ip_connection.rb +4 -4
  104. data/lib/tinkerforge/version.rb +1 -1
  105. metadata +17 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7ad537e60f699af8ac4f2758a2d369f49b9ef617
4
- data.tar.gz: fce6800517170a6dd09b1e1368a3723fa56e0764
3
+ metadata.gz: 617ee249ffa5abe4ff9e12e178bee3ede5fcb248
4
+ data.tar.gz: b5f84ca2e34947f1dae73738c4349d2eba41162b
5
5
  SHA512:
6
- metadata.gz: 70ca95c498ac5f5d2cb54d00f0a049201f9a72f48f684b4799c396355252c14bcf0f6146dd73d03dbe759d83fc9228158cb1f595d6b174de8710fb4081585158
7
- data.tar.gz: 85c8609e7e54fe1338a84f584879ec5682eeb66bdfc42de8475b651204b891517aef972c791d4f7253069bfe3ee600f9600b9c87369dd704608942218347baad
6
+ metadata.gz: 3bc085806cd7fd14670cea29d29b5fbe2e030cf7b4d5f5739abb13a6ec519b779387c3377b311664fa2e3b8839d720bd652789f9fc7ed0ef850a86947e0a6860
7
+ data.tar.gz: ad8b5ea516151373147e4b5d3351732ba6cb97ed1f63e4e1cd16cf01f7c742b01144a0c37801d985652fade40fc5cfaee24126373d1e4806230d7138065388a5
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -106,7 +106,7 @@ module Tinkerforge
106
106
  def initialize(uid, ipcon)
107
107
  super uid, ipcon
108
108
 
109
- @api_version = [2, 0, 0]
109
+ @api_version = [2, 0, 3]
110
110
 
111
111
  @response_expected[FUNCTION_SET_VELOCITY] = RESPONSE_EXPECTED_FALSE
112
112
  @response_expected[FUNCTION_GET_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -115,7 +115,7 @@ module Tinkerforge
115
115
  def initialize(uid, ipcon)
116
116
  super uid, ipcon
117
117
 
118
- @api_version = [2, 0, 1]
118
+ @api_version = [2, 0, 4]
119
119
 
120
120
  @response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
121
121
  @response_expected[FUNCTION_GET_MAGNETIC_FIELD] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -160,7 +160,7 @@ module Tinkerforge
160
160
  def initialize(uid, ipcon)
161
161
  super uid, ipcon
162
162
 
163
- @api_version = [2, 0, 1]
163
+ @api_version = [2, 0, 3]
164
164
 
165
165
  @response_expected[FUNCTION_GET_ACCELERATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
166
166
  @response_expected[FUNCTION_GET_MAGNETIC_FIELD] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -288,7 +288,7 @@ module Tinkerforge
288
288
  def initialize(uid, ipcon)
289
289
  super uid, ipcon
290
290
 
291
- @api_version = [2, 0, 4]
291
+ @api_version = [2, 0, 9]
292
292
 
293
293
  @response_expected[FUNCTION_GET_STACK_VOLTAGE] = RESPONSE_EXPECTED_ALWAYS_TRUE
294
294
  @response_expected[FUNCTION_GET_STACK_CURRENT] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -103,7 +103,7 @@ module Tinkerforge
103
103
  def initialize(uid, ipcon)
104
104
  super uid, ipcon
105
105
 
106
- @api_version = [2, 0, 1]
106
+ @api_version = [2, 0, 4]
107
107
 
108
108
  @response_expected[FUNCTION_ENABLE] = RESPONSE_EXPECTED_FALSE
109
109
  @response_expected[FUNCTION_DISABLE] = RESPONSE_EXPECTED_FALSE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -155,7 +155,7 @@ module Tinkerforge
155
155
  def initialize(uid, ipcon)
156
156
  super uid, ipcon
157
157
 
158
- @api_version = [2, 0, 0]
158
+ @api_version = [2, 0, 1]
159
159
 
160
160
  @response_expected[FUNCTION_SET_MAX_VELOCITY] = RESPONSE_EXPECTED_FALSE
161
161
  @response_expected[FUNCTION_GET_MAX_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -115,7 +115,7 @@ module Tinkerforge
115
115
  def initialize(uid, ipcon)
116
116
  super uid, ipcon
117
117
 
118
- @api_version = [2, 0, 0]
118
+ @api_version = [2, 0, 4]
119
119
 
120
120
  @response_expected[FUNCTION_SET_MAX_VELOCITY] = RESPONSE_EXPECTED_FALSE
121
121
  @response_expected[FUNCTION_GET_MAX_VELOCITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -16,9 +16,9 @@ module Tinkerforge
16
16
  DEVICE_DISPLAY_NAME = 'Analog In Bricklet 3.0' # :nodoc:
17
17
 
18
18
  # This callback is triggered periodically according to the configuration set by
19
- # BrickletAnalogInV3#set_voltage_callback_configuration.
19
+ # BrickletAnalogInV3#set_voltage_callback_configuration.
20
20
  #
21
- # The `parameter` is the same as BrickletAnalogInV3#get_voltage.
21
+ # The parameter is the same as BrickletAnalogInV3#get_voltage.
22
22
  CALLBACK_VOLTAGE = 4
23
23
 
24
24
  FUNCTION_GET_VOLTAGE = 1 # :nodoc:
@@ -135,11 +135,10 @@ module Tinkerforge
135
135
  #
136
136
  # "'x'", "Threshold is turned off"
137
137
  # "'o'", "Threshold is triggered when the value is *outside* the min and max values"
138
- # "'i'", "Threshold is triggered when the value is *inside* the min and max values"
138
+ # "'i'", "Threshold is triggered when the value is *inside* or equal to the min and max values"
139
139
  # "'<'", "Threshold is triggered when the value is smaller than the min value (max is ignored)"
140
140
  # "'>'", "Threshold is triggered when the value is greater than the min value (max is ignored)"
141
141
  #
142
- #
143
142
  # If the option is set to 'x' (threshold turned off) the callback is triggered with the fixed period.
144
143
  #
145
144
  # The default value is (0, false, 'x', 0, 0).
@@ -1,8 +1,8 @@
1
1
  # -*- ruby encoding: utf-8 -*-
2
2
  #############################################################
3
- # This file was automatically generated on 2018-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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-02-28. #
3
+ # This file was automatically generated on 2018-06-08. #
4
4
  # #
5
- # Ruby Bindings Version 2.1.16 #
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 #
@@ -156,7 +156,7 @@ module Tinkerforge
156
156
  #
157
157
  # The CAN transceiver has three different modes:
158
158
  #
159
- # * Normal: Reads from and writes and to the CAN bus and performs active bus
159
+ # * Normal: Reads from and writes to the CAN bus and performs active bus
160
160
  # error detection and acknowledgement.
161
161
  # * Loopback: All reads and writes are performed internally. The transceiver
162
162
  # is disconnected from the actual CAN bus.
@@ -0,0 +1,770 @@
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 CAN bus devices
14
+ class BrickletCANV2 < Device
15
+ DEVICE_IDENTIFIER = 2107 # :nodoc:
16
+ DEVICE_DISPLAY_NAME = 'CAN Bricklet 2.0' # :nodoc:
17
+
18
+ # This callback is triggered if a data or remote frame was received by the CAN
19
+ # transceiver.
20
+ #
21
+ # The ``identifier`` return value follows the identifier format described for
22
+ # BrickletCANV2#write_frame.
23
+ #
24
+ # For details on the ``data`` return value see BrickletCANV2#read_frame.
25
+ #
26
+ # A configurable read filter can be used to define which frames should be
27
+ # received by the CAN transceiver and put into the read queue (see
28
+ # BrickletCANV2#set_queue_configuration).
29
+ #
30
+ # To enable this callback, use BrickletCANV2#set_frame_read_callback_configuration.
31
+ CALLBACK_FRAME_READ_LOW_LEVEL = 16
32
+
33
+ # This callback is triggered if a data or remote frame was received by the CAN
34
+ # transceiver.
35
+ #
36
+ # The ``identifier`` return value follows the identifier format described for
37
+ # BrickletCANV2#write_frame.
38
+ #
39
+ # For details on the ``data`` return value see BrickletCANV2#read_frame.
40
+ #
41
+ # A configurable read filter can be used to define which frames should be
42
+ # received by the CAN transceiver and put into the read queue (see
43
+ # BrickletCANV2#set_queue_configuration).
44
+ #
45
+ # To enable this callback, use BrickletCANV2#set_frame_read_callback_configuration.
46
+ CALLBACK_FRAME_READ = -16
47
+
48
+ FUNCTION_WRITE_FRAME_LOW_LEVEL = 1 # :nodoc:
49
+ FUNCTION_READ_FRAME_LOW_LEVEL = 2 # :nodoc:
50
+ FUNCTION_SET_FRAME_READ_CALLBACK_CONFIGURATION = 3 # :nodoc:
51
+ FUNCTION_GET_FRAME_READ_CALLBACK_CONFIGURATION = 4 # :nodoc:
52
+ FUNCTION_SET_TRANSCEIVER_CONFIGURATION = 5 # :nodoc:
53
+ FUNCTION_GET_TRANSCEIVER_CONFIGURATION = 6 # :nodoc:
54
+ FUNCTION_SET_QUEUE_CONFIGURATION_LOW_LEVEL = 7 # :nodoc:
55
+ FUNCTION_GET_QUEUE_CONFIGURATION_LOW_LEVEL = 8 # :nodoc:
56
+ FUNCTION_SET_READ_FILTER_CONFIGURATION = 9 # :nodoc:
57
+ FUNCTION_GET_READ_FILTER_CONFIGURATION = 10 # :nodoc:
58
+ FUNCTION_GET_ERROR_LOG_LOW_LEVEL = 11 # :nodoc:
59
+ FUNCTION_SET_COMMUNICATION_LED_CONFIG = 12 # :nodoc:
60
+ FUNCTION_GET_COMMUNICATION_LED_CONFIG = 13 # :nodoc:
61
+ FUNCTION_SET_ERROR_LED_CONFIG = 14 # :nodoc:
62
+ FUNCTION_GET_ERROR_LED_CONFIG = 15 # :nodoc:
63
+ FUNCTION_GET_SPITFP_ERROR_COUNT = 234 # :nodoc:
64
+ FUNCTION_SET_BOOTLOADER_MODE = 235 # :nodoc:
65
+ FUNCTION_GET_BOOTLOADER_MODE = 236 # :nodoc:
66
+ FUNCTION_SET_WRITE_FIRMWARE_POINTER = 237 # :nodoc:
67
+ FUNCTION_WRITE_FIRMWARE = 238 # :nodoc:
68
+ FUNCTION_SET_STATUS_LED_CONFIG = 239 # :nodoc:
69
+ FUNCTION_GET_STATUS_LED_CONFIG = 240 # :nodoc:
70
+ FUNCTION_GET_CHIP_TEMPERATURE = 242 # :nodoc:
71
+ FUNCTION_RESET = 243 # :nodoc:
72
+ FUNCTION_WRITE_UID = 248 # :nodoc:
73
+ FUNCTION_READ_UID = 249 # :nodoc:
74
+ FUNCTION_GET_IDENTITY = 255 # :nodoc:
75
+
76
+ FRAME_TYPE_STANDARD_DATA = 0 # :nodoc:
77
+ FRAME_TYPE_STANDARD_REMOTE = 1 # :nodoc:
78
+ FRAME_TYPE_EXTENDED_DATA = 2 # :nodoc:
79
+ FRAME_TYPE_EXTENDED_REMOTE = 3 # :nodoc:
80
+ TRANSCEIVER_MODE_NORMAL = 0 # :nodoc:
81
+ TRANSCEIVER_MODE_LOOPBACK = 1 # :nodoc:
82
+ TRANSCEIVER_MODE_READ_ONLY = 2 # :nodoc:
83
+ FILTER_MODE_ACCEPT_ALL = 0 # :nodoc:
84
+ FILTER_MODE_MATCH_STANDARD_ONLY = 1 # :nodoc:
85
+ FILTER_MODE_MATCH_EXTENDED_ONLY = 2 # :nodoc:
86
+ FILTER_MODE_MATCH_STANDARD_AND_EXTENDED = 3 # :nodoc:
87
+ TRANSCEIVER_STATE_ACTIVE = 0 # :nodoc:
88
+ TRANSCEIVER_STATE_PASSIVE = 1 # :nodoc:
89
+ TRANSCEIVER_STATE_DISABLED = 2 # :nodoc:
90
+ COMMUNICATION_LED_CONFIG_OFF = 0 # :nodoc:
91
+ COMMUNICATION_LED_CONFIG_ON = 1 # :nodoc:
92
+ COMMUNICATION_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
93
+ COMMUNICATION_LED_CONFIG_SHOW_COMMUNICATION = 3 # :nodoc:
94
+ ERROR_LED_CONFIG_OFF = 0 # :nodoc:
95
+ ERROR_LED_CONFIG_ON = 1 # :nodoc:
96
+ ERROR_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
97
+ ERROR_LED_CONFIG_SHOW_TRANSCEIVER_STATE = 3 # :nodoc:
98
+ ERROR_LED_CONFIG_SHOW_ERROR = 4 # :nodoc:
99
+ BOOTLOADER_MODE_BOOTLOADER = 0 # :nodoc:
100
+ BOOTLOADER_MODE_FIRMWARE = 1 # :nodoc:
101
+ BOOTLOADER_MODE_BOOTLOADER_WAIT_FOR_REBOOT = 2 # :nodoc:
102
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_REBOOT = 3 # :nodoc:
103
+ BOOTLOADER_MODE_FIRMWARE_WAIT_FOR_ERASE_AND_REBOOT = 4 # :nodoc:
104
+ BOOTLOADER_STATUS_OK = 0 # :nodoc:
105
+ BOOTLOADER_STATUS_INVALID_MODE = 1 # :nodoc:
106
+ BOOTLOADER_STATUS_NO_CHANGE = 2 # :nodoc:
107
+ BOOTLOADER_STATUS_ENTRY_FUNCTION_NOT_PRESENT = 3 # :nodoc:
108
+ BOOTLOADER_STATUS_DEVICE_IDENTIFIER_INCORRECT = 4 # :nodoc:
109
+ BOOTLOADER_STATUS_CRC_MISMATCH = 5 # :nodoc:
110
+ STATUS_LED_CONFIG_OFF = 0 # :nodoc:
111
+ STATUS_LED_CONFIG_ON = 1 # :nodoc:
112
+ STATUS_LED_CONFIG_SHOW_HEARTBEAT = 2 # :nodoc:
113
+ STATUS_LED_CONFIG_SHOW_STATUS = 3 # :nodoc:
114
+
115
+ # Creates an object with the unique device ID <tt>uid</tt> and adds it to
116
+ # the IP Connection <tt>ipcon</tt>.
117
+ def initialize(uid, ipcon)
118
+ super uid, ipcon
119
+
120
+ @api_version = [2, 0, 0]
121
+
122
+ @response_expected[FUNCTION_WRITE_FRAME_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
123
+ @response_expected[FUNCTION_READ_FRAME_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
124
+ @response_expected[FUNCTION_SET_FRAME_READ_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_TRUE
125
+ @response_expected[FUNCTION_GET_FRAME_READ_CALLBACK_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
126
+ @response_expected[FUNCTION_SET_TRANSCEIVER_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
127
+ @response_expected[FUNCTION_GET_TRANSCEIVER_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
128
+ @response_expected[FUNCTION_SET_QUEUE_CONFIGURATION_LOW_LEVEL] = RESPONSE_EXPECTED_TRUE
129
+ @response_expected[FUNCTION_GET_QUEUE_CONFIGURATION_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
130
+ @response_expected[FUNCTION_SET_READ_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_FALSE
131
+ @response_expected[FUNCTION_GET_READ_FILTER_CONFIGURATION] = RESPONSE_EXPECTED_ALWAYS_TRUE
132
+ @response_expected[FUNCTION_GET_ERROR_LOG_LOW_LEVEL] = RESPONSE_EXPECTED_ALWAYS_TRUE
133
+ @response_expected[FUNCTION_SET_COMMUNICATION_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
134
+ @response_expected[FUNCTION_GET_COMMUNICATION_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
135
+ @response_expected[FUNCTION_SET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
136
+ @response_expected[FUNCTION_GET_ERROR_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
137
+ @response_expected[FUNCTION_GET_SPITFP_ERROR_COUNT] = RESPONSE_EXPECTED_ALWAYS_TRUE
138
+ @response_expected[FUNCTION_SET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
139
+ @response_expected[FUNCTION_GET_BOOTLOADER_MODE] = RESPONSE_EXPECTED_ALWAYS_TRUE
140
+ @response_expected[FUNCTION_SET_WRITE_FIRMWARE_POINTER] = RESPONSE_EXPECTED_FALSE
141
+ @response_expected[FUNCTION_WRITE_FIRMWARE] = RESPONSE_EXPECTED_ALWAYS_TRUE
142
+ @response_expected[FUNCTION_SET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_FALSE
143
+ @response_expected[FUNCTION_GET_STATUS_LED_CONFIG] = RESPONSE_EXPECTED_ALWAYS_TRUE
144
+ @response_expected[FUNCTION_GET_CHIP_TEMPERATURE] = RESPONSE_EXPECTED_ALWAYS_TRUE
145
+ @response_expected[FUNCTION_RESET] = RESPONSE_EXPECTED_FALSE
146
+ @response_expected[FUNCTION_WRITE_UID] = RESPONSE_EXPECTED_FALSE
147
+ @response_expected[FUNCTION_READ_UID] = RESPONSE_EXPECTED_ALWAYS_TRUE
148
+ @response_expected[FUNCTION_GET_IDENTITY] = RESPONSE_EXPECTED_ALWAYS_TRUE
149
+
150
+ @callback_formats[CALLBACK_FRAME_READ_LOW_LEVEL] = 'C L C C15'
151
+
152
+ @high_level_callbacks[CALLBACK_FRAME_READ] = [[nil, nil, 'stream_length', 'stream_chunk_data'], {'fixed_length' => nil, 'single_chunk' => true}, nil]
153
+ end
154
+
155
+ # Writes a data or remote frame to the write queue to be transmitted over the
156
+ # CAN transceiver.
157
+ #
158
+ # The Bricklet supports the standard 11-bit (CAN 2.0A) and the additional extended
159
+ # 29-bit (CAN 2.0B) identifiers. For standard frames the Bricklet uses bit 0 to 10
160
+ # from the ``identifier`` parameter as standard 11-bit identifier. For extended
161
+ # frames the Bricklet uses bit 0 to 28 from the ``identifier`` parameter as
162
+ # extended 29-bit identifier.
163
+ #
164
+ # The ``data`` parameter can be up to 15 bytes long. For data frames up to 8 bytes
165
+ # will be used as the actual data. The length (DLC) field in the data or remote
166
+ # frame will be set to the actual length of the ``data`` parameter. This allows
167
+ # to transmit data and remote frames with excess length. For remote frames only
168
+ # the length of the ``data`` parameter is used. The actual ``data`` bytes are
169
+ # ignored.
170
+ #
171
+ # Returns *true* if the frame was successfully added to the write queue. Returns
172
+ # *false* if the frame could not be added because write queue is already full or
173
+ # because the write buffer or the write backlog are configured with a size of
174
+ # zero (see BrickletCANV2#set_queue_configuration).
175
+ #
176
+ # The write queue can overflow if frames are written to it at a higher rate
177
+ # than the Bricklet can transmitted them over the CAN transceiver. This may
178
+ # happen if the CAN transceiver is configured as read-only or is using a low baud
179
+ # rate (see BrickletCANV2#set_transceiver_configuration). It can also happen if the CAN
180
+ # bus is congested and the frame cannot be transmitted because it constantly loses
181
+ # arbitration or because the CAN transceiver is currently disabled due to a high
182
+ # write error level (see BrickletCANV2#get_error_log).
183
+ def write_frame_low_level(frame_type, identifier, data_length, data_data)
184
+ send_request FUNCTION_WRITE_FRAME_LOW_LEVEL, [frame_type, identifier, data_length, data_data], 'C L C C15', 1, '?'
185
+ end
186
+
187
+ # Tries to read the next data or remote frame from the read queue and returns it.
188
+ # If a frame was successfully read, then the ``success`` return value is set to
189
+ # *true* and the other return values contain the frame. If the read queue is
190
+ # empty and no frame could be read, then the ``success`` return value is set to
191
+ # *false* and the other return values contain invalid data.
192
+ #
193
+ # The ``identifier`` return value follows the identifier format described for
194
+ # BrickletCANV2#write_frame.
195
+ #
196
+ # The ``data`` return value can be up to 15 bytes long. For data frames up to the
197
+ # first 8 bytes are the actual received data. All bytes after the 8th byte are
198
+ # always zero and only there to indicate the length of a data or remote frame
199
+ # with excess length. For remote frames the length of the ``data`` return value
200
+ # represents the requested length. The actual ``data`` bytes are always zero.
201
+ #
202
+ # A configurable read filter can be used to define which frames should be
203
+ # received by the CAN transceiver and put into the read queue (see
204
+ # BrickletCANV2#set_read_filter_configuration).
205
+ #
206
+ # Instead of polling with this function, you can also use callbacks. See the
207
+ # BrickletCANV2#set_frame_read_callback_configuration function and the CALLBACK_FRAME_READ
208
+ # callback.
209
+ def read_frame_low_level
210
+ send_request FUNCTION_READ_FRAME_LOW_LEVEL, [], '', 22, '? C L C C15'
211
+ end
212
+
213
+ # Enables and disables the CALLBACK_FRAME_READ callback.
214
+ #
215
+ # By default the callback is disabled.
216
+ def set_frame_read_callback_configuration(enabled)
217
+ send_request FUNCTION_SET_FRAME_READ_CALLBACK_CONFIGURATION, [enabled], '?', 0, ''
218
+ end
219
+
220
+ # Returns *true* if the CALLBACK_FRAME_READ callback is enabled, *false* otherwise.
221
+ def get_frame_read_callback_configuration
222
+ send_request FUNCTION_GET_FRAME_READ_CALLBACK_CONFIGURATION, [], '', 1, '?'
223
+ end
224
+
225
+ # Sets the transceiver configuration for the CAN bus communication.
226
+ #
227
+ # The baud rate can be configured in bit/s between 10 and 1000 kbit/s and the
228
+ # sample point can be configured in 1/10 % between 50 and 90 %.
229
+ #
230
+ # The CAN transceiver has three different modes:
231
+ #
232
+ # * Normal: Reads from and writes to the CAN bus and performs active bus
233
+ # error detection and acknowledgement.
234
+ # * Loopback: All reads and writes are performed internally. The transceiver
235
+ # is disconnected from the actual CAN bus.
236
+ # * Read-Only: Only reads from the CAN bus, but does neither active bus error
237
+ # detection nor acknowledgement. Only the receiving part of the transceiver
238
+ # is connected to the CAN bus.
239
+ #
240
+ # The default is: 125 kbit/s, 62.5 % and normal transceiver mode.
241
+ def set_transceiver_configuration(baud_rate, sample_point, transceiver_mode)
242
+ send_request FUNCTION_SET_TRANSCEIVER_CONFIGURATION, [baud_rate, sample_point, transceiver_mode], 'L S C', 0, ''
243
+ end
244
+
245
+ # Returns the configuration as set by BrickletCANV2#set_transceiver_configuration.
246
+ def get_transceiver_configuration
247
+ send_request FUNCTION_GET_TRANSCEIVER_CONFIGURATION, [], '', 7, 'L S C'
248
+ end
249
+
250
+ # Sets the write and read queue configuration.
251
+ #
252
+ # The CAN transceiver has 32 buffers in total in hardware for transmitting and
253
+ # receiving frames. Additionally, the Bricklet has a backlog for 768 frames in
254
+ # total in software. The buffers and the backlog can be freely assigned to the
255
+ # write and read queues.
256
+ #
257
+ # BrickletCANV2#write_frame writes a frame into the write backlog. The Bricklet moves
258
+ # the frame from the backlog into a free write buffer. The CAN transceiver then
259
+ # transmits the frame from the write buffer to the CAN bus. If there are no
260
+ # write buffers (``write_buffer_size`` is zero) or there is no write backlog
261
+ # (``write_backlog_size`` is zero) then no frames can be transmitted and
262
+ # BrickletCANV2#write_frame returns always *false*.
263
+ #
264
+ # The CAN transceiver receives a frame from the CAN bus and stores it into a
265
+ # free read buffer. The Bricklet moves the frame from the read buffer into the
266
+ # read backlog. BrickletCANV2#read_frame reads the frame from the read backlog and
267
+ # returns it. If there are no read buffers (``read_buffer_sizes`` is empty) or
268
+ # there is no read backlog (``read_backlog_size`` is zero) then no frames can be
269
+ # received and BrickletCANV2#read_frame returns always *false*.
270
+ #
271
+ # There can be multiple read buffers, because the CAN transceiver cannot receive
272
+ # data and remote frames into the same read buffer. A positive read buffer size
273
+ # represents a data frame read buffer and a negative read buffer size represents
274
+ # a remote frame read buffer. A read buffer size of zero is not allowed. By
275
+ # default the first read buffer is configured for data frames and the second read
276
+ # buffer is configured for remote frame. There can be up to 32 different read
277
+ # buffers, assuming that no write buffer is used. Each read buffer has its own
278
+ # filter configuration (see BrickletCANV2#set_read_filter_configuration).
279
+ #
280
+ # A valid queue configuration fulfills these conditions::
281
+ #
282
+ # write_buffer_size + read_buffer_size_0 + read_buffer_size_1 + ... + read_buffer_size_31 <= 32
283
+ # write_backlog_size + read_backlog_size <= 768
284
+ #
285
+ # The write buffer timeout has three different modes that define how a failed
286
+ # frame transmission should be handled:
287
+ #
288
+ # * Single-Shot (< 0): Only one transmission attempt will be made. If the
289
+ # transmission fails then the frame is discarded.
290
+ # * Infinite (= 0): Infinite transmission attempts will be made. The frame will
291
+ # never be discarded.
292
+ # * Milliseconds (> 0): A limited number of transmission attempts will be made.
293
+ # If the frame could not be transmitted successfully after the configured
294
+ # number of milliseconds then the frame is discarded.
295
+ #
296
+ # The current content of the queues is lost when this function is called.
297
+ #
298
+ # The default is:
299
+ #
300
+ # * 8 write buffers,
301
+ # * infinite write timeout,
302
+ # * 383 write backlog frames,
303
+ # * 16 read buffers for data frames,
304
+ # * 8 read buffers for remote frames and
305
+ # * 383 read backlog frames.
306
+ def set_queue_configuration_low_level(write_buffer_size, write_buffer_timeout, write_backlog_size, read_buffer_sizes_length, read_buffer_sizes_data, read_backlog_size)
307
+ send_request FUNCTION_SET_QUEUE_CONFIGURATION_LOW_LEVEL, [write_buffer_size, write_buffer_timeout, write_backlog_size, read_buffer_sizes_length, read_buffer_sizes_data, read_backlog_size], 'C l S C c32 S', 0, ''
308
+ end
309
+
310
+ # Returns the queue configuration as set by BrickletCANV2#set_queue_configuration.
311
+ def get_queue_configuration_low_level
312
+ send_request FUNCTION_GET_QUEUE_CONFIGURATION_LOW_LEVEL, [], '', 42, 'C l S C c32 S'
313
+ end
314
+
315
+ # Set the read filter configuration for the given read buffer index. This can be
316
+ # used to define which frames should be received by the CAN transceiver and put
317
+ # into the read buffer.
318
+ #
319
+ # The read filter has four different modes that define if and how the filter mask
320
+ # and the filter identifier are applied:
321
+ #
322
+ # * Accept-All: All frames are received.
323
+ # * Match-Standard-Only: Only standard frames with a matching identifier are
324
+ # received.
325
+ # * Match-Extended-Only: Only extended frames with a matching identifier are
326
+ # received.
327
+ # * Match-Standard-And-Extended: Standard and extended frames with a matching
328
+ # identifier are received.
329
+ #
330
+ # The filter mask and filter identifier are used as bit masks. Their usage
331
+ # depends on the mode:
332
+ #
333
+ # * Accept-All: Mask and identifier are ignored.
334
+ # * Match-Standard-Only: Bit 0 to 10 (11 bits) of filter mask and filter
335
+ # identifier are used to match the 11-bit identifier of standard frames.
336
+ # * Match-Extended-Only: Bit 0 to 28 (29 bits) of filter mask and filter
337
+ # identifier are used to match the 29-bit identifier of extended frames.
338
+ # * Match-Standard-And-Extended: Bit 18 to 28 (11 bits) of filter mask and filter
339
+ # identifier are used to match the 11-bit identifier of standard frames, bit 0
340
+ # to 17 (18 bits) are ignored in this case. Bit 0 to 28 (29 bits) of filter
341
+ # mask and filter identifier are used to match the 29-bit identifier of extended
342
+ # frames.
343
+ #
344
+ # The filter mask and filter identifier are applied in this way: The filter mask
345
+ # is used to select the frame identifier bits that should be compared to the
346
+ # corresponding filter identifier bits. All unselected bits are automatically
347
+ # accepted. All selected bits have to match the filter identifier to be accepted.
348
+ # If all bits for the selected mode are accepted then the frame is accepted and
349
+ # is added to the read buffer.
350
+ #
351
+ # "Filter Mask Bit", "Filter Identifier Bit", "Frame Identifier Bit", "Result"
352
+ #
353
+ # 0, X, X, Accept
354
+ # 1, 0, 0, Accept
355
+ # 1, 0, 1, Reject
356
+ # 1, 1, 0, Reject
357
+ # 1, 1, 1, Accept
358
+ #
359
+ # For example, to receive standard frames with identifier 0x123 only, the mode
360
+ # can be set to Match-Standard-Only with 0x7FF as mask and 0x123 as identifier.
361
+ # The mask of 0x7FF selects all 11 identifier bits for matching so that the
362
+ # identifier has to be exactly 0x123 to be accepted.
363
+ #
364
+ # To accept identifier 0x123 and identifier 0x456 at the same time, just set
365
+ # filter 2 to 0x456 and keep mask and filter 1 unchanged.
366
+ #
367
+ # There can be up to 32 different read filters configured at the same time,
368
+ # because there can be up to 32 read buffer (see BrickletCANV2#set_queue_configuration).
369
+ #
370
+ # The default mode is accept-all for all read buffers.
371
+ def set_read_filter_configuration(buffer_index, filter_mode, filter_mask, filter_identifier)
372
+ send_request FUNCTION_SET_READ_FILTER_CONFIGURATION, [buffer_index, filter_mode, filter_mask, filter_identifier], 'C C L L', 0, ''
373
+ end
374
+
375
+ # Returns the read filter configuration as set by BrickletCANV2#set_read_filter_configuration.
376
+ def get_read_filter_configuration(buffer_index)
377
+ send_request FUNCTION_GET_READ_FILTER_CONFIGURATION, [buffer_index], 'C', 9, 'C L L'
378
+ end
379
+
380
+ # Returns information about different kinds of errors.
381
+ #
382
+ # The write and read error levels indicate the current level of stuffing, form,
383
+ # acknowledgement, bit and checksum errors during CAN bus write and read
384
+ # operations. For each of this error kinds there is also an individual counter.
385
+ #
386
+ # When the write error level extends 255 then the CAN transceiver gets disabled
387
+ # and no frames can be transmitted or received anymore. The CAN transceiver will
388
+ # automatically be activated again after the CAN bus is idle for a while.
389
+ #
390
+ # The write buffer timeout, read buffer and backlog overflow counts represents the
391
+ # number of these errors:
392
+ #
393
+ # * A write buffer timeout occurs if a frame could not be transmitted before the
394
+ # configured write buffer timeout expired (see BrickletCANV2#set_queue_configuration).
395
+ # * A read buffer overflow occurs if a read buffer of the CAN transceiver
396
+ # still contains the last received frame when the next frame arrives. In this
397
+ # case the last received frame is lost. This happens if the CAN transceiver
398
+ # receives more frames than the Bricklet can handle. Using the read filter
399
+ # (see BrickletCANV2#set_read_filter_configuration) can help to reduce the amount of
400
+ # received frames. This count is not exact, but a lower bound, because the
401
+ # Bricklet might not able detect all overflows if they occur in rapid succession.
402
+ # * A read backlog overflow occurs if the read backlog of the Bricklet is already
403
+ # full when the next frame should be read from a read buffer of the CAN
404
+ # transceiver. In this case the frame in the read buffer is lost. This
405
+ # happens if the CAN transceiver receives more frames to be added to the read
406
+ # backlog than are removed from the read backlog using the BrickletCANV2#read_frame
407
+ # function. Using the CALLBACK_FRAME_READ callback ensures that the read backlog
408
+ # can not overflow.
409
+ #
410
+ # The read buffer overflow counter counts the overflows of all configured read
411
+ # buffers. Which read buffer exactly suffered from an overflow can be figured
412
+ # out from the read buffer overflow occurrence list
413
+ # (``read_buffer_overflow_error_occurred``).
414
+ def get_error_log_low_level
415
+ send_request FUNCTION_GET_ERROR_LOG_LOW_LEVEL, [], '', 72, 'C C C L L L L L L L L C ?32 L'
416
+ end
417
+
418
+ # Sets the communication LED configuration. By default the LED shows
419
+ # CAN-Bus traffic, it flickers once for every 40 transmitted or received frames.
420
+ #
421
+ # You can also turn the LED permanently on/off or show a heartbeat.
422
+ #
423
+ # If the Bricklet is in bootloader mode, the LED is off.
424
+ def set_communication_led_config(config)
425
+ send_request FUNCTION_SET_COMMUNICATION_LED_CONFIG, [config], 'C', 0, ''
426
+ end
427
+
428
+ # Returns the configuration as set by BrickletCANV2#set_communication_led_config
429
+ def get_communication_led_config
430
+ send_request FUNCTION_GET_COMMUNICATION_LED_CONFIG, [], '', 1, 'C'
431
+ end
432
+
433
+ # Sets the error LED configuration.
434
+ #
435
+ # By default (show-transceiver-state) the error LED turns on if the CAN
436
+ # transceiver is passive or disabled state (see BrickletCANV2#get_error_log). If
437
+ # the CAN transceiver is in active state the LED turns off.
438
+ #
439
+ # If the LED is configured as show-error then the error LED turns on if any error
440
+ # occurs. If you call this function with the show-error option again, the LED will
441
+ # turn off until the next error occurs.
442
+ #
443
+ # You can also turn the LED permanently on/off or show a heartbeat.
444
+ #
445
+ # If the Bricklet is in bootloader mode, the LED is off.
446
+ def set_error_led_config(config)
447
+ send_request FUNCTION_SET_ERROR_LED_CONFIG, [config], 'C', 0, ''
448
+ end
449
+
450
+ # Returns the configuration as set by BrickletCANV2#set_error_led_config.
451
+ def get_error_led_config
452
+ send_request FUNCTION_GET_ERROR_LED_CONFIG, [], '', 1, 'C'
453
+ end
454
+
455
+ # Returns the error count for the communication between Brick and Bricklet.
456
+ #
457
+ # The errors are divided into
458
+ #
459
+ # * ack checksum errors,
460
+ # * message checksum errors,
461
+ # * frameing errors and
462
+ # * overflow errors.
463
+ #
464
+ # The errors counts are for errors that occur on the Bricklet side. All
465
+ # Bricks have a similar function that returns the errors on the Brick side.
466
+ def get_spitfp_error_count
467
+ send_request FUNCTION_GET_SPITFP_ERROR_COUNT, [], '', 16, 'L L L L'
468
+ end
469
+
470
+ # Sets the bootloader mode and returns the status after the requested
471
+ # mode change was instigated.
472
+ #
473
+ # You can change from bootloader mode to firmware mode and vice versa. A change
474
+ # from bootloader mode to firmware mode will only take place if the entry function,
475
+ # device identifier und crc are present and correct.
476
+ #
477
+ # This function is used by Brick Viewer during flashing. It should not be
478
+ # necessary to call it in a normal user program.
479
+ def set_bootloader_mode(mode)
480
+ send_request FUNCTION_SET_BOOTLOADER_MODE, [mode], 'C', 1, 'C'
481
+ end
482
+
483
+ # Returns the current bootloader mode, see BrickletCANV2#set_bootloader_mode.
484
+ def get_bootloader_mode
485
+ send_request FUNCTION_GET_BOOTLOADER_MODE, [], '', 1, 'C'
486
+ end
487
+
488
+ # Sets the firmware pointer for BrickletCANV2#write_firmware. The pointer has
489
+ # to be increased by chunks of size 64. The data is written to flash
490
+ # every 4 chunks (which equals to one page of size 256).
491
+ #
492
+ # This function is used by Brick Viewer during flashing. It should not be
493
+ # necessary to call it in a normal user program.
494
+ def set_write_firmware_pointer(pointer)
495
+ send_request FUNCTION_SET_WRITE_FIRMWARE_POINTER, [pointer], 'L', 0, ''
496
+ end
497
+
498
+ # Writes 64 Bytes of firmware at the position as written by
499
+ # BrickletCANV2#set_write_firmware_pointer before. The firmware is written
500
+ # to flash every 4 chunks.
501
+ #
502
+ # You can only write firmware in bootloader mode.
503
+ #
504
+ # This function is used by Brick Viewer during flashing. It should not be
505
+ # necessary to call it in a normal user program.
506
+ def write_firmware(data)
507
+ send_request FUNCTION_WRITE_FIRMWARE, [data], 'C64', 1, 'C'
508
+ end
509
+
510
+ # Sets the status LED configuration. By default the LED shows
511
+ # communication traffic between Brick and Bricklet, it flickers once
512
+ # for every 10 received data packets.
513
+ #
514
+ # You can also turn the LED permanently on/off or show a heartbeat.
515
+ #
516
+ # If the Bricklet is in bootloader mode, the LED is will show heartbeat by default.
517
+ def set_status_led_config(config)
518
+ send_request FUNCTION_SET_STATUS_LED_CONFIG, [config], 'C', 0, ''
519
+ end
520
+
521
+ # Returns the configuration as set by BrickletCANV2#set_status_led_config
522
+ def get_status_led_config
523
+ send_request FUNCTION_GET_STATUS_LED_CONFIG, [], '', 1, 'C'
524
+ end
525
+
526
+ # Returns the temperature in °C as measured inside the microcontroller. The
527
+ # value returned is not the ambient temperature!
528
+ #
529
+ # The temperature is only proportional to the real temperature and it has bad
530
+ # accuracy. Practically it is only useful as an indicator for
531
+ # temperature changes.
532
+ def get_chip_temperature
533
+ send_request FUNCTION_GET_CHIP_TEMPERATURE, [], '', 2, 's'
534
+ end
535
+
536
+ # Calling this function will reset the Bricklet. All configurations
537
+ # will be lost.
538
+ #
539
+ # After a reset you have to create new device objects,
540
+ # calling functions on the existing ones will result in
541
+ # undefined behavior!
542
+ def reset
543
+ send_request FUNCTION_RESET, [], '', 0, ''
544
+ end
545
+
546
+ # Writes a new UID into flash. If you want to set a new UID
547
+ # you have to decode the Base58 encoded UID string into an
548
+ # integer first.
549
+ #
550
+ # We recommend that you use Brick Viewer to change the UID.
551
+ def write_uid(uid)
552
+ send_request FUNCTION_WRITE_UID, [uid], 'L', 0, ''
553
+ end
554
+
555
+ # Returns the current UID as an integer. Encode as
556
+ # Base58 to get the usual string version.
557
+ def read_uid
558
+ send_request FUNCTION_READ_UID, [], '', 4, 'L'
559
+ end
560
+
561
+ # Returns the UID, the UID where the Bricklet is connected to,
562
+ # the position, the hardware and firmware version as well as the
563
+ # device identifier.
564
+ #
565
+ # The position can be 'a', 'b', 'c' or 'd'.
566
+ #
567
+ # The device identifier numbers can be found :ref:`here <device_identifier>`.
568
+ # |device_identifier_constant|
569
+ def get_identity
570
+ send_request FUNCTION_GET_IDENTITY, [], '', 25, 'Z8 Z8 k C3 C3 S'
571
+ end
572
+
573
+ # Writes a data or remote frame to the write queue to be transmitted over the
574
+ # CAN transceiver.
575
+ #
576
+ # The Bricklet supports the standard 11-bit (CAN 2.0A) and the additional extended
577
+ # 29-bit (CAN 2.0B) identifiers. For standard frames the Bricklet uses bit 0 to 10
578
+ # from the ``identifier`` parameter as standard 11-bit identifier. For extended
579
+ # frames the Bricklet uses bit 0 to 28 from the ``identifier`` parameter as
580
+ # extended 29-bit identifier.
581
+ #
582
+ # The ``data`` parameter can be up to 15 bytes long. For data frames up to 8 bytes
583
+ # will be used as the actual data. The length (DLC) field in the data or remote
584
+ # frame will be set to the actual length of the ``data`` parameter. This allows
585
+ # to transmit data and remote frames with excess length. For remote frames only
586
+ # the length of the ``data`` parameter is used. The actual ``data`` bytes are
587
+ # ignored.
588
+ #
589
+ # Returns *true* if the frame was successfully added to the write queue. Returns
590
+ # *false* if the frame could not be added because write queue is already full or
591
+ # because the write buffer or the write backlog are configured with a size of
592
+ # zero (see BrickletCANV2#set_queue_configuration).
593
+ #
594
+ # The write queue can overflow if frames are written to it at a higher rate
595
+ # than the Bricklet can transmitted them over the CAN transceiver. This may
596
+ # happen if the CAN transceiver is configured as read-only or is using a low baud
597
+ # rate (see BrickletCANV2#set_transceiver_configuration). It can also happen if the CAN
598
+ # bus is congested and the frame cannot be transmitted because it constantly loses
599
+ # arbitration or because the CAN transceiver is currently disabled due to a high
600
+ # write error level (see BrickletCANV2#get_error_log).
601
+ def write_frame(frame_type, identifier, data)
602
+ data = data.clone # clone so we can potentially extend it
603
+ data_length = data.length
604
+ data_data = data
605
+
606
+ if data_length > 15
607
+ raise ArgumentError, 'Data can be at most 15 items long'
608
+ end
609
+
610
+ if data_length < 15
611
+ data_data += [0] * (15 - data_length)
612
+ end
613
+
614
+ write_frame_low_level frame_type, identifier, data_length, data_data
615
+ end
616
+
617
+ # Tries to read the next data or remote frame from the read queue and returns it.
618
+ # If a frame was successfully read, then the ``success`` return value is set to
619
+ # *true* and the other return values contain the frame. If the read queue is
620
+ # empty and no frame could be read, then the ``success`` return value is set to
621
+ # *false* and the other return values contain invalid data.
622
+ #
623
+ # The ``identifier`` return value follows the identifier format described for
624
+ # BrickletCANV2#write_frame.
625
+ #
626
+ # The ``data`` return value can be up to 15 bytes long. For data frames up to the
627
+ # first 8 bytes are the actual received data. All bytes after the 8th byte are
628
+ # always zero and only there to indicate the length of a data or remote frame
629
+ # with excess length. For remote frames the length of the ``data`` return value
630
+ # represents the requested length. The actual ``data`` bytes are always zero.
631
+ #
632
+ # A configurable read filter can be used to define which frames should be
633
+ # received by the CAN transceiver and put into the read queue (see
634
+ # BrickletCANV2#set_read_filter_configuration).
635
+ #
636
+ # Instead of polling with this function, you can also use callbacks. See the
637
+ # BrickletCANV2#set_frame_read_callback_configuration function and the CALLBACK_FRAME_READ
638
+ # callback.
639
+ def read_frame
640
+ ret = read_frame_low_level
641
+
642
+ [ret[0], ret[1], ret[2], ret[4][0, ret[3]]]
643
+ end
644
+
645
+ # Sets the write and read queue configuration.
646
+ #
647
+ # The CAN transceiver has 32 buffers in total in hardware for transmitting and
648
+ # receiving frames. Additionally, the Bricklet has a backlog for 768 frames in
649
+ # total in software. The buffers and the backlog can be freely assigned to the
650
+ # write and read queues.
651
+ #
652
+ # BrickletCANV2#write_frame writes a frame into the write backlog. The Bricklet moves
653
+ # the frame from the backlog into a free write buffer. The CAN transceiver then
654
+ # transmits the frame from the write buffer to the CAN bus. If there are no
655
+ # write buffers (``write_buffer_size`` is zero) or there is no write backlog
656
+ # (``write_backlog_size`` is zero) then no frames can be transmitted and
657
+ # BrickletCANV2#write_frame returns always *false*.
658
+ #
659
+ # The CAN transceiver receives a frame from the CAN bus and stores it into a
660
+ # free read buffer. The Bricklet moves the frame from the read buffer into the
661
+ # read backlog. BrickletCANV2#read_frame reads the frame from the read backlog and
662
+ # returns it. If there are no read buffers (``read_buffer_sizes`` is empty) or
663
+ # there is no read backlog (``read_backlog_size`` is zero) then no frames can be
664
+ # received and BrickletCANV2#read_frame returns always *false*.
665
+ #
666
+ # There can be multiple read buffers, because the CAN transceiver cannot receive
667
+ # data and remote frames into the same read buffer. A positive read buffer size
668
+ # represents a data frame read buffer and a negative read buffer size represents
669
+ # a remote frame read buffer. A read buffer size of zero is not allowed. By
670
+ # default the first read buffer is configured for data frames and the second read
671
+ # buffer is configured for remote frame. There can be up to 32 different read
672
+ # buffers, assuming that no write buffer is used. Each read buffer has its own
673
+ # filter configuration (see BrickletCANV2#set_read_filter_configuration).
674
+ #
675
+ # A valid queue configuration fulfills these conditions::
676
+ #
677
+ # write_buffer_size + read_buffer_size_0 + read_buffer_size_1 + ... + read_buffer_size_31 <= 32
678
+ # write_backlog_size + read_backlog_size <= 768
679
+ #
680
+ # The write buffer timeout has three different modes that define how a failed
681
+ # frame transmission should be handled:
682
+ #
683
+ # * Single-Shot (< 0): Only one transmission attempt will be made. If the
684
+ # transmission fails then the frame is discarded.
685
+ # * Infinite (= 0): Infinite transmission attempts will be made. The frame will
686
+ # never be discarded.
687
+ # * Milliseconds (> 0): A limited number of transmission attempts will be made.
688
+ # If the frame could not be transmitted successfully after the configured
689
+ # number of milliseconds then the frame is discarded.
690
+ #
691
+ # The current content of the queues is lost when this function is called.
692
+ #
693
+ # The default is:
694
+ #
695
+ # * 8 write buffers,
696
+ # * infinite write timeout,
697
+ # * 383 write backlog frames,
698
+ # * 16 read buffers for data frames,
699
+ # * 8 read buffers for remote frames and
700
+ # * 383 read backlog frames.
701
+ def set_queue_configuration(write_buffer_size, write_buffer_timeout, write_backlog_size, read_buffer_sizes, read_backlog_size)
702
+ read_buffer_sizes = read_buffer_sizes.clone # clone so we can potentially extend it
703
+ read_buffer_sizes_length = read_buffer_sizes.length
704
+ read_buffer_sizes_data = read_buffer_sizes
705
+
706
+ if read_buffer_sizes_length > 32
707
+ raise ArgumentError, 'Read Buffer Sizes can be at most 32 items long'
708
+ end
709
+
710
+ if read_buffer_sizes_length < 32
711
+ read_buffer_sizes_data += [0] * (32 - read_buffer_sizes_length)
712
+ end
713
+
714
+ set_queue_configuration_low_level write_buffer_size, write_buffer_timeout, write_backlog_size, read_buffer_sizes_length, read_buffer_sizes_data, read_backlog_size
715
+ end
716
+
717
+ # Returns the queue configuration as set by BrickletCANV2#set_queue_configuration.
718
+ def get_queue_configuration
719
+ ret = get_queue_configuration_low_level
720
+
721
+ [ret[0], ret[1], ret[2], ret[4][0, ret[3]], ret[5]]
722
+ end
723
+
724
+ # Returns information about different kinds of errors.
725
+ #
726
+ # The write and read error levels indicate the current level of stuffing, form,
727
+ # acknowledgement, bit and checksum errors during CAN bus write and read
728
+ # operations. For each of this error kinds there is also an individual counter.
729
+ #
730
+ # When the write error level extends 255 then the CAN transceiver gets disabled
731
+ # and no frames can be transmitted or received anymore. The CAN transceiver will
732
+ # automatically be activated again after the CAN bus is idle for a while.
733
+ #
734
+ # The write buffer timeout, read buffer and backlog overflow counts represents the
735
+ # number of these errors:
736
+ #
737
+ # * A write buffer timeout occurs if a frame could not be transmitted before the
738
+ # configured write buffer timeout expired (see BrickletCANV2#set_queue_configuration).
739
+ # * A read buffer overflow occurs if a read buffer of the CAN transceiver
740
+ # still contains the last received frame when the next frame arrives. In this
741
+ # case the last received frame is lost. This happens if the CAN transceiver
742
+ # receives more frames than the Bricklet can handle. Using the read filter
743
+ # (see BrickletCANV2#set_read_filter_configuration) can help to reduce the amount of
744
+ # received frames. This count is not exact, but a lower bound, because the
745
+ # Bricklet might not able detect all overflows if they occur in rapid succession.
746
+ # * A read backlog overflow occurs if the read backlog of the Bricklet is already
747
+ # full when the next frame should be read from a read buffer of the CAN
748
+ # transceiver. In this case the frame in the read buffer is lost. This
749
+ # happens if the CAN transceiver receives more frames to be added to the read
750
+ # backlog than are removed from the read backlog using the BrickletCANV2#read_frame
751
+ # function. Using the CALLBACK_FRAME_READ callback ensures that the read backlog
752
+ # can not overflow.
753
+ #
754
+ # The read buffer overflow counter counts the overflows of all configured read
755
+ # buffers. Which read buffer exactly suffered from an overflow can be figured
756
+ # out from the read buffer overflow occurrence list
757
+ # (``read_buffer_overflow_error_occurred``).
758
+ def get_error_log
759
+ ret = get_error_log_low_level
760
+
761
+ [ret[0], ret[1], ret[2], ret[3], ret[4], ret[5], ret[6], ret[7], ret[8], ret[9], ret[10], ret[12][0, ret[11]], ret[13]]
762
+ end
763
+
764
+ # Registers a callback with ID <tt>id</tt> to the block <tt>block</tt>.
765
+ def register_callback(id, &block)
766
+ callback = block
767
+ @registered_callbacks[id] = callback
768
+ end
769
+ end
770
+ end