summaryrefslogtreecommitdiffstats
path: root/low-can-binding/can/can-encoder.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'low-can-binding/can/can-encoder.cpp')
-rw-r--r--low-can-binding/can/can-encoder.cpp68
1 files changed, 37 insertions, 31 deletions
diff --git a/low-can-binding/can/can-encoder.cpp b/low-can-binding/can/can-encoder.cpp
index 113428b9..f0ea0921 100644
--- a/low-can-binding/can/can-encoder.cpp
+++ b/low-can-binding/can/can-encoder.cpp
@@ -167,41 +167,47 @@ message_t* encoder_t::build_message(const std::shared_ptr<signal_t>& signal, uin
{
message_t *message;
std::vector<uint8_t> data;
- if(signal->get_message()->is_fd())
+ switch(signal->get_message()->get_flags())
{
- message = new can_message_t( CANFD_MAX_DLEN,
- signal->get_message()->get_id(),
- CANFD_MAX_DLEN,
- false,
- signal->get_message()->get_flags(),
- data,
- 0);
-
- return build_frame(signal, value, message, factor, offset);
- }
+ case CAN_PROTOCOL_WITH_FD_FRAME:
+ message = new can_message_t(CANFD_MAX_DLEN,
+ signal->get_message()->get_id(),
+ CANFD_MAX_DLEN,
+ false,
+ signal->get_message()->get_flags(),
+ data,
+ 0);
+ return build_frame(signal, value, message, factor, offset);
#ifdef USE_FEATURE_J1939
- else if(signal->get_message()->is_j1939())
- {
- message = new j1939_message_t( signal->get_message()->get_length(),
- data,
- 0,
- J1939_NO_NAME,
- signal->get_message()->get_id(),
- J1939_NO_ADDR);
- return build_frame(signal, value, message, factor, offset);
- }
+ case J1939_PROTOCOL:
+ message = new j1939_message_t(signal->get_message()->get_length(),
+ data,
+ 0,
+ J1939_NO_NAME,
+ signal->get_message()->get_id(),
+ J1939_NO_ADDR);
+ return build_frame(signal, value, message, factor, offset);
#endif
- else
- {
- message = new can_message_t(CAN_MAX_DLEN,
- signal->get_message()->get_id(),
- CAN_MAX_DLEN,
- false,
- signal->get_message()->get_flags(),
- data,
- 0);
- return build_frame(signal,value,message, factor, offset);
+ case CAN_PROTOCOL:
+ message = new can_message_t(CAN_MAX_DLEN,
+ signal->get_message()->get_id(),
+ CAN_MAX_DLEN,
+ false,
+ signal->get_message()->get_flags(),
+ data,
+ 0);
+ return build_frame(signal, value, message, factor, offset);
+ default:
+ message = new can_message_t(CAN_MAX_DLEN,
+ signal->get_message()->get_id(),
+ CAN_MAX_DLEN,
+ false,
+ signal->get_message()->get_flags(),
+ data,
+ 0);
+ return build_frame(signal, value, message, factor, offset);
}
+
}
/// @brief Encode a boolean into an integer, fit for a CAN signal bitfield.