Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

door_status not coming through #263

Closed
zacnelson opened this issue Sep 5, 2014 · 4 comments
Closed

door_status not coming through #263

zacnelson opened this issue Sep 5, 2014 · 4 comments
Assignees
Labels

Comments

@zacnelson
Copy link

Looks like shared_handlers has changed with v6.X of vi-firmware and our previous implementation of door_status signals is no longer working.

I've modified the doorStatusDecoder(...) such that it is now returns an openxc_DynamicField. I will create an issue branch from next and get this working. Below are the changes I made to shared_handlers.

Right now, I'm getting an issue where the call to publishVehicleMessage(...) is causing the VI to hang and stall.

openxc_DynamicField openxc::signals::handlers::doorStatusDecoder(CanSignal* signal,
        CanSignal* signals, int signalCount,
        Pipeline* pipeline, float value, bool* send) {
    openxc_DynamicField ajarStatus = booleanDecoder(signal, signals, signalCount, 
            pipeline, value, send);
    *send = openxc::can::read::shouldSend(signal, value);
    if(send) {
        openxc_DynamicField doorIdValue = {0};
        doorIdValue.has_type = true;
        doorIdValue.type = openxc_DynamicField_Type_STRING;
        doorIdValue.has_string_value = true;
        if(!strcmp(signal->genericName, "driver_door")) {
            strcpy(doorIdValue.string_value, "driver");
        } else if(!strcmp(signal->genericName, "passenger_door")) {
            strcpy(doorIdValue.string_value, "passenger");
        } else if(!strcmp(signal->genericName, "rear_right_door")) {
            strcpy(doorIdValue.string_value, "rear_right");
        } else if(!strcmp(signal->genericName, "rear_left_door")) {
            strcpy(doorIdValue.string_value, "rear_left");
        } else {
            strcpy(doorIdValue.string_value, signal->genericName);
        }
        publishVehicleMessage(
                openxc::signals::handlers::DOOR_STATUS_GENERIC_NAME,
                &doorIdValue, &ajarStatus, pipeline);
    }

    // Block the normal sending, we overrode it
    *send = false;
    return openxc::payload::wrapNumber(0);
}

The door_status signals are mapped in the following format:

"Driver_door_status_signal": {
    "generic_name": "driver_door",
    "decoder": "doorStatusDecoder",
    "send_same": false
},

The idea is that the door_status event-based signals are only sent when something changes (i.e. when a door opens or closes.)

Any thoughts why publishVehicleMessage crashes? Commenting out that line fixes the crash, but then I don't get any JSON output, of course.

@zacnelson zacnelson self-assigned this Sep 5, 2014
@peplin peplin added in progress and removed ready labels Oct 3, 2014
peplin added a commit that referenced this issue Oct 5, 2014
@peplin
Copy link
Member

peplin commented Oct 5, 2014

Thanks for the help finding this bug, Zac. I think it's fixed now. There were two problems:

  • The doorStatusDecoder and tirePressureDecoder had a call to decodeSignal, which would end up being a recursive call when running the full VI stack. It needed to be a more specific decoder, i.e. booleanDecoder as you have it.
  • Signal decoders were being passed NULL as the pipeline argument (https://github.com/openxc/vi-firmware/blob/master/src/can/canread.cpp#L236). I've added a unit tests for this and fixed it so it passes in the proper, global output pipeline object. I think this was the root cause of your crash - inside publishVehicleMessage it would try to use the pipeline, but it was NULL.

@peplin
Copy link
Member

peplin commented Oct 5, 2014

I'll close this bug for now, but let me know when you have time to give it a test (in next as of f0577cd) and if it's still a problem.

@peplin peplin closed this as completed Oct 5, 2014
@peplin peplin removed the in progress label Oct 5, 2014
peplin added a commit that referenced this issue Oct 5, 2014
        - Fix recursive call to decodeSignal in tire and door decoders.
        - Add functional tests for testing full decode signal stack.

See #263.
@zacnelson
Copy link
Author

Cool, thanks for catching the pipeline issue! In the updated door examples, it looks like the values would be sent every time there's a CAN message. Here's my suggestion:

  • Because we're using a specific decoder, booleanDecoder, we need to call shouldSend(...) in order to determine if/when to send the value. I suggest we add a send_same=false flag to each signal as in my comment above. That way you only get door signal event messages when a door opens or closes.

@peplin
Copy link
Member

peplin commented Oct 5, 2014

Thanks, just added that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants