Module: Tinkerforge
- Defined in:
- lib/tinkerforge/brick_dc.rb,
lib/tinkerforge.rb,
lib/tinkerforge/version.rb,
lib/tinkerforge/brick_imu.rb,
lib/tinkerforge/brick_red.rb,
lib/tinkerforge/brick_servo.rb,
lib/tinkerforge/brick_imu_v2.rb,
lib/tinkerforge/brick_master.rb,
lib/tinkerforge/bricklet_can.rb,
lib/tinkerforge/bricklet_co2.rb,
lib/tinkerforge/bricklet_gps.rb,
lib/tinkerforge/bricklet_io4.rb,
lib/tinkerforge/bricklet_ptc.rb,
lib/tinkerforge/brick_stepper.rb,
lib/tinkerforge/bricklet_io16.rb,
lib/tinkerforge/bricklet_line.rb,
lib/tinkerforge/bricklet_tilt.rb,
lib/tinkerforge/ip_connection.rb,
lib/tinkerforge/bricklet_color.rb,
lib/tinkerforge/bricklet_rs232.rb,
lib/tinkerforge/bricklet_rgb_led.rb,
lib/tinkerforge/bricklet_voltage.rb,
lib/tinkerforge/bricklet_humidity.rb,
lib/tinkerforge/bricklet_joystick.rb,
lib/tinkerforge/bricklet_lcd_16x2.rb,
lib/tinkerforge/bricklet_lcd_20x4.rb,
lib/tinkerforge/bricklet_moisture.rb,
lib/tinkerforge/bricklet_nfc_rfid.rb,
lib/tinkerforge/bricklet_uv_light.rb,
lib/tinkerforge/bricklet_analog_in.rb,
lib/tinkerforge/bricklet_barometer.rb,
lib/tinkerforge/bricklet_current12.rb,
lib/tinkerforge/bricklet_current25.rb,
lib/tinkerforge/bricklet_led_strip.rb,
lib/tinkerforge/bricklet_load_cell.rb,
lib/tinkerforge/bricklet_analog_out.rb,
lib/tinkerforge/bricklet_dual_relay.rb,
lib/tinkerforge/bricklet_oled_64x48.rb,
lib/tinkerforge/bricklet_distance_ir.rb,
lib/tinkerforge/bricklet_distance_us.rb,
lib/tinkerforge/bricklet_dual_button.rb,
lib/tinkerforge/bricklet_hall_effect.rb,
lib/tinkerforge/bricklet_linear_poti.rb,
lib/tinkerforge/bricklet_multi_touch.rb,
lib/tinkerforge/bricklet_oled_128x64.rb,
lib/tinkerforge/bricklet_rotary_poti.rb,
lib/tinkerforge/bricklet_temperature.rb,
lib/tinkerforge/bricklet_analog_in_v2.rb,
lib/tinkerforge/bricklet_piezo_buzzer.rb,
lib/tinkerforge/bricklet_thermocouple.rb,
lib/tinkerforge/bricklet_accelerometer.rb,
lib/tinkerforge/bricklet_ambient_light.rb,
lib/tinkerforge/bricklet_analog_out_v2.rb,
lib/tinkerforge/bricklet_dust_detector.rb,
lib/tinkerforge/bricklet_piezo_speaker.rb,
lib/tinkerforge/bricklet_remote_switch.rb,
lib/tinkerforge/bricklet_rotary_encoder.rb,
lib/tinkerforge/bricklet_temperature_ir.rb,
lib/tinkerforge/bricklet_motion_detector.rb,
lib/tinkerforge/bricklet_real_time_clock.rb,
lib/tinkerforge/bricklet_sound_intensity.rb,
lib/tinkerforge/bricklet_voltage_current.rb,
lib/tinkerforge/bricklet_ambient_light_v2.rb,
lib/tinkerforge/bricklet_solid_state_relay.rb,
lib/tinkerforge/bricklet_laser_range_finder.rb,
lib/tinkerforge/bricklet_segment_display_4x7.rb,
lib/tinkerforge/bricklet_industrial_analog_out.rb,
lib/tinkerforge/bricklet_industrial_quad_relay.rb,
lib/tinkerforge/bricklet_industrial_dual_0_20ma.rb,
lib/tinkerforge/bricklet_industrial_digital_in_4.rb,
lib/tinkerforge/bricklet_industrial_digital_out_4.rb,
lib/tinkerforge/bricklet_industrial_dual_analog_in.rb
Overview
This file was automatically generated on 2016-06-30. #
Ruby Bindings Version 2.1.9 #
If you have a bugfix for this file and want to commit it, # please fix the bug in the generator. You can find a link # to the generators git repository on tinkerforge.com #
Defined Under Namespace
Classes: AlreadyConnectedException, Base58, BrickDC, BrickDaemon, BrickIMU, BrickIMUV2, BrickMaster, BrickRED, BrickServo, BrickStepper, BrickletAccelerometer, BrickletAmbientLight, BrickletAmbientLightV2, BrickletAnalogIn, BrickletAnalogInV2, BrickletAnalogOut, BrickletAnalogOutV2, BrickletBarometer, BrickletCAN, BrickletCO2, BrickletColor, BrickletCurrent12, BrickletCurrent25, BrickletDistanceIR, BrickletDistanceUS, BrickletDualButton, BrickletDualRelay, BrickletDustDetector, BrickletGPS, BrickletHallEffect, BrickletHumidity, BrickletIO16, BrickletIO4, BrickletIndustrialAnalogOut, BrickletIndustrialDigitalIn4, BrickletIndustrialDigitalOut4, BrickletIndustrialDual020mA, BrickletIndustrialDualAnalogIn, BrickletIndustrialQuadRelay, BrickletJoystick, BrickletLCD16x2, BrickletLCD20x4, BrickletLEDStrip, BrickletLaserRangeFinder, BrickletLine, BrickletLinearPoti, BrickletLoadCell, BrickletMoisture, BrickletMotionDetector, BrickletMultiTouch, BrickletNFCRFID, BrickletOLED128x64, BrickletOLED64x48, BrickletPTC, BrickletPiezoBuzzer, BrickletPiezoSpeaker, BrickletRGBLED, BrickletRS232, BrickletRealTimeClock, BrickletRemoteSwitch, BrickletRotaryEncoder, BrickletRotaryPoti, BrickletSegmentDisplay4x7, BrickletSolidStateRelay, BrickletSoundIntensity, BrickletTemperature, BrickletTemperatureIR, BrickletThermocouple, BrickletTilt, BrickletUVLight, BrickletVoltage, BrickletVoltageCurrent, CallbackContext, Device, IPConnection, NotConnectedException, NotSupportedException, TimeoutException, TinkerforgeException
Constant Summary
collapse
- VERSION =
'2.1.9'
Instance Method Summary
collapse
Instance Method Details
#get_error_code_from_data(data) ⇒ Object
179
180
181
|
# File 'lib/tinkerforge/ip_connection.rb', line 179
def get_error_code_from_data(data)
(data[7, 1].unpack('C')[0] >> 6) & 0x03
end
|
#get_function_id_from_data(data) ⇒ Object
171
172
173
|
# File 'lib/tinkerforge/ip_connection.rb', line 171
def get_function_id_from_data(data)
data[5, 1].unpack('C')[0]
end
|
#get_length_from_data(data) ⇒ Object
167
168
169
|
# File 'lib/tinkerforge/ip_connection.rb', line 167
def get_length_from_data(data)
data[4, 1].unpack('C')[0]
end
|
#get_sequence_number_from_data(data) ⇒ Object
175
176
177
|
# File 'lib/tinkerforge/ip_connection.rb', line 175
def get_sequence_number_from_data(data)
(data[6, 1].unpack('C')[0] >> 4) & 0x0F
end
|
#get_uid_from_data(data) ⇒ Object
163
164
165
|
# File 'lib/tinkerforge/ip_connection.rb', line 163
def get_uid_from_data(data)
data[0, 4].unpack('L<')[0]
end
|
#pack(unpacked, format) ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/tinkerforge/ip_connection.rb', line 55
def pack(unpacked, format)
data = ''
format.split(' ').each do |f|
if f.length > 1
f0 = f[0, 1]
f1 = f[1..-1]
r = []
if f0 == '?'
unpacked[0].each { |b| r << b ? 1 : 0 }
data += r.pack "C#{f1}"
elsif f0 == 'k'
unpacked[0].each { |c| r << c.ord }
data += r.pack "c#{f1}"
else
r = unpacked[0]
if ['s', 'S', 'l', 'L', 'q', 'Q'].count(f0) > 0
data += r.pack "#{f0}<#{f1}"
elsif f0 == 'Z'
data += [r].pack "#{f0}#{f1}"
else
data += r.pack "#{f0}#{f1}"
end
end
else
if f == '?'
r = [unpacked[0] ? 1 : 0]
data += r.pack 'C'
elsif f == 'k'
r = [unpacked[0].ord]
data += r.pack 'c'
else
r = [unpacked[0]]
if ['s', 'S', 'l', 'L', 'q', 'Q'].count(f) > 0
data += r.pack "#{f}<"
else
data += r.pack f
end
end
end
unpacked = unpacked.drop 1
end
data
end
|
#unpack(data, format) ⇒ Object
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
# File 'lib/tinkerforge/ip_connection.rb', line 102
def unpack(data, format)
unpacked = []
format.split(' ').each do |f|
if f.length > 1
f0 = f[0, 1]
f1 = f[1..-1]
u = []
if f0 == '?'
r = data.unpack "C#{f1}a*"
data = r[-1]
r.delete_at(-1)
r.each { |b| u << b != 0 }
elsif f0 == 'k'
r = data.unpack "c#{f1}a*"
data = r[-1]
r.delete_at(-1)
r.each { |c| u << c.chr }
else
if ['s', 'S', 'l', 'L', 'q', 'Q'].count(f0) > 0
r = data.unpack "#{f}<a*"
else
r = data.unpack "#{f}a*"
end
data = r[-1]
r.delete_at(-1)
r.each { |i| u << i }
end
if u.length == 1
u = u[0]
end
unpacked << u
else
r = []
u = nil
if f == '?'
r = data.unpack "Ca*"
u = r[0] != 0
elsif f == 'k'
r = data.unpack "ca*"
u = r[0].chr
else
if ['s', 'q', 'l', 'L', 'S', 'Q'].count(f) > 0
r = data.unpack "#{f}<a*"
else
r = data.unpack "#{f}a*"
end
u = r[0]
end
data = r[1]
unpacked << u
end
end
unpacked
end
|