Skip to content

Commit

Permalink
Adaptation of the CAN demos to the latest fmi-ls-bus header version
Browse files Browse the repository at this point in the history
  • Loading branch information
Benedikt Menne authored and Benedikt Menne committed Feb 21, 2024
1 parent 6573bc8 commit db4ae08
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ls-bus-guide/demos/can-bus-simulation/PackFmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Repository to fetch the LS-BUS headers from
LS_BUS_REPO = 'modelica/fmi-ls-bus'
LS_BUS_REV = '7d277c5d55b294f69d61627b1968f39d7ff9fc4d'
LS_BUS_REV = '6c4b6b27e17046e439a653adafd7e9019925d4bf'
LS_BUS_HEADERS = [ 'fmi3LsBus.h', 'fmi3LsBusCan.h', 'fmi3LsBusUtil.h', 'fmi3LsBusUtilCan.h' ]


Expand Down
4 changes: 2 additions & 2 deletions ls-bus-guide/demos/can-bus-simulation/src/App.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ void App_EvaluateDiscreteStates(FmuInstance* instance)
fmi3LsBusOperationHeader* operation = NULL;
while (FMI3_LS_BUS_READ_NEXT_OPERATION(&instance->App->Nodes[i].RxBufferInfo, operation))
{
if (operation->type == FMI3_LS_BUS_CAN_OP_CAN_TRANSMIT)
if (operation->opCode == FMI3_LS_BUS_CAN_OP_CAN_TRANSMIT)
{
const fmi3LsBusCanOperationCanTransmit* transmitOp = (fmi3LsBusCanOperationCanTransmit*)operation;
LogFmuMessage(instance, fmi3OK, "Info", "Received CAN frame with ID %u and length %u from node %u",
transmitOp->id, transmitOp->dataLength, i + 1);
FrameQueue_Enqueue(&instance->App->Nodes[i].FrameQueue, transmitOp);
}
else if (operation->type == FMI3_LS_BUS_CAN_OP_CONFIGURATION)
else if (operation->opCode == FMI3_LS_BUS_CAN_OP_CONFIGURATION)
{
const fmi3LsBusCanOperationConfiguration* configOp = (fmi3LsBusCanOperationConfiguration*)operation;
if (configOp->parameterType == FMI3_LS_BUS_CAN_CONFIG_PARAM_TYPE_CAN_BAUDRATE)
Expand Down
2 changes: 1 addition & 1 deletion ls-bus-guide/demos/can-node-triggered-output/PackFmu.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

# Repository to fetch the LS-BUS headers from
LS_BUS_REPO = 'modelica/fmi-ls-bus'
LS_BUS_REV = '7d277c5d55b294f69d61627b1968f39d7ff9fc4d'
LS_BUS_REV = '6c4b6b27e17046e439a653adafd7e9019925d4bf'
LS_BUS_HEADERS = [ 'fmi3LsBus.h', 'fmi3LsBusCan.h', 'fmi3LsBusUtil.h', 'fmi3LsBusUtilCan.h' ]


Expand Down
12 changes: 6 additions & 6 deletions ls-bus-guide/demos/can-node-triggered-output/src/App.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,17 +125,17 @@ void App_UpdateDiscreteStates(FmuInstance* instance)
fmi3LsBusOperationHeader* operation = NULL;
while (FMI3_LS_BUS_READ_NEXT_OPERATION(&instance->App->RxBufferInfo, operation))
{
if (operation->type == FMI3_LS_BUS_CAN_OP_CAN_TRANSMIT)
if (operation->opCode == FMI3_LS_BUS_CAN_OP_CAN_TRANSMIT)
{
const fmi3LsBusCanOperationCanTransmit* transmitOp = (fmi3LsBusCanOperationCanTransmit*)operation;
LogFmuMessage(instance, fmi3OK, "Info", "Received CAN frame with ID %u and length %u", transmitOp->id,
transmitOp->dataLength);
}
else if (operation->type == FMI3_LS_BUS_CAN_OP_CONFIGURATION ||
operation->type == FMI3_LS_BUS_CAN_OP_STATUS ||
operation->type == FMI3_LS_BUS_CAN_OP_CONFIRM ||
operation->type == FMI3_LS_BUS_CAN_OP_BUS_ERROR ||
operation->type == FMI3_LS_BUS_CAN_OP_ARBITRATION_LOST)
else if (operation->opCode == FMI3_LS_BUS_CAN_OP_CONFIGURATION ||
operation->opCode == FMI3_LS_BUS_CAN_OP_STATUS ||
operation->opCode == FMI3_LS_BUS_CAN_OP_CONFIRM ||
operation->opCode == FMI3_LS_BUS_CAN_OP_BUS_ERROR ||
operation->opCode == FMI3_LS_BUS_CAN_OP_ARBITRATION_LOST)
{
// Ignore
}
Expand Down

0 comments on commit db4ae08

Please sign in to comment.