Skip to content

Commit 2981758

Browse files
authored
Merge pull request #847 from OpenC3/disconnect
Expand allowed methods in disconnect mode
2 parents d1be81f + 5aca4e3 commit 2981758

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

openc3-cosmos-init/plugins/packages/openc3-cosmos-demo/targets/INST/procedures/stash.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Stash API is useful for storing simple key/value pairs
22
# to preserve state between script runs
33
stash_set('key1', 'val1')
4+
puts "key1: #{stash_get('key1')}"
45
stash_set('key2', 'val2')
6+
puts "key2: #{stash_get('key2')}"
57
check_expression("'#{stash_get('key1')}' == 'val1'")
68
check_expression("'#{stash_get('key2')}' == 'val2'")
79
check_expression("'#{stash_keys().to_s}' == '[\"key1\", \"key2\"]'")

openc3/lib/openc3/script/script.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ def method_missing(method_name, *method_params, **kw_params)
260260
disconnect = kw_params.delete(:disconnect)
261261
# The only commands allowed through in disconnect mode are read-only
262262
# Thus we allow the get, list, tlm and limits_enabled and subscribe methods
263-
if method_name =~ /get_\w*|list_\w*|^tlm|limits_enabled|subscribe/
263+
if method_name =~ /\w*_get$|^get_\w*|\w*_list$|^list_\w*|^tlm|^limits_enabled$|^subscribe$/
264264
result = @json_drb.method_missing(method_name, *method_params, **kw_params)
265265
end
266266
# If they overrode the return value using the disconnect keyword then return that

openc3/spec/script/script_spec.rb

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,12 @@ module OpenC3
5252
# Test that the disconnect mode value doesn't matter if we're connected
5353
expect(tlm("INST HEALTH_STATUS TEMP1", disconnect: 10)).to be_nil
5454
get_command("INST ABORT")
55+
stash_set("SOMETHING")
56+
stash_get("SOMETHING")
57+
list_configs()
5558
set_limits("INST", "HEALTH_STATUS", "TEMP1", 0.0, 10.0, 20.0, 30.0)
5659
inject_tlm("INST", "HEALTH_STATUS", { TEMP1: 0, TEMP2: 0, TEMP3: 0, TEMP4: 0 })
57-
58-
expect(@methods).to eql %i(set_tlm tlm get_command set_limits inject_tlm)
60+
expect(@methods).to eql %i(set_tlm tlm get_command stash_set stash_get list_configs set_limits inject_tlm)
5961
end
6062

6163
it "disconnect_script should only allow read only methods" do
@@ -65,11 +67,14 @@ module OpenC3
6567
# Test that we can override the return value in disconnect mode
6668
expect(tlm("INST HEALTH_STATUS TEMP1", disconnect: 10)).to eql 10
6769
get_command("INST ABORT")
70+
stash_set("SOMETHING")
71+
stash_get("SOMETHING")
72+
list_configs()
6873
set_limits("INST", "HEALTH_STATUS", "TEMP1", 0.0, 10.0, 20.0, 30.0)
6974
inject_tlm("INST", "HEALTH_STATUS", { TEMP1: 0, TEMP2: 0, TEMP3: 0, TEMP4: 0 })
7075

7176
# In disconnect we don't pass through set commands or inject_tlm
72-
expect(@methods).to eql %i(tlm get_command)
77+
expect(@methods).to eql %i(tlm get_command stash_get list_configs)
7378
end
7479
end
7580
end

0 commit comments

Comments
 (0)