summaryrefslogtreecommitdiffstats
path: root/low-can-binding/binding/low-can-subscription.cpp
diff options
context:
space:
mode:
authorArthur Guyader <arthur.guyader@iot.bzh>2019-07-29 12:19:13 +0200
committerArthur Guyader <arthur.guyader@iot.bzh>2019-08-12 15:06:45 +0200
commit88077fb4b383cf7f35093b6cc0d2d9d86c6f1bf3 (patch)
treeae7df9ff1f6981c629bb4456ae8d17fc383e71ef /low-can-binding/binding/low-can-subscription.cpp
parent8c0a3d45ca37f710100afab065b07e82682dc1ef (diff)
Add feature to build messages and fix some functions
Allows to build a message (J1939,BCM) with a signal and a value. Bug-AGL: SPEC-2386 Signed-off-by: Arthur Guyader <arthur.guyader@iot.bzh> Change-Id: Iadca13a927ff83f713f39da441c88356695a1285
Diffstat (limited to 'low-can-binding/binding/low-can-subscription.cpp')
-rw-r--r--low-can-binding/binding/low-can-subscription.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/low-can-binding/binding/low-can-subscription.cpp b/low-can-binding/binding/low-can-subscription.cpp
index c2f31a03..b31fe48e 100644
--- a/low-can-binding/binding/low-can-subscription.cpp
+++ b/low-can-binding/binding/low-can-subscription.cpp
@@ -427,9 +427,9 @@ int low_can_subscription_t::create_rx_filter_bcm(low_can_subscription_t &subscri
// If it's not an OBD2 CAN ID then just add a simple RX_SETUP job
// else monitor all standard 8 CAN OBD2 ID response.
- std::shared_ptr<can_message_t> msg = std::make_shared<can_message_t>();
+ can_message_t msg = can_message_t();
- msg->set_bcm_msg(bcm_msg);
+ msg.set_bcm_msg(bcm_msg);
if(bcm_msg.msg_head.can_id != OBD2_FUNCTIONAL_BROADCAST_ID)
{
@@ -442,7 +442,7 @@ int low_can_subscription_t::create_rx_filter_bcm(low_can_subscription_t &subscri
for(uint8_t i = 0; i < 8; i++)
{
bcm_msg.msg_head.can_id = OBD2_FUNCTIONAL_RESPONSE_START + i;
- msg->set_bcm_msg(bcm_msg);
+ msg.set_bcm_msg(bcm_msg);
subscription.socket_->write_message(msg);
if(! subscription.socket_)
return -1;
@@ -455,22 +455,23 @@ int low_can_subscription_t::create_rx_filter_bcm(low_can_subscription_t &subscri
/// send a message
///
/// @return 0 if ok else -1
-int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, struct canfd_frame& cfd, const std::string& bus_name)
+int low_can_subscription_t::tx_send(low_can_subscription_t &subscription, message_t *message, const std::string& bus_name)
{
- struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cfd.can_id);
+ can_message_t *cm = static_cast<can_message_t*>(message);
+
+ struct bcm_msg bcm_msg = subscription.make_bcm_head(TX_SEND, cm->get_id(),cm->get_flags());
+ canfd_frame cfd = cm->convert_to_canfd_frame();
subscription.add_one_bcm_frame(cfd, bcm_msg);
if(subscription.open_socket(subscription, bus_name) < 0)
{return -1;}
-
- std::shared_ptr<can_message_t> msg = std::make_shared<can_message_t>();
-
- msg->set_bcm_msg(bcm_msg);
-
- subscription.socket_->write_message(msg);
+ cm->set_bcm_msg(bcm_msg);
+ subscription.socket_->write_message(*cm);
if(! subscription.socket_.get())
- return -1;
+ {
+ return -1;
+ }
return 0;
-}
+} \ No newline at end of file