rfbeam 0.3.4 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/output.csv ADDED
@@ -0,0 +1,257 @@
1
+ 0,2105,2105
2
+ 1,3070,2915
3
+ 2,2915,805
4
+ 3,2325,2830
5
+ 4,805,3420
6
+ 5,1000,1340
7
+ 6,2830,1555
8
+ 7,3810,2645
9
+ 8,3420,1270
10
+ 9,1645,1400
11
+ 10,1340,1130
12
+ 11,1285,1350
13
+ 12,1555,1085
14
+ 13,1500,910
15
+ 14,2645,1400
16
+ 15,2785,1435
17
+ 16,1270,1150
18
+ 17,500,1545
19
+ 18,1400,1270
20
+ 19,615,1285
21
+ 20,1130,1435
22
+ 21,1000,785
23
+ 22,1350,710
24
+ 23,1565,955
25
+ 24,1085,1165
26
+ 25,1420,1645
27
+ 26,910,1595
28
+ 27,1265,455
29
+ 28,1400,805
30
+ 29,1015,1050
31
+ 30,1435,560
32
+ 31,1060,1530
33
+ 32,1150,3275
34
+ 33,305,3510
35
+ 34,1545,650
36
+ 35,765,1415
37
+ 36,1270,1760
38
+ 37,785,650
39
+ 38,1285,830
40
+ 39,980,560
41
+ 40,1435,850
42
+ 41,1085,0
43
+ 42,785,480
44
+ 43,1340,1150
45
+ 44,710,910
46
+ 45,1210,1050
47
+ 46,955,500
48
+ 47,1000,1230
49
+ 48,1165,1040
50
+ 49,1060,955
51
+ 50,1645,910
52
+ 51,2200,150
53
+ 52,1595,455
54
+ 53,1085,150
55
+ 54,455,830
56
+ 55,1400,455
57
+ 56,805,500
58
+ 57,1490,850
59
+ 58,1050,0
60
+ 59,560,980
61
+ 60,560,1040
62
+ 61,800,500
63
+ 62,1530,800
64
+ 63,0,1410
65
+ 64,3275,305
66
+ 65,3990,1570
67
+ 66,3510,1255
68
+ 67,1105,955
69
+ 68,650,150
70
+ 69,700,655
71
+ 70,1415,1245
72
+ 71,1295,455
73
+ 72,1760,710
74
+ 73,1235,560
75
+ 74,650,650
76
+ 75,500,1000
77
+ 76,830,760
78
+ 77,650,760
79
+ 78,560,350
80
+ 79,1240,305
81
+ 80,850,150
82
+ 81,1400,910
83
+ 82,0,650
84
+ 83,805,500
85
+ 84,480,1180
86
+ 85,150,1435
87
+ 86,1150,850
88
+ 87,1360,800
89
+ 88,910,1305
90
+ 89,1190,910
91
+ 90,1050,1260
92
+ 91,1115,455
93
+ 92,500,1000
94
+ 93,800,615
95
+ 94,1230,1265
96
+ 95,980,3955
97
+ 96,1040,3675
98
+ 97,500,615
99
+ 98,955,300
100
+ 99,1285,1825
101
+ 100,910,760
102
+ 101,980,1315
103
+ 102,150,1435
104
+ 103,1200,1260
105
+ 104,455,850
106
+ 105,480,1260
107
+ 106,150,1970
108
+ 107,500,1015
109
+ 108,830,350
110
+ 109,700,735
111
+ 110,455,1680
112
+ 111,150,350
113
+ 112,500,1135
114
+ 113,605,865
115
+ 114,850,1735
116
+ 115,805,850
117
+ 116,0,1165
118
+ 117,710,1965
119
+ 118,980,810
120
+ 119,305,1005
121
+ 120,1040,1200
122
+ 121,150,2885
123
+ 122,500,1095
124
+ 123,710,1060
125
+ 124,800,2455
126
+ 125,1265,2145
127
+ 126,1410,1665
128
+ 127,1175,3230
129
+ 128,305,4328
130
+ 129,1255,4228
131
+ 130,1570,4069
132
+ 131,980,3995
133
+ 132,1255,3946
134
+ 133,1480,3910
135
+ 134,955,3881
136
+ 135,455,3857
137
+ 136,150,3836
138
+ 137,910,3818
139
+ 138,655,3802
140
+ 139,350,3788
141
+ 140,1245,3774
142
+ 141,1150,3762
143
+ 142,455,3751
144
+ 143,560,3741
145
+ 144,710,3731
146
+ 145,150,3722
147
+ 146,560,3714
148
+ 147,830,3706
149
+ 148,650,3698
150
+ 149,655,3691
151
+ 150,1000,3684
152
+ 151,350,3677
153
+ 152,760,3671
154
+ 153,455,3665
155
+ 154,760,3659
156
+ 155,560,3654
157
+ 156,350,3648
158
+ 157,655,3643
159
+ 158,305,3638
160
+ 159,150,3633
161
+ 160,150,3629
162
+ 161,910,3624
163
+ 162,910,3620
164
+ 163,1190,3616
165
+ 164,650,3612
166
+ 165,455,3608
167
+ 166,500,3604
168
+ 167,500,3600
169
+ 168,1180,3596
170
+ 169,1500,3592
171
+ 170,1435,3589
172
+ 171,1265,3586
173
+ 172,850,3582
174
+ 173,650,3579
175
+ 174,800,3576
176
+ 175,1350,3573
177
+ 176,1305,3569
178
+ 177,1260,3566
179
+ 178,910,3563
180
+ 179,805,3561
181
+ 180,1260,3558
182
+ 181,1175,3555
183
+ 182,455,3552
184
+ 183,965,3550
185
+ 184,1000,3547
186
+ 185,755,3544
187
+ 186,615,3542
188
+ 187,350,3539
189
+ 188,1265,3537
190
+ 189,935,3534
191
+ 190,3955,3532
192
+ 191,4445,3530
193
+ 192,3675,3528
194
+ 193,1365,3530
195
+ 194,615,3532
196
+ 195,605,3534
197
+ 196,300,3537
198
+ 197,1135,3539
199
+ 198,1825,3542
200
+ 199,895,3544
201
+ 200,760,3547
202
+ 201,500,3550
203
+ 202,1315,3552
204
+ 203,1330,3555
205
+ 204,1435,3558
206
+ 205,1385,3561
207
+ 206,1260,3563
208
+ 207,920,3566
209
+ 208,850,3569
210
+ 209,615,3573
211
+ 210,1260,3576
212
+ 211,1545,3579
213
+ 212,1970,3582
214
+ 213,1605,3586
215
+ 214,1015,3589
216
+ 215,955,3592
217
+ 216,350,3596
218
+ 217,1270,3600
219
+ 218,735,3604
220
+ 219,1330,3608
221
+ 220,1680,3612
222
+ 221,630,3616
223
+ 222,350,3620
224
+ 223,1200,3624
225
+ 224,1135,3629
226
+ 225,850,3633
227
+ 226,865,3638
228
+ 227,1540,3643
229
+ 228,1735,3648
230
+ 229,500,3654
231
+ 230,850,3659
232
+ 231,150,3665
233
+ 232,1165,3671
234
+ 233,1345,3677
235
+ 234,1965,3684
236
+ 235,1630,3691
237
+ 236,810,3698
238
+ 237,1175,3706
239
+ 238,1005,3714
240
+ 239,500,3722
241
+ 240,1200,3731
242
+ 241,2830,3741
243
+ 242,2885,3751
244
+ 243,1630,3762
245
+ 244,1095,3774
246
+ 245,980,3788
247
+ 246,1060,3802
248
+ 247,1190,3818
249
+ 248,2455,3836
250
+ 249,3045,3857
251
+ 250,2145,3881
252
+ 251,1500,3910
253
+ 252,1665,3946
254
+ 253,1975,3995
255
+ 254,3230,
256
+ 255,3470,
257
+ 256,4328,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rfbeam
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Carruthers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-03-31 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -55,7 +55,8 @@ dependencies:
55
55
  description: Currently only tested with K-LD7 on MacOS & Raspian (bullseye)
56
56
  email:
57
57
  - robc@hey.com
58
- executables: []
58
+ executables:
59
+ - rfbeam
59
60
  extensions: []
60
61
  extra_rdoc_files: []
61
62
  files:
@@ -68,11 +69,14 @@ files:
68
69
  - LICENSE.txt
69
70
  - README.md
70
71
  - Rakefile
72
+ - exe/rfbeam
71
73
  - lib/rfbeam.rb
72
- - lib/rfbeam/kld7/app_commands.rb
73
- - lib/rfbeam/kld7/app_messages.rb
74
- - lib/rfbeam/kld7/connection.rb
74
+ - lib/rfbeam/cli.rb
75
75
  - lib/rfbeam/kld7/constants.rb
76
+ - lib/rfbeam/kld7/radar_messages.rb
77
+ - lib/rfbeam/kld7/radar_parameters.rb
78
+ - lib/rfbeam/kld7/serial_connection.rb
79
+ - lib/rfbeam/kld7/streamer.rb
76
80
  - lib/rfbeam/version.rb
77
81
  - node_modules/.bin/prettier
78
82
  - node_modules/.yarn-integrity
@@ -159,6 +163,7 @@ files:
159
163
  - node_modules/prettier/parser-yaml.js
160
164
  - node_modules/prettier/standalone.js
161
165
  - node_modules/prettier/third-party.js
166
+ - output.csv
162
167
  - package.json
163
168
  - rfbeam.gemspec
164
169
  - sig/rfbeam.rbs
@@ -1,201 +0,0 @@
1
- module RfBeam
2
- module KLD7
3
-
4
- # Base Frequency, 0 = low, 1 = middle (default), 2 = high
5
- def base_frequency
6
- data = grps
7
- data[3]
8
- end
9
- alias rbfr base_frequency
10
-
11
-
12
- def set_base_frequency(frequency = 1)
13
- value = case frequency
14
- when 0, :low, 'low'
15
- 0
16
- when 1, :middle, 'middle'
17
- 1
18
- when 2, :high, 'high'
19
- 2
20
- else
21
- raise ArgumentError, "Invalid arg: '#{frequency}'"
22
- end
23
- set_parameter(:rbfr, value, :uint8)
24
- end
25
- alias set_rbfr set_base_frequency
26
-
27
- # Maximum Speed, 0 = 12.5km/h, 1 = 25km/h (default), 2 = 50km/h, 3 = 100km/h
28
- def set_max_speed(speed = 1)
29
- set_parameter :rspi, speed, :uint8
30
- end
31
- alias rspi set_max_speed
32
-
33
- # Maximum Range, 0 = 5m, 1 = 10m (default), 2 = 30m, 3 = 100m
34
- def set_max_range(range = 1)
35
- set_parameter :rrai, range, :uint8
36
- end
37
- alias rrai set_max_range
38
-
39
- # Threshold Offset, 10 - 60db, (default = 30)
40
- def set_threshold_offset(offset = 30)
41
- range = 10..60
42
- return false unless range.include?(offset)
43
-
44
- set_parameter :thof, offset, :uint8
45
- end
46
- alias thof set_threshold_offset
47
-
48
- # Tracking filter type, 0 = Standard (Default), 1 = Fast Tracking, 2 = Long visibility
49
- def set_tracking_filter(type = 0)
50
- set_parameter :trft, type, :uint8
51
- end
52
- alias trtf set_tracking_filter
53
-
54
- # Vibration suppression, 0 - 16, 0 = No Suppression, 16 = High Suppression, default = 2
55
- def set_vibration_suppression(value = 2)
56
- set_parameter :visu, value, :uint8
57
- end
58
- alias visu set_vibration_suppression
59
-
60
- # Minimum Detection distance, 0 - 100% of Range setting, default = 0
61
- def set_min_detection_distance(value = 0)
62
- set_parameter :mira, value, :uint8
63
- end
64
- alias mira set_min_detection_distance
65
-
66
- # Maximum Detection distance, 0 - 100% of Range setting, default = 50
67
- def set_max_detection_distance(value = 50)
68
- set_parameter :mara, value, :uint8
69
- end
70
- alias mara set_max_detection_distance
71
-
72
- # Minimum Detection Angle, -90° - 90°, default = -90
73
- def set_min_detection_angle(angle = -90)
74
- set_parameter :mian, angle, :int8
75
- end
76
- alias mian set_min_detection_distance
77
-
78
- # Maximum Detection Angle, -90° - 90°, default = 90
79
- def set_max_detection_angle(angle = 90)
80
- set_parameter :maan, angle, :int8
81
- end
82
- alias maan set_max_detection_angle
83
-
84
- # Minimum Detection Speed, 0 - 100% of Speed setting, default = 0
85
- def set_min_detection_speed(speed = 0)
86
- set_parameter :misp, speed, :uint8
87
- end
88
- alias misp set_min_detection_speed
89
-
90
- # Maximum Detection Speed, 0 - 100% of Speed setting, default = 100
91
- def set_max_detection_speed(speed = 100)
92
- set_parameter :masp, speed, :uint8
93
- end
94
- alias masp set_max_detection_speed
95
-
96
- # Detection Direction, 0 = Receding, 1 = Approaching, 2 = Both (default)
97
- def set_detection_direction(direction = 2)
98
- set_parameter :dedi, direction, :uint8
99
- end
100
- alias dedi set_detection_direction
101
-
102
- # Range Threshold, 0 - 100% of Range setting, default = 10
103
- def set_range_threshold(value = 10)
104
- range = 0..100
105
- return false unless range.include?(value)
106
-
107
- set_parameter :rath, value, :uint8
108
- end
109
- alias rath set_range_threshold
110
-
111
- # Angle Threshold, -90° to 90°, default = 0
112
- def set_range_threshold(value = 0)
113
- range = -90..90
114
- return false unless range.include?(value)
115
-
116
- set_parameter :anth, value, :int8
117
- end
118
- alias anth set_range_threshold
119
-
120
- # Speed Threshold, 0 - 100% of speed setting, default = 50
121
- def set_angle_threshold(value = 50)
122
- range = 0..100
123
- return false unless range.include?(value)
124
-
125
- set_parameter :spth, value, :uint8
126
- end
127
- alias spth set_angle_threshold
128
-
129
- # Digital output 1, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 0
130
- def set_dio_1(value = 0)
131
- range = 0..4
132
- return false unless range.include?(value)
133
-
134
- set_parameter :dig1, value, :uint8
135
- end
136
- alias dig1 set_dio_1
137
-
138
- # Digital output 2, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 1
139
- def set_dio_2(value = 1)
140
- range = 0..4
141
- return false unless range.include?(value)
142
-
143
- set_parameter :dig2, value, :uint8
144
- end
145
- alias dig2 set_dio_2
146
-
147
- # Digital output 3, 0 = Direction, 1 = Angle, 2 = Range, 3 = Speed, 4 = Micro Detection, default = 2
148
- def set_dio_3(value = 2)
149
- range = 0..4
150
- return false unless range.include?(value)
151
-
152
- set_parameter :dig3, value, :uint8
153
- end
154
- alias dig3 set_dio_3
155
-
156
- # Hold Time, 1 - 7200s, default = 1
157
- def set_hold_time(time = 1)
158
- range = 1..7200
159
- return false unless range.include?(time)
160
-
161
- set_parameter :hold, time, :uint16
162
- end
163
- alias hold set_hold_time
164
-
165
- # Micro Detection retrigger, 0 = Off (default), 1 = Retrigger
166
- def set_micro_detection_retrigger(value = 0)
167
- return false unless [0, 1].include?(value)
168
-
169
- set_parameter :mide, value, :uint8
170
- end
171
- alias mide set_micro_detection_retrigger
172
-
173
- # Micro Detection sensitivity, 0 - 9, 0 = Min, 9 = Max, default = 4
174
- def set_micro_detection_sensitivty(value = 4)
175
- range = 0..9
176
- return false unless range.include?(value)
177
-
178
- set_parameter :mids, value, :uint8
179
- end
180
- alias mids set_micro_detection_sensitivty
181
-
182
- private
183
-
184
- def set_parameter(header, value, return_type = :uint8)
185
- return_type =
186
- case return_type
187
- when :uint8
188
- 'L'
189
- when :int8
190
- 'l'
191
- when :uint16
192
- 'S'
193
- else
194
- 'L'
195
- end
196
- command = [header.upcase.to_s, 4, value]
197
- write command.pack("a4L#{return_type}")
198
- check_response
199
- end
200
- end
201
- end
@@ -1,100 +0,0 @@
1
- module RfBeam
2
- module KLD7
3
- def detection?
4
- data = ddat
5
- (data[2] == 1)
6
- end
7
-
8
- def pdat(formatted: false)
9
- request_frame_data(:pdat)
10
- resp = read(102).unpack('a4LSssSSssSSssSSssSSssSSssSSssSSssSSssSSssS')
11
- return resp unless formatted
12
-
13
- target_count = resp[1].to_i / 8
14
- return [] unless target_count > 0
15
-
16
- resp.shift 2
17
- resp.compact
18
- detected_raw_targets = []
19
- target_count.times { detected_raw_targets << format_raw_target_data(resp.shift(4)) }
20
- detected_raw_targets
21
- end
22
-
23
- def tdat
24
- request_frame_data(:tdat)
25
-
26
- sleep 0.1
27
- resp = read(16).unpack('a4LSssS')
28
- return { dist: resp[2], speed: resp[3], angle: resp[4], mag: resp[5] } unless resp[1].zero?
29
- end
30
-
31
- def ddat
32
- request_frame_data(:ddat)
33
-
34
- read(14).unpack('a4LC6')
35
- end
36
-
37
- def config
38
- puts formatted_grps(grps)
39
- end
40
-
41
- def formatted_parameter(param)
42
- return unless PARAMETERS.include? param
43
-
44
- param_data = PARAMETERS[param]
45
- grps_data = grps
46
- index = grps_data[param_data[:grps_index]]
47
- param_data[:values][index]
48
- end
49
-
50
- # Get the radar parameter structure
51
- def grps
52
- command = ['GRPS', 0]
53
- write command.pack('a4L')
54
- check_response
55
- read(50).unpack('a4LA19C8c2C4cCCCCSCC')
56
- end
57
-
58
-
59
- private
60
-
61
- def format_raw_target_data(array)
62
- { dist: array.shift, speed: array.shift, angle: array.shift, mag: array.shift }
63
- end
64
-
65
- def request_frame_data(type)
66
- command = ['GNFD', 4, FRAME_DATA_TYPES[type]]
67
- write command.pack('a4LL')
68
- check_response
69
- end
70
-
71
- def formatted_grps(data)
72
- output = "\n"
73
- output << "Software Version: #{data[2]}\n"
74
- output << "Base Frequency: #{PARAMETER_STRUCTURE[:base_frequency][data[3]]}\n"
75
- output << "Max Speed: #{PARAMETER_STRUCTURE[:max_speed][data[4]]}\n"
76
- output << "Max Range: #{PARAMETER_STRUCTURE[:max_range][data[5]]}\n"
77
- output << "Threshold offset: #{data[6]}db\n"
78
- output << "Tracking Filter Type: #{PARAMETER_STRUCTURE[:tracking_filter_type][data[7]]}\n"
79
- output << "Vibration Suppression: #{data[8]} , (#{PARAMETER_STRUCTURE[:vibration_suppression]})\n"
80
- output << "Minimum Detection Distance: #{data[9]} , (#{PARAMETER_STRUCTURE[:min_detection_distance]})\n"
81
- output << "Maximum Detection Distance: #{data[10]} , (#{PARAMETER_STRUCTURE[:max_detection_distance]})\n"
82
- output << "Minimum Detection Angle: #{data[11]}° , (#{PARAMETER_STRUCTURE[:min_detection_angle]})\n"
83
- output << "Maximum Detection Angle: #{data[12]}° , (#{PARAMETER_STRUCTURE[:max_detection_angle]})\n"
84
- output << "Minimum Detection Speed: #{data[13]} , (#{PARAMETER_STRUCTURE[:min_detection_speed]})\n"
85
- output << "Maximum Detection Speed: #{data[14]} , (#{PARAMETER_STRUCTURE[:max_detection_speed]})\n"
86
- output << "Detection Direction: #{PARAMETER_STRUCTURE[:detection_direction][data[15]]}\n"
87
- output << "Range Threshold: #{data[16]}%, (#{PARAMETER_STRUCTURE[:range_threshold]})\n"
88
- output << "Angle Threshold: #{data[17]}°, (#{PARAMETER_STRUCTURE[:angle_threshold]})\n"
89
- output << "Speed Threshold: #{data[18]}%, (#{PARAMETER_STRUCTURE[:speed_threshold]})\n"
90
- output << "Digital output 1: #{PARAMETER_STRUCTURE[:digital_output_1][data[19]]}\n"
91
- output << "Digital output 2: #{PARAMETER_STRUCTURE[:digital_output_2][data[20]]}\n"
92
- output << "Digital output 3: #{PARAMETER_STRUCTURE[:digital_output_3][data[21]]}\n"
93
- output << "Hold time: #{data[22]}sec\n"
94
- output << "Micro Detection Retrigger: #{PARAMETER_STRUCTURE[:micro_detection_trigger][data[23]]}\n"
95
- output << "Micro Detection Sensitivity: #{data[24]} (#{PARAMETER_STRUCTURE[:micro_detection_sensitivity]})"
96
-
97
- output
98
- end
99
- end
100
- end