void initializeOtherStuff() { }
void myLooper() {
- // this function will be called once each time through the main loop, after
+ // this function will be called once, each time through the main loop, after
// all CAN message processing has been completed
}
void initializeOtherStuff() { }
void myLooper() {
- // this function will be called once each time through the main loop, after
+ // this function will be called once, each time through the main loop, after
// all CAN message processing has been completed
}
*
* 000000000000000010101000000000000000000000000000000000000000000
*
- * If the architecture where is code is running is little-endian, the input data
+ * If the architecture where the code is running is little-endian, the input data
* will be swapped before grabbing the bit field.
*
* Examples
*
* source - the source byte array.
* byte_index - the index of the byte to retreive. The leftmost byte is index 0.
- * data_is_big_endian - if the data passed in is little endian, set this to false and it
+ * data_is_big_endian - if the passed data in is little endian, set this to false and it
* will be flipped before grabbing the bit field.
*
* Returns the retreived byte.
*destination++ |= c;
/*
- * Middle: copy with only shifting the source.
+ * Middle: copy by only shifting the source.
*/
int byte_len = bit_count / CHAR_BIT;
while(--byte_len >= 0) {
extern "C" {
#endif
-/* Public: Reads a subset of bits into a uint64_t, right aligned so they may be
+/* Public: Reads a subset of bits into a uint64_t, right aligned so they can be
* interpreted as a number.
*
* source - the bytes in question.
#include <regex>
#include <algorithm>
-// Représente un fichier de configuration.
+// Represents a configuration file.
class ini_config
{
public:
#include "../diagnostic/diagnostic-manager.hpp"
///
-/// @brief Class representing a configuration attached to the binding.
+/// @brief Class represents 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
+/// It regroups all object instances from other classes
+/// that will be used through the binding life. It receives a global vision
/// on which signals are implemented for that binding.
-/// Here, it is only the definition of the class with predefined accessors
+/// Here, only the definition of the class is given with predefined accessors
/// methods used in the binding.
///
/// It will be the reference point to needed objects.
class application_t
{
private:
- can_bus_t can_bus_manager_; ///< instanciate the CAN bus manager. It's the one in charge of initialize the CAN bus devices.
+ can_bus_t can_bus_manager_; ///< instanciate the CAN bus manager. It's responsible of initializing the CAN bus devices.
diagnostic_manager_t diagnostic_manager_; ///< Diagnostic manager use to manage diagnostic message communication.
uint8_t active_message_set_ = 0; ///< Which is the active message set ? Default to 0.
return 0;
}
-/// @brief Will determine if it is needed or not to create the event handle and checks it to be sure that
-/// we got a valid afb_event to get subscribe or unsubscribe. Then launch the subscription or unsubscription
+/// @brief This will determine if an event handle needs to be creaed and checks if
+/// we got a valid afb_event to get subscribe or unsubscribe. After thta launch the subscription or unsubscription
/// against the application framework using that event handle.
static int subscribe_unsubscribe_signal(struct afb_req request,
bool subscribe,
ret = create_event_handle(can_subscription, s);
}
- // Check whether or not the event handler has been correctly created and
- // make the subscription/unsubscription operation is so.
+ // Check whether or not the event handler is correctly created and
+ // make the subscription/unsubscription operation if so.
if (ret < 0)
return ret;
return make_subscription_unsubscription(request, can_subscription, s, subscribe);
can_subscription = it != s.end() ?
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
+ // If the requested diagnostic message is not supported by the car then unsubcribe it
+ // no matter what we want, worst case will be a failed unsubscription but at least we won't
// poll a PID for nothing.
if(sig->get_supported() && subscribe)
{
///
/// @brief subscribe to all signals in the vector signals
///
-/// @param[in] afb_req request : contain original request use to subscribe or unsubscribe
-/// @param[in] subscribe boolean value used to chose between a subscription operation or an unsubscription
+/// @param[in] afb_req request : contains original request use to subscribe or unsubscribe
+/// @param[in] subscribe boolean value to chose between a subscription operation or an unsubscription
/// @param[in] signals - struct containing vectors with can_signal_t and diagnostic_messages to subscribe
///
/// @return Number of correctly subscribed signal
if(application_t::instance().get_diagnostic_manager().initialize())
ret = 0;
- // Add a recurring dignostic message request to get engine speed continuously
+ // Add a recurring dignostic message request to get engine speed at all times.
openxc_DynamicField search_key = build_DynamicField("diagnostic_messages.engine.speed");
struct utils::signals_found sf = utils::signals_manager_t::instance().find_signals(search_key);
{
event_filter_.max = max;
}
-/// @brief Based upon which object is subscribed CAN signal or diagnostic message
-/// this will open the socket with the required CAN bus device name.
+/// @brief Depending if object is subscribed to CAN signal or diagnostic message
+/// it will open the socket with the required CAN bus device name.
///
-/// @return INVALID_SOCKET on failure else positive integer
+/// @return INVALID_SOCKET on failure, else positive integer
int low_can_socket_t::open_socket(const std::string& bus_name)
{
int ret = 0;
return ret;
}
-/// @brief Build a BCM message head but don't set can_frame.
+/// @brief Builds a BCM message head but doesn't set can_frame.
///
-/// @return a simple_bcm_msg with the msg_head parts set and can_frame
+/// @returns a simple_bcm_msg with the msg_head parts set and can_frame
/// zeroed.
struct utils::simple_bcm_msg low_can_socket_t::make_bcm_head(uint32_t opcode, uint32_t can_id, uint32_t flags, const struct timeval& timeout, const struct timeval& frequency_thinning) const
{
return bcm_msg;
}
-/// @brief Take an existing simple_bcm_msg struct and add a can_frame to it.
-/// Only possible for now to add 1 uniq can_frame, it isn't possible to build
+/// @brief Take an existing simple_bcm_msg struct and add a can_frame.
+/// Currently only 1 uniq can_frame can be added, it't not possible to build
/// a multiplexed message with several can_frame.
void low_can_socket_t::add_bcm_frame(const struct can_frame& cf, struct utils::simple_bcm_msg& bcm_msg) const
{
}
}
-/// @brief Create a RX_SETUP receive job used by the BCM socket for a CAN signal
+/// @brief Create a RX_SETUP receive job to be used by the BCM socket for a CAN signal
/// subscription
///
/// @return 0 if ok else -1
return create_rx_filter(bcm_msg);
}
-/// @brief Create a RX_SETUP receive job used by the BCM socket for a
+/// @brief Create a RX_SETUP receive job to be used by the BCM socket for a
/// diagnostic message subscription.
///
/// @return 0 if ok else -1
}
/// @brief Create a RX_SETUP receive job used by the BCM socket directly from
-/// a simple_bcm_msg. You will not use this method directly but rather use the
+/// a simple_bcm_msg. The method is not used directly but rather through the
/// two previous method with can_signal_t or diagnostic_message_t object.
///
/// If the CAN arbitration ID is the OBD2 functional broadcast id the subscribed
/// @return 0 if ok else -1
int low_can_socket_t::create_rx_filter(utils::simple_bcm_msg& bcm_msg)
{
- // Make sure that socket has been opened.
+ // Make sure that socket is opened.
if(open_socket() < 0)
{return -1;}
- // If it isn't an OBD2 CAN ID then just add a simple RX_SETUP job
+ // 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.
if(bcm_msg.msg_head.can_id != OBD2_FUNCTIONAL_BROADCAST_ID)
{
return 0;
}
-/// @brief Create a TX_SEND job used by the BCM socket to
+/// @brief Create a TX_SEND job to be used by the BCM socket to
/// simply send message
///
/// @return 0 if ok else -1
return 0;
}
-/// @brief Create a TX_SEND job used by the BCM socket to
+/// @brief Create a TX_SEND job to be used by the BCM socket to
/// simply send message
///
/// @return 0 if ok else -1
#include "../diagnostic/diagnostic-message.hpp"
#include "../utils/socketcan-bcm.hpp"
-/// @brief Filtering values. Theses values has to be tested into
+/// @brief Filtering values. Theses values have to be tested in
/// can_bus_t::apply_filter method.
struct event_filter_t
{
- float frequency; ///< frequency - Maximum frequency which will be received and pushed a subscribed event.
- float min; ///< min - Minimum value that the signal don't have to go below to be pushed.
- float max; ///< max - Maximum value that the signal don't have to go above to be pushed.
+ float frequency; ///< frequency - Maximum frequency which will be received and pushed to a subscribed event.
+ float min; ///< min - Minimum value that the signal doesn't have to go below to be pushed.
+ float max; ///< max - Maximum value that the signal doesn't have to go above to be pushed.
event_filter_t() : frequency{0}, min{-__FLT_MAX__}, max{__FLT_MAX__} {};
bool operator==(const event_filter_t& ext) const {
return frequency == ext.frequency && min == ext.min && max == ext.max;
}
};
-/// @brief An object storing socket to CAN to be used to write on it.
-/// This is a simple access to a CAN bus device without subscriptions attached
+/// @brief The object stores socket to CAN to be used to write on it.
+/// This is a simple access to a CAN bus device without the subscriptions attached
class low_can_socket_t
{
protected:
/// Signal part
std::shared_ptr<can_signal_t> can_signal_; ///< can_signal_ - the CAN signal subscribed
- std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_message_; ///< diagnostic_message_ - diagnostic messages meant to received OBD2 responses.
- /// normal diagnostic request and response not tested for now.
+ std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_message_; ///< diagnostic_message_ - diagnostic messages meant to receive OBD2 responses.
+ /// normal diagnostic request and response are not tested for now.
utils::socketcan_bcm_t socket_; ///< socket_ - socket_ that receives CAN messages.
#include "../diagnostic/diagnostic-message.hpp"
#include "../utils/socketcan-bcm.hpp"
-/// @brief A subscription object used has a context that handle all needed values to describe a subscription
-/// to the low-can binding. It can holds a CAN signal or diagnostic message. Diagnostic message for OBD2 is a kind
-/// of special because there is only 1 listener to retrieve OBD2 requests. So it's needed that all diagnostic messages
-/// subscriptions is to be in 1 object.
+/// @brief The subscription object has a context that can handle all needed values to describe a subscription
+/// to the low-can binding. It can hold a CAN signal or a diagnostic message. A diagnostic message for OBD2 is
+/// special because there is only 1 listener to retrieve OBD2 requests. It is required that all diagnostic message
+/// subscriptions are in 1 object.
class low_can_subscription_t : public low_can_socket_t
{
private:
std::string name;
std::string device_name;
float max_message_frequency; //<! maxMessageFrequency - the default maximum frequency for all CAN messages when
- /// using the raw passthrough mode. To put no limit on the frequency, set
+ /// using the raw passthrough mode. To disable frequency limit, set
/// this to 0.
- bool raw_writable; //<! rawWritable - True if this CAN bus connection should allow raw CAN messages
+ bool raw_writable; //<! rawWritable - Set this to True if the CAN bus connection should allow raw CAN messages
/// writes. This is independent from the CanSignal 'writable' option, which
- /// can be set to still allow translated writes back to this bus.
- bool passthrough_can_messages; //<! passthroughCanMessages - True if low-level CAN messages should be send to the
+ /// can also be set to allow translated writes back to this bus.
+ bool passthrough_can_messages; //<! passthroughCanMessages - Set this to True if low-level CAN messages should be able to send to the
/// output interface, not just signals as simple vehicle messages.
public:
: conf_file_{conf_file}
{}
-/// @brief Take a decoded message to determine if its value comply with the wanted
-/// filtering values.
+/// @brief Take a decoded message to determine if its value complies with the desired
+/// filters.
///
-/// @param[in] vehicle_message - A decoded message to analyze
+/// @param[in] vehicle_message - The decoded message to be analyzed.
/// @param[in] can_subscription - the subscription which will be notified depending
/// on its filtering values. Filtering values are stored in the event_filtermember.
///
/// json conf file describing the CAN devices to use. Thus, those object will read
/// on the device the CAN frame and push them into the can_bus_t can_message_q_ queue.
///
-/// That queue will be later used to be decoded and pushed to subscribers.
+/// That queue will later be decoded and pushed to subscribers.
class can_bus_t
{
private:
void process_diagnostic_signals(diagnostic_manager_t& manager, const can_message_t& can_message, std::map<int, std::shared_ptr<low_can_subscription_t> >& s);
void can_decode_message();
- std::thread th_decoding_; ///< thread that'll handle decoding a can frame
+ std::thread th_decoding_; ///< thread that will handle decoding a can frame
bool is_decoding_ = false; ///< boolean member controling thread while loop
void can_event_push();
- std::thread th_pushing_; ///< thread that'll handle pushing decoded can frame to subscribers
+ std::thread th_pushing_; ///< thread that will handle pushing decoded can frame to subscribers
bool is_pushing_ = false; ///< boolean member controling thread while loop
std::condition_variable new_can_message_cv_; ///< condition_variable use to wait until there is a new CAN message to read
std::mutex can_message_mutex_; ///< mutex protecting the can_message_q_ queue.
- std::queue <can_message_t> can_message_q_; ///< queue that'll store can_message_t to decoded
+ std::queue <can_message_t> can_message_q_; ///< queue that will store can_message_t to be decoded
std::condition_variable new_decoded_can_message_; ///< condition_variable use to wait until there is a new vehicle message to read from the queue vehicle_message_q_
std::mutex decoded_can_message_mutex_; ///< mutex protecting the vehicle_message_q_ queue.
- std::queue <std::pair<int, openxc_VehicleMessage> > vehicle_message_q_; ///< queue that'll store openxc_VehicleMessage to pushed
+ std::queue <std::pair<int, openxc_VehicleMessage> > vehicle_message_q_; ///< queue that will store openxc_VehicleMessage to be pushed
std::vector<std::pair<std::string, std::string> > can_devices_mapping_; ///< can_devices_mapping_ - holds a mapping between logical CAN devices names and linux CAN devices names.
public:
/// @struct CanCommand
/// @brief The structure to represent a supported custom OpenXC command.
///
-/// For completely customized CAN commands without a 1-1 mapping between an
+/// For completely customized CAN commands without a 1-1 mapping between a
/// OpenXC message from the host and a CAN signal, you can define the name of the
/// command and a custom function to handle it in the VI. An example is
/// the "turn_signal_status" command in OpenXC, which has a value of "left" or
#include "can-message-definition.hpp"
#include "../binding/low-can-hat.hpp"
-/// @brief Parse the signal's bitfield from the given data and return the raw
+/// @brief Parses the signal's bitfield from the given data and returns the raw
/// value.
///
-/// @param[in] signal - The signal to parse from the data.
+/// @param[in] signal - The signal to be parsed from the data.
/// @param[in] message - can_message_t to parse
///
/// @return Returns the raw value of the signal parsed as a bitfield from the given byte
signal.get_offset());
}
-/// @brief Wrap a raw CAN signal value in a DynamicField without modification.
+/// @brief Wraps a raw CAN signal value in a DynamicField without modification.
///
/// This is an implementation of the Signal type signature, and can be
/// used directly in the can_signal_t.decoder field.
#include "../utils/openxc-utils.hpp"
#include "can-message-definition.hpp"
-/// @brief Write a value into a CAN signal in the destination buffer.
+/// @brief Write a value in a CAN signal in the destination buffer.
///
/// @param[in] signal - The CAN signal to write, including the bit position and bit size.
-/// @param[in] value - The encoded integer value to write into the CAN signal.
+/// @param[in] value - The encoded integer value to write in the CAN signal.
/// @param[out] data - The destination buffer.
/// @param[in] length - The length of the destination buffer.
///
, diagnostic_messages_{diagnostic_messages}
{}
-/// @brief Return vector holding all message definition handled by this message set.
+/// @brief Returns a vector holding all message definitions which are handled by this message set.
std::vector<std::shared_ptr<can_message_definition_t> >& can_message_set_t::get_can_message_definition()
{
return can_messages_definition_;
return can_signals;
}
-/// @brief Return vector holding all diagnostic messages definitions handled by this message set.
+/// @brief Returns a vector holding all diagnostic message definitions which are handled by this message set.
std::vector<std::shared_ptr<diagnostic_message_t> >& can_message_set_t::get_diagnostic_messages()
{
return diagnostic_messages_;
class can_message_set_t
{
private:
- uint8_t index_; /// < A numerical ID for the message set, ideally the index in an array for fast lookup
+ uint8_t index_; /// < A numerical ID for the message set, ideally the index is in an array for fast lookup
const std::string name_; /// < The name of the message set.
- std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition_; ///< Vector holding all message definition handled by this message set.
+ std::vector<std::shared_ptr<can_message_definition_t> > can_messages_definition_; ///< Vector holding all message definitions handled by the set message.
std::vector<std::shared_ptr<diagnostic_message_t> > diagnostic_messages_; ///< Vector holding all diagnostics messages from JSON signals description file. First vector map to message set
public:
///
/// @brief Class constructor
///
-/// Constructor about can_message_t class.
+/// Constructor of can_message_t class.
///
can_message_t::can_message_t()
: maxdlen_{0},
/// @brief Set format_ member value.
///
-/// Preferred way to initialize these members by using
+/// Preferred way to initialize these members is to use
/// convert_from_canfd_frame method.
///
/// @param[in] new_format - class member
return can_message_t(maxdlen, id, length, format, rtr_flag, flags, data, timestamp);
}
-/// @brief Take all initialized class's members and build an
+/// @brief Take all initialized class members and build a
/// canfd_frame struct that can be use to send a CAN message over
/// the bus.
///
return frame;
}
-/// @brief Take all initialized class's members and build an
+/// @brief Take all initialized class members and build a
/// can_frame struct that can be use to send a CAN message over
/// the bus.
///
/// @param[in] signalCount - The length of the signals array.
/// @param[in] value - The CAN signal parsed from the message as a raw floating point
/// value.
-/// @param[out] send - An output parameter. If the decoding failed or the CAN signal should
-/// not send for some other reason, this should be flipped to false.
+/// @param[out] send - An output parameter. If decoding fails or CAN signal is
+/// not sending, this should be flipped to false.
///
/// @return a decoded value in an openxc_DynamicField struct.
///
}
}
-/// @brief Diagnostic manager isn't initialized at launch but after
-/// CAN bus devices initialization. For the moment, it is only possible
+/// @brief Diagnostic manager is not initialized at launch but after
+/// the initialization ofCAN bus devices. For the moment, it is only possible
/// to have 1 diagnostic bus which are the first bus declared in the JSON
/// description file. Configuration instance will return it.
///
#include "../can/can-bus.hpp"
#include "active-diagnostic-request.hpp"
-/// Each CAN bus needs its own set of shim functions, so this should
+/// Each CAN bus requires own set of shim functions, so this should
/// match the maximum CAN controller count.
///
#define DIAGNOSTIC_RESPONSE_ARBITRATION_ID_OFFSET 0x8
class active_diagnostic_request_t;
///
-/// @brief The core structure for running the diagnostics module by the binding.
+/// @brief The core structure for running the diagnostics module of the binding.
///
/// This stores details about the active requests and shims required to connect
/// the diagnostics library to the CAN device.