cosmos-ccsds_transfer_frames 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89006d10884c558d15f95aa5f4ac33f318c30445
|
4
|
+
data.tar.gz: 8ed81aa7a0264e5756eeadf6af8582c018f74c87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ec01cbd0780df0f5b7166fdc5d233efeec9e20be86ebf9344d7808a92ce1f8d0e99406d44b0e9fc729051535177830fd4879c29b26ac261ccf4e883dfaa69a7
|
7
|
+
data.tar.gz: a691e88527df7288fefbf9ce714d0d02fe62775a1f30b250a0461a652ccfe4836d7a0eca5f628e8736fde410dbf14f2864379b5d07ca7d5d3f4cd3efab2a0565
|
data/README.md
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
# Cosmos::CcsdsTransferFrames
|
2
2
|
|
3
|
-
This gem contains a CCSDS transfer frame protocol for use with the Ball Aerospace COSMOS application.
|
3
|
+
This gem contains a [CCSDS](https://public.ccsds.org/default.aspx) transfer frame protocol for use with the [Ball Aerospace COSMOS application](http://cosmosrb.com).
|
4
4
|
|
5
5
|
The protocol extracts CCSDS space packets from CCSDS transfer frames, optionally prefixing each packet with the transfer frame headers of the frame where it started.
|
6
6
|
|
7
|
+
See [CCSDS 132.0-B-2 - TM Space Data Link Protocol. Blue Book.](https://public.ccsds.org/Pubs/132x0b2.pdf) and [CCSDS 133.0-B-1 - Space Packet Protocol. Blue Book.](https://public.ccsds.org/Pubs/133x0b1c2.pdf) for detailed information.
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
|
-
This gem is intended to be installed as a
|
11
|
+
This gem is intended to be installed as a [gem based target/tool](http://cosmosrb.com/docs/gemtargets/) in COSMOS and made available for use as a normal protocol in a target command and telemetry server configuration. Note that the protocol provided in this gem is neither a target nor a tool in the COSMOS sense.
|
10
12
|
|
11
13
|
In order to make this protocol available for use in your COSMOS targets, add this line to the Gemfile of your COSMOS project:
|
12
14
|
|
@@ -45,7 +47,7 @@ This would set up the protocol to expect transfer frames with:
|
|
45
47
|
* No prefixing of packets (default).
|
46
48
|
* Discarding of idle packets (default).
|
47
49
|
|
48
|
-
For detailed information about the available configuration parameters for the protocol, please consult the yard inline source code documentation in
|
50
|
+
For detailed information about the available configuration parameters for the protocol, please consult the yard inline source code documentation in [ccsds_transfer_frame_protocol.rb](lib/cosmos/ccsds_transfer_frames/ccsds_transfer_frame_protocol.rb) or the generated documentation for the currently published gem at https://www.rubydoc.info/gems/cosmos-ccsds_transfer_frames/Cosmos/CcsdsTransferFrames/CcsdsTransferFrameProtocol
|
49
51
|
|
50
52
|
## Development
|
51
53
|
|
@@ -132,7 +132,7 @@ module Cosmos
|
|
132
132
|
#
|
133
133
|
# @return [String] Packet data, if the queues contained at least one
|
134
134
|
# complete packet.
|
135
|
-
# @return [Symbol] :STOP, if the queues
|
135
|
+
# @return [Symbol] :STOP, if the queues do not contain any complete
|
136
136
|
# packets.
|
137
137
|
def get_packet
|
138
138
|
@virtual_channels.each do |vc|
|
@@ -182,35 +182,58 @@ module Cosmos
|
|
182
182
|
|
183
183
|
frame_data_field = frame[@frame_headers_length, @frame_data_field_length]
|
184
184
|
|
185
|
-
|
186
|
-
return if (Symbol === status && status == :STOP)
|
185
|
+
handle_packet_continuation(virtual_channel, frame_data_field, first_header_pointer)
|
187
186
|
|
188
|
-
if (
|
189
|
-
# No continuation packet was completed, and a packet starts in this
|
190
|
-
# frame. Utilise the first header pointer to re-sync to a packet start.
|
191
|
-
frame_data_field.replace(frame_data_field[first_header_pointer..-1])
|
192
|
-
end
|
187
|
+
return if (first_header_pointer == NO_PACKET_START_FIRST_HEADER_POINTER)
|
193
188
|
|
194
|
-
frame_headers = frame[0, @frame_headers_length]
|
189
|
+
frame_headers = frame[0, @frame_headers_length]
|
195
190
|
store_packets(virtual_channel, frame_headers, frame_data_field)
|
196
191
|
end
|
197
192
|
|
198
193
|
# Handle packet continuation when processing a transfer frame.
|
199
194
|
#
|
200
|
-
#
|
201
|
-
# header to determine its length and then
|
202
|
-
#
|
195
|
+
# First ensures that any incomplete packet has enough data for the packet
|
196
|
+
# header to determine its length and then tries to complete it.
|
197
|
+
#
|
198
|
+
# If the first header pointer indicates that a packet starts in this
|
199
|
+
# frame, the frame_data_field parameter will be modified by removing
|
200
|
+
# everything before the first header pointer.
|
203
201
|
#
|
204
202
|
# @param virtual_channel [Int] Transfer frame virtual channel.
|
205
203
|
# @param frame_data_field [String] Transfer frame data field.
|
206
204
|
# @param first_header_pointer [Int] First header pointer value.
|
207
205
|
def handle_packet_continuation(virtual_channel, frame_data_field, first_header_pointer)
|
208
206
|
vc = @virtual_channels[virtual_channel]
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
207
|
+
|
208
|
+
if (vc.packet_queue.length == 0 ||
|
209
|
+
vc.pending_incomplete_packet_bytes_left == 0)
|
210
|
+
# no packet in queue to be continued
|
211
|
+
|
212
|
+
return if (first_header_pointer == NO_PACKET_START_FIRST_HEADER_POINTER)
|
213
|
+
|
214
|
+
frame_data_field.replace(frame_data_field[first_header_pointer..-1])
|
215
|
+
return
|
216
|
+
end
|
217
|
+
|
218
|
+
packet_continuation = nil
|
219
|
+
if (first_header_pointer == NO_PACKET_START_FIRST_HEADER_POINTER)
|
220
|
+
packet_continuation = frame_data_field
|
221
|
+
else
|
222
|
+
packet_continuation = frame_data_field.slice!(0, first_header_pointer)
|
223
|
+
end
|
224
|
+
|
225
|
+
if (vc.packet_queue[-1].length < @packet_prefix_length + SPACE_PACKET_HEADER_LENGTH)
|
226
|
+
# Pending incomplete packet does not yet heave header, try to
|
227
|
+
# complete header and get length before processing further.
|
228
|
+
rest_of_packet_header_length = vc.pending_incomplete_packet_bytes_left
|
229
|
+
if (rest_of_packet_header_length > packet_continuation.length)
|
230
|
+
# Not enough continuation to complete packet header, first header
|
231
|
+
# pointer takes precedence and packet is cut short.
|
232
|
+
vc.packet_queue[-1] << packet_continuation
|
233
|
+
vc.pending_incomplete_packet_bytes_left = 0
|
234
|
+
return
|
235
|
+
end
|
236
|
+
vc.packet_queue[-1] << packet_continuation.slice!(0, rest_of_packet_header_length)
|
214
237
|
|
215
238
|
space_packet_length = get_space_packet_length(vc.packet_queue[-1][@packet_prefix_length..-1])
|
216
239
|
throw "failed to get space packet length" if Symbol === space_packet_length && space_packet_length == :STOP
|
@@ -218,25 +241,46 @@ module Cosmos
|
|
218
241
|
vc.pending_incomplete_packet_bytes_left = space_packet_length - SPACE_PACKET_HEADER_LENGTH
|
219
242
|
end
|
220
243
|
|
221
|
-
if (
|
222
|
-
#
|
223
|
-
|
244
|
+
if (first_header_pointer == NO_PACKET_START_FIRST_HEADER_POINTER)
|
245
|
+
# packet continues past this frame or ends exactly at end of this
|
246
|
+
# frame according to first header pointer
|
247
|
+
|
248
|
+
if (vc.pending_incomplete_packet_bytes_left < packet_continuation.length)
|
249
|
+
# Packet length is inconsistent with first header pointer, since it
|
250
|
+
# indicates that the packet ends before the end of this frame.
|
251
|
+
#
|
252
|
+
# Complete the packet based on the packet length and ignore the
|
253
|
+
# rest of the data in the frame (will use first header pointer to
|
254
|
+
# re-sync with start of next packet in a later frame).
|
255
|
+
vc.packet_queue[-1] << packet_continuation[0, vc.pending_incomplete_packet_bytes_left]
|
256
|
+
vc.pending_incomplete_packet_bytes_left = 0
|
257
|
+
return
|
258
|
+
end
|
259
|
+
|
260
|
+
# First header pointer and packet length are consistent, append whole frame.
|
261
|
+
vc.packet_queue[-1] << packet_continuation
|
224
262
|
vc.pending_incomplete_packet_bytes_left -= frame_data_field.length
|
225
|
-
return
|
263
|
+
return
|
226
264
|
end
|
227
265
|
|
228
|
-
|
229
|
-
|
230
|
-
# an ignored idle packet), wait for another frame to find a packet
|
231
|
-
# start.
|
232
|
-
return :STOP
|
233
|
-
end
|
266
|
+
# packet ends before the end of this frame according to first header
|
267
|
+
# pointer
|
234
268
|
|
235
|
-
if (vc.pending_incomplete_packet_bytes_left
|
236
|
-
|
237
|
-
|
238
|
-
|
269
|
+
if (vc.pending_incomplete_packet_bytes_left < packet_continuation.length)
|
270
|
+
# Packet length is inconsistent with first header pointer, since it
|
271
|
+
# indicates that the packet ends before the first header pointer.
|
272
|
+
#
|
273
|
+
# Complete the packet based on the packet length and ignore the data
|
274
|
+
# between the packet end and the first header pointer.
|
275
|
+
packet_continuation.replace(packet_continuation[0, vc.pending_incomplete_packet_bytes_left])
|
239
276
|
end
|
277
|
+
|
278
|
+
# If the packet length is too long compared to the first header
|
279
|
+
# pointer, the first header pointer takes precedence and the packet is
|
280
|
+
# cut short.
|
281
|
+
|
282
|
+
vc.packet_queue[-1] << packet_continuation
|
283
|
+
vc.pending_incomplete_packet_bytes_left = 0
|
240
284
|
end
|
241
285
|
|
242
286
|
# Extract all packets from the remaining frame data field, and store them
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cosmos-ccsds_transfer_frames
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Erik Werner
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cosmos
|