"doors.coffer.open",
88,
1,
- 0.00000f,
- 0,
+ 0.00000f,
+ 0,
0,
0,
frequency_clock_t(0.00000f),
"doors.driver.open",
78,
1,
- 0.00000f,
- 0,
+ 0.00000f,
+ 0,
0,
0,
frequency_clock_t(0.00000f),
"doors.passenger.open",
79,
1,
- 0.00000f,
- 0,
+ 0.00000f,
+ 0,
0,
0,
frequency_clock_t(0.00000f),
"doors.rearleft.open",
86,
1,
- 0.00000f,
- 0,
+ 0.00000f,
+ 0,
0,
0,
frequency_clock_t(0.00000f),
"doors.rearright.open",
85,
4,
- 0.00000f,
- 0,
+ 0.00000f,
+ 0,
0,
0,
frequency_clock_t(0.00000f),
#include "ini-config.hpp"
-bool starts_with(const std::string& text, const std::string& token)
+bool starts_with(const std::string& text, const std::string& token)
{
if(text.length() < token.length()) return false;
return (text.compare(0, token.length(), token) == 0);
{
map ret;
std::string key;
-
+
std::string prefix = section + '/';
for(auto i = config_.begin();
i != config_.end();
}
}
return line_type::ignore;
-}
\ No newline at end of file
+}
/// @brief Class representing a configuration attached to the binding.
///
/// It regroups all needed objects instance from other class
-/// that will be used along the binding life. It gets a global vision
-/// on which signals are implemented for that binding.
+/// that will be used along the binding life. It gets a global vision
+/// on which signals are implemented for that binding.
/// Here, it is only the definition of the class with predefined accessors
/// methods used in the binding.
///
auto it = std::find_if(s.begin(), s.end(), [&sig](std::pair<int, std::shared_ptr<low_can_subscription_t> > sub){ return (! sub.second->get_diagnostic_message().empty());});
can_subscription = it != s.end() ?
- it->second :
+ it->second :
std::make_shared<low_can_subscription_t>(low_can_subscription_t(event_filter));
// If the requested diagnostic message isn't supported by the car then unsubcribe it
// no matter what we want, worse case will be a fail unsubscription but at least we don't
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
+
#pragma once
#include <cstddef>
class can_message_definition_t;
class diagnostic_message_t;
-/// @brief A parent wrapper for a particular set of CAN messages and diagnostic messages
+/// @brief A parent wrapper for a particular set of CAN messages and diagnostic messages
/// (e.g. a vehicle or program).
class can_message_set_t
{
float can_signal_t::get_min_value() const
{
return min_value_;
-}
+}
float can_signal_t::get_max_value() const
{
/// A signal_encoder transforms a number, string or boolean into a raw floating
/// point value that fits in the CAN signal.
///
-/// @param[in] signal - The CAN signal to encode.
+/// @param[in] signal - The CAN signal to encode.
/// @param[in] value - The dynamic field to encode.
/// @param[out] send - An output parameter. If the encoding failed or the CAN signal should
/// not be encoded for some other reason, this will be flipped to false.
name_ = adr.name_;
decoder_ = adr.decoder_;
callback_ = adr.callback_;
- recurring_ = adr.recurring_;
+ recurring_ = adr.recurring_;
wait_for_multiple_responses_ = adr.wait_for_multiple_responses_;
frequency_clock_ = adr.frequency_clock_;
timeout_clock_ = adr.timeout_clock_;
socket_ = adr.socket_;
}
-
+
return *this;
}
DiagnosticRequestHandle* handle_; ///< handle_ - A handle for the request to keep track of it between
///< sending the frames of the request and receiving all frames of the response.
std::string name_; ///< name_ - Human readable name, to be used when publishing received responses.
- static std::string prefix_; ///< prefix_ - It has to reflect the JSON object which it comes from. It makes easier sorting
+ static std::string prefix_; ///< prefix_ - It has to reflect the JSON object which it comes from. It makes easier sorting
///< incoming CAN messages.
DiagnosticResponseDecoder decoder_; ///< decoder_ - An optional DiagnosticResponseDecoder to parse the payload of responses
///< to this request. If the decoder is NULL, the output will include the raw payload
/// to have 1 diagnostic bus which are the first bus declared in the JSON
/// description file. Configuration instance will return it.
///
-/// this will initialize DiagnosticShims and cancel all active requests
+/// this will initialize DiagnosticShims and cancel all active requests
/// if there are any.
bool diagnostic_manager_t::initialize()
{
/// @param[in] data - The data payload for the message. NULL is valid if size is also 0.
/// @param[in] size - The size of the data payload, in bytes.
///
-/// @return true if the CAN message was sent successfully.
+/// @return true if the CAN message was sent successfully.
bool diagnostic_manager_t::shims_send(const uint32_t arbitration_id, const uint8_t* data, const uint8_t size)
{
diagnostic_manager_t& dm = application_t::instance().get_diagnostic_manager();
}
/// @brief Cleanup a specific request if it isn't running and get complete. As it is almost
-/// impossible to get that state for a recurring request without waiting for that, you can
+/// impossible to get that state for a recurring request without waiting for that, you can
/// force the cleaning operation.
///
/// @param[in] entry - the request to clean
recurring_requests_.push_back(entry);
entry->set_handle(shims_, request);
- start_diagnostic_request(&shims_, entry->get_handle());
+ start_diagnostic_request(&shims_, entry->get_handle());
}
else
{
}
/// @brief Will take the CAN message and pass it to the receive functions that will process
-/// diagnostic handle for each active diagnostic request then depending on the result we will
+/// diagnostic handle for each active diagnostic request then depending on the result we will
/// return pass the diagnostic response to decode it.
///
/// @param[in] entry - A pointer to an active diagnostic request holding a valid diagnostic handle
}
/// @brief Tell if the CAN message received is a diagnostic response.
-/// Request broadcast ID use 0x7DF and assigned ID goes from 0x7E0 to Ox7E7. That allows up to 8 ECU to respond
+/// Request broadcast ID use 0x7DF and assigned ID goes from 0x7E0 to Ox7E7. That allows up to 8 ECU to respond
/// at the same time. The response is the assigned ID + 0x8, so response ID can goes from 0x7E8 to 0x7EF.
///
/// @param[in] cm - CAN message received from the socket.
/// and put into the DiagnosticResponse of the VehicleMessage.
/// @param[in] parsed_value - raw parsed value of the payload from CAN message
///
-/// @return a vehicle message including simple message that will be convert into
+/// @return a vehicle message including simple message that will be convert into
/// a JSON object before being pushed to the subscribers
///
const openxc_VehicleMessage build_VehicleMessage(active_diagnostic_request_t* request, const DiagnosticResponse& response, float parsed_value)
/// @param[in] message - simple message to include into openxc_VehicleMessage
/// @param[in] timestamp - timestamp from ioctl when reading the socket
///
-/// @return a vehicle message including simple message that will be convert into
+/// @return a vehicle message including simple message that will be convert into
/// a JSON object before being pushed to the subscribers
///
const openxc_VehicleMessage build_VehicleMessage(const openxc_SimpleMessage& message, uint64_t timestamp)
{
openxc_VehicleMessage v;
-
+
v.has_type = true,
v.type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE;
v.has_simple_message = true;
///
/// @param[in] message - simple message to include into openxc_VehicleMessage
///
-/// @return a vehicle message including simple message that will be convert into
+/// @return a vehicle message including simple message that will be convert into
/// a JSON object before being pushed to the subscribers
///
const openxc_VehicleMessage build_VehicleMessage(const openxc_SimpleMessage& message)
{
openxc_VehicleMessage v;
-
+
v.has_type = true,
v.type = openxc_VehicleMessage_Type::openxc_VehicleMessage_Type_SIMPLE;
v.has_simple_message = true;
/// @brief Build an openxc_SimpleMessage associating a name to an openxc_DynamicField
///
/// @param[in] name - const string reference name to assign to the created SimpleMessage
-/// this will set has_name member to true and assign name to the name member. Maximum size for name is
+/// this will set has_name member to true and assign name to the name member. Maximum size for name is
/// set to 100 char.
/// @param[in] value - const reference with DynamicField to assign to SimpleMessage
/// value.
openxc_DynamicField d;
d.has_type = true;
d.type = openxc_DynamicField_Type_STRING;
-
+
d.has_string_value = true;
d.has_numeric_value = false;
d.has_boolean_value = false;
::strncpy(d.string_value, value.c_str(), 100);
-
+
return d;
}
openxc_DynamicField d;
d.has_type = true;
d.type = openxc_DynamicField_Type_NUM;
-
+
d.has_string_value = false;
d.has_numeric_value = true;
d.has_boolean_value = false;
d.numeric_value = value;
-
+
return d;
}
openxc_DynamicField d;
d.has_type = true;
d.type = openxc_DynamicField_Type_BOOL;
-
+
d.has_string_value = false;
d.has_numeric_value = false;
d.has_boolean_value = true;
d.boolean_value = value;
-
+
return d;
}
{
if (v_msg.has_simple_message)
return v_msg.simple_message;
-
+
openxc_SimpleMessage s_msg = { false, "", false, build_DynamicField(false), false, build_DynamicField(false)};
return s_msg;
}
///
/// @brief Make a JSON object from a SimpleMessage
///
-/// @param[in] s_msg - const reference to an openxc_SimpleMessage
+/// @param[in] s_msg - const reference to an openxc_SimpleMessage
/// struct to convert into a json object.
/// @param[out] json - pointer with the DynamicField converted into json object
-///
+///
/// @return True if SimpleMessage has been transformed into json object
/// and false if not. In such case, a json object is returned { "error": "error msg"}
///
}
json_object_object_add(json, "error", json_object_new_string("openxc_SimpleMessage doesn't have name'"));
return false;
-}
\ No newline at end of file
+}
///
/// @brief return the subscribed_signals map.
- ///
+ ///
/// @return Map of subscribed signals.
std::map<int, std::shared_ptr<low_can_subscription_t> >& signals_manager_t::get_subscribed_signals()
{
/// @fn std::vector<std::string> find_signals(const openxc_DynamicField &key)
/// @brief return signals name found searching through CAN_signals and OBD2 pid
///
- /// @param[in] key : can contain numeric or string value in order to search against
+ /// @param[in] key : can contain numeric or string value in order to search against
/// can signals or obd2 signals name.
///
- /// @return Vector of signals name found.
+ /// @return Vector of signals name found.
///
struct signals_found signals_manager_t::find_signals(const openxc_DynamicField &key)
{
std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages;
};
- /// @brief Signal manager singleton hold subscription object with attached afb_event and its mutex
+ /// @brief Signal manager singleton hold subscription object with attached afb_event and its mutex
/// to read and write it safely.
/// It can be used to browse CAN signals and Diagnostic messages vectors and find a particular signal to
/// subscribe to.
int socketcan_bcm_t::open(std::string device_name)
{
close();
-
+
struct ifreq ifr;
socket_ = socketcan_t::open(PF_CAN, SOCK_DGRAM, CAN_BCM);
int socketcan_raw_t::open(std::string device_name)
{
close();
-
+
struct ifreq ifr;
socket_ = socketcan_t::open(PF_CAN, SOCK_RAW, CAN_RAW);
*/
#include <time.h>
-#include <stdlib.h>
+#include <stdlib.h>
#include <cmath>
#include "timer.hpp"
{
struct timespec t_usec;
long long int timestamp_usec = 0;
-
+
if(!::clock_gettime(CLOCK_MONOTONIC, &t_usec))
timestamp_usec = (t_usec.tv_nsec / 1000ll) + (t_usec.tv_sec* 1000000ll);
return timestamp_usec;
{
struct timespec t_msec;
long long int timestamp_msec = 0;
-
+
if(!::clock_gettime(CLOCK_MONOTONIC, &t_msec))
timestamp_msec = (t_msec.tv_nsec / 1000000ll) + (t_msec.tv_sec* 1000ll);
return timestamp_msec;
{
struct timespec t_sec;
long long int timestamp_sec = 0;
-
+
if(!::clock_gettime(CLOCK_MONOTONIC, &t_sec))
timestamp_sec = t_sec.tv_sec;
return timestamp_sec;
return frequency_ == 0 ? 0 : 1 / frequency_;
}
-/// @brief Return a timeval struct based on the frequency_ member. used to
+/// @brief Return a timeval struct based on the frequency_ member. used to
/// specified CAN BCM timers.
const struct timeval frequency_clock_t::get_timeval_from_period() const
{