Skip to content

Commit e5d4af2

Browse files
committed
Fix array of strings
1 parent ae28e90 commit e5d4af2

File tree

8 files changed

+23
-24
lines changed

8 files changed

+23
-24
lines changed

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/cmd_tlm/inst_tlm.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ TELEMETRY <%= target_name %> MECH BIG_ENDIAN "Mechanism status ©®"
169169
UNITS DEGREES DEG
170170
APPEND_ITEM CURRENT 32 FLOAT "Device current"
171171
UNITS micro-Ampères µA
172-
APPEND_ITEM STRING 0 STRING "String"
172+
APPEND_ARRAY_ITEM STRINGS 2048 STRING 0 "Array of strings"
173173
ITEM PACKET_TIME 0 0 DERIVED "Ruby time based on TIMESEC and TIMEUS"
174174
READ_CONVERSION unix_time_conversion.rb TIMESEC TIMEUS
175175

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/lib/sim_inst.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ def read(count_100hz, time)
428428
packet.slrpnl4 = @solar_panel_positions[3]
429429
packet.slrpnl5 = @solar_panel_positions[4]
430430
packet.current = 0.5
431+
packet.strings = ['STRING1'.ljust(256, "\x00"), 'STRING2'.ljust(256, "\x00"), 'STRING3'.ljust(256, "\x00")]
432+
packet.CcsdsLength = packet.buffer.length - 7
431433

432434
when 'HIDDEN'
433435
packet.timesec = time.tv_sec - @time_offset

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/screens/array.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ VERTICAL
1717
ARRAY <%= target_name %> HEALTH_STATUS ARY2 300 65 nil 5 WITH_UNITS
1818
TEXTBOX <%= target_name %> HEALTH_STATUS ARY 200 65
1919
TEXTBOX <%= target_name %> HEALTH_STATUS ARY2 300 65
20-
ARRAY <%= target_name %> HEALTH_STATUS GROUND1STATUS 300 65 nil 8 FORMATTED
21-
ARRAY <%= target_name %> HEALTH_STATUS GROUND2STATUS 300 65 nil 5 WITH_UNITS
20+
ARRAY <%= target_name %> MECH STRINGS 300
2221
END

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/cmd_tlm/inst_tlm.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ TELEMETRY <%= target_name %> MECH BIG_ENDIAN "Mechanism status ©®"
163163
UNITS DEGREES DEG
164164
APPEND_ITEM CURRENT 32 FLOAT "Device current"
165165
UNITS micro-Ampères µA
166-
APPEND_ITEM STRING 0 STRING "String"
166+
APPEND_ARRAY_ITEM STRINGS 2048 STRING 0 "Array of strings"
167167
ITEM PACKET_TIME 0 0 DERIVED "Python time based on TIMESEC and TIMEUS"
168168
READ_CONVERSION openc3/conversions/unix_time_conversion.py TIMESEC TIMEUS
169169

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/lib/sim_inst.py

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,11 @@ def set_rates(self):
157157
self.set_rate("PARAMS.PKT", 100)
158158
self.set_rate("IMAGE", 100)
159159
self.set_rate("MECH", 10)
160-
self.set_rate('JSONTLM', 500)
161-
self.set_rate('CBORTLM', 500)
162-
self.set_rate('XMLTLM', 500)
163-
self.set_rate('HTMLTLM', 500)
164-
self.set_rate('HYBRIDTLM', 500)
160+
self.set_rate("JSONTLM", 500)
161+
self.set_rate("CBORTLM", 500)
162+
self.set_rate("XMLTLM", 500)
163+
self.set_rate("HTMLTLM", 500)
164+
self.set_rate("HYBRIDTLM", 500)
165165

166166
def tick_period_seconds(self):
167167
return 0.1 # Override this method to optimize
@@ -430,7 +430,15 @@ def read(self, count_100hz, time):
430430
packet.write("slrpnl4", self.solar_panel_positions[3])
431431
packet.write("slrpnl5", self.solar_panel_positions[4])
432432
packet.write("current", 0.5)
433-
packet.write("string", f"Time is {time}")
433+
packet.write(
434+
"strings",
435+
[
436+
"STRING1".ljust(256, "\x00"),
437+
"STRING2".ljust(256, "\x00"),
438+
"STRING3".ljust(256, "\x00"),
439+
],
440+
)
441+
packet.write("CcsdsLength", len(packet.buffer) - 7)
434442

435443
# Every 10s throw an unknown packet at the server just to demo that
436444
if count_100hz % 1000 == 900:

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST2/screens/array.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,5 @@ VERTICAL
1717
ARRAY <%= target_name %> HEALTH_STATUS ARY2 300 65 nil 5 WITH_UNITS
1818
TEXTBOX <%= target_name %> HEALTH_STATUS ARY 200 65
1919
TEXTBOX <%= target_name %> HEALTH_STATUS ARY2 300 65
20-
ARRAY <%= target_name %> HEALTH_STATUS GROUND1STATUS 300 65 nil 8 FORMATTED
21-
ARRAY <%= target_name %> HEALTH_STATUS GROUND2STATUS 300 65 nil 5 WITH_UNITS
20+
ARRAY <%= target_name %> MECH STRINGS 300
2221
END

openc3/lib/openc3/api/tlm_api.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,8 @@ def get_tlm_available(items, manual: false, scope: $openc3_scope, token: $openc3
284284
value_type = 'RAW' # Must request the raw value when dealing with the reserved items
285285
end
286286

287-
# QuestDB 9.0.0 only supports DOUBLE arrays: https://questdb.com/docs/concept/array/
287+
# Arrays must be accessed as RAW since there's no conversion
288288
if item['array_size']
289-
# TODO: This needs work ... we're JSON encoding non numeric array values
290-
if item['data_type'] == 'STRING' or item['data_type'] == 'BLOCK'
291-
results << nil
292-
next
293-
end
294289
value_type = 'RAW'
295290
end
296291

openc3/python/openc3/api/tlm_api.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,8 @@ def get_tlm_available(items, manual=False, scope=OPENC3_SCOPE):
306306
if item_name in Packet.RESERVED_ITEM_NAMES:
307307
value_type = 'RAW' # Must request the raw value when dealing with the reserved items
308308

309-
# QuestDB 9.0.0 only supports DOUBLE arrays: https://questdb.com/docs/concept/array/
310-
if item_config.get('array_size'):
311-
# TODO: This needs work ... we're JSON encoding non numeric array values
312-
if item_config.get('data_type') in ['STRING', 'BLOCK']:
313-
results.append(None)
314-
continue
309+
# Arrays must be accessed as RAW since there's no conversion
310+
if item_config.get('array_size') is not None:
315311
value_type = 'RAW'
316312

317313
# Determine the best available value type based on item configuration

0 commit comments

Comments
 (0)