Skip to content

Commit

Permalink
Merge pull request #1674 from OpenC3/completion
Browse files Browse the repository at this point in the history
Handle BLOCK and STRING params in autocomplete
  • Loading branch information
ryanmelt authored Oct 28, 2024
2 parents 6be77b6 + 0df61e6 commit 6cc33e6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,14 @@ def build_cmd_snippet(packet, target_info)
end
if filtered_items.any?
params = filtered_items.each_with_index.map do |item, index|
default = item['default'] || 0
if item['data_type'] == 'BLOCK'
# Unpack binary data to uppercase hex string
default = "0x#{item['default'].unpack('H*').first.upcase}"
elsif item['data_type'] == 'STRING'
default = "'#{item['default']}'" || ''
else
default = item['default'] || 0
end
if item.key? 'states'
default_state = item['states'].find { |_key, val| val['value'] == default }
default = default_state[0] if default_state
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
# Sorted so first should be INST ABORT
expect(ret[0]).to include({"caption" => "INST ABORT"})
# Spot check
expect(ret).to include({"caption"=>"INST ASCIICMD",
"snippet"=>"INST ASCIICMD with STRING ${1:'NOOP'}, BINARY ${2:0xDEADBEEF}, ASCII ${3:'0xDEADBEEF'}",
"meta"=>"command"})
expect(ret).to include({"caption"=>"INST COLLECT",
"snippet"=>"INST COLLECT with TYPE ${1:NORMAL}, DURATION ${2:1.0}, OPCODE ${3:171}, TEMP ${4:0.0}",
"meta"=>"command"})
Expand Down
20 changes: 11 additions & 9 deletions openc3/spec/install/config/targets/INST/cmd_tlm/inst_cmds.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,20 @@ COMMAND INST SETPARAMS BIG_ENDIAN "Sets numbered parameters"
DISABLE_MESSAGES

COMMAND INST ASCIICMD BIG_ENDIAN "Enumerated ASCII command"
PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS primary header version number"
PARAMETER CCSDSTYPE 3 1 UINT 1 1 1 "CCSDS primary header packet type"
PARAMETER CCSDSSHF 4 1 UINT 0 0 0 "CCSDS primary header secondary header flag"
ID_PARAMETER CCSDSAPID 5 11 UINT 0 2047 999 "CCSDS primary header application id"
PARAMETER CCSDSSEQFLAGS 16 2 UINT 3 3 3 "CCSDS primary header sequence flags"
PARAMETER CCSDSSEQCNT 18 14 UINT 0 16383 0 "CCSDS primary header sequence count"
PARAMETER CCSDSLENGTH 32 16 UINT 0 65535 0 "CCSDS primary header packet length"
ID_PARAMETER PKTID 48 16 UINT 0 65535 5 "Packet id"
PARAMETER STRING 64 2048 STRING "NOOP" "Enumerated string parameter"
APPEND_PARAMETER CCSDSVER 3 UINT 0 0 0 "CCSDS primary header version number"
APPEND_PARAMETER CCSDSTYPE 1 UINT 1 1 1 "CCSDS primary header packet type"
APPEND_PARAMETER CCSDSSHF 1 UINT 0 0 0 "CCSDS primary header secondary header flag"
APPEND_ID_PARAMETER CCSDSAPID 11 UINT 0 2047 999 "CCSDS primary header application id"
APPEND_PARAMETER CCSDSSEQFLAGS 2 UINT 3 3 3 "CCSDS primary header sequence flags"
APPEND_PARAMETER CCSDSSEQCNT 14 UINT 0 16383 0 "CCSDS primary header sequence count"
APPEND_PARAMETER CCSDSLENGTH 16 UINT 0 65535 0 "CCSDS primary header packet length"
APPEND_ID_PARAMETER PKTID 16 UINT 0 65535 5 "Packet id"
APPEND_PARAMETER STRING 2048 STRING "NOOP" "Enumerated string parameter"
STATE "NOOP" "NOOP" DISABLE_MESSAGES
STATE "ARM LASER" "ARM LASER" HAZARDOUS "Arming the laser poses an eye safety hazard."
STATE "FIRE LASER" "FIRE LASER" HAZARDOUS "WARNING Laser will be fired!"
APPEND_PARAMETER BINARY 32 BLOCK 0xDEADBEEF "Binary string"
APPEND_PARAMETER ASCII 80 STRING "0xDEADBEEF" "ASCII string"

COMMAND INST FLTCMD BIG_ENDIAN "Command with float parameters"
PARAMETER CCSDSVER 0 3 UINT 0 0 0 "CCSDS primary header version number"
Expand Down

0 comments on commit 6cc33e6

Please sign in to comment.