Check whether a signal is writable before sending
authorRomain Forlot <romain.forlot@iot.bzh>
Mon, 17 Jul 2017 08:57:45 +0000 (10:57 +0200)
committerRomain Forlot <romain.forlot@iot.bzh>
Fri, 21 Jul 2017 10:02:11 +0000 (12:02 +0200)
Change-Id: Id04d04a07e43738f7379e33fa7c6022eaa426343
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
low-can-binding/binding/low-can-cb.cpp

index cac9fc4..be2985f 100644 (file)
@@ -427,9 +427,14 @@ static int write_signal(const std::string& name, uint64_t value)
        {
                for(const auto& sig: sf.can_signals)
                {
-                       cf = encoder_t::build_frame(sig, value);
-                       const std::string bus_name = sig->get_message()->get_bus_name();
-                       rc = send_frame(bus_name, cf);
+                       if(sig->get_writable())
+                       {
+                               cf = encoder_t::build_frame(sig, value);
+                               const std::string bus_name = sig->get_message()->get_bus_name();
+                               rc = send_frame(bus_name, cf);
+                       }
+                       else
+                               {AFB_NOTICE("%s isn't writable. Message not sent.", sig->get_name().c_str());}
                }
        }