Skip to content

Commit

Permalink
Fixed emulator diagnostic responses
Browse files Browse the repository at this point in the history
  • Loading branch information
PPRAKA30 committed Jan 23, 2020
1 parent 2cda5e4 commit 27c1868
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
19 changes: 18 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,25 @@ def build(capture=False, do_clean=False):
options = build_options()
with lcd("%s/src" % env.root_dir):
if do_clean:
clean();
clean()
if env.mode == 'emulator':
try:
f = open("src/signals.cpp")
f.close()
with quiet():
local(f"mv signals.cpp signals.cpp.oxc")
except:
pass
output = local("%s make -j1 " % options, capture=capture)
if env.mode == 'emulator':
try:
f = open(f"src/signals.cpp.oxc")
f.close()
with quiet():
local(f"mv signals.cpp.oxc signals.cpp")
print("Since this is an emulator build, your signals.cpp was backed up and restored.")
except:
pass
if output.failed:
puts(output)
abort(red("Building %s failed" % board_options['name']))
Expand Down
16 changes: 12 additions & 4 deletions src/diagnostics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,10 +689,18 @@ bool openxc::diagnostics::handleDiagnosticCommand(
message.diagnostic_response.mode = commandRequest->mode;
message.diagnostic_response.pid = commandRequest->pid;

openxc_DynamicField value = openxc_DynamicField(); // Zero fill
value.type = openxc_DynamicField_Type_NUM;
value.numeric_value = rand() % 100;
message.diagnostic_response.value = value;
message.diagnostic_response.success = rand() & 1;
if (message.diagnostic_response.success)
{
openxc_DynamicField value = openxc_DynamicField(); // Zero fill
value.type = openxc_DynamicField_Type_NUM;
value.numeric_value = rand() % 100;
message.diagnostic_response.value = value;
}
else
{
message.diagnostic_response.negative_response_code = rand() % 15 + 1;
}

debug("Response message id: %d", message.diagnostic_response.message_id);
pipeline::publish(&message, &getConfiguration()->pipeline);
Expand Down

0 comments on commit 27c1868

Please sign in to comment.