Skip to content

Commit

Permalink
Merge pull request #431 from openxc/emulator-diagnostic-responses
Browse files Browse the repository at this point in the history
Improve Emulator Diagnostic Responses
  • Loading branch information
pjt0620 authored Jan 23, 2020
2 parents b52f17c + b8ea11d commit 616c094
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
9 changes: 8 additions & 1 deletion fabfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,15 @@ 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' and os.path.exists("src/signals.cpp"):
with quiet():
local(f"mv signals.cpp signals.cpp.oxc")
output = local("%s make -j1 " % options, capture=capture)
if env.mode == 'emulator' and os.path.exists("src/signals.cpp.oxc"):
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.")
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 616c094

Please sign in to comment.