/* Make the subscription or unsubscription to the event */
if (((subscribe ? afb_req_subscribe : afb_req_unsubscribe)(request, s[can_subscription->get_index()]->get_event())) < 0)
{
- ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str());
+ AFB_ERROR("Operation goes wrong for signal: %s", can_subscription->get_name().c_str());
return -1;
}
return 0;
s[sub_index] = can_subscription;
if (!afb_event_is_valid(s[sub_index]->get_event()))
{
- ERROR("Can't create an event for %s, something goes wrong.", can_subscription->get_name().c_str());
+ AFB_ERROR("Can't create an event for %s, something goes wrong.", can_subscription->get_name().c_str());
return -1;
}
return 0;
{
if (!afb_event_is_valid(s[sub_index]->get_event()) && !subscribe)
{
- NOTICE("Event isn't valid, no need to unsubscribed.");
+ AFB_NOTICE("Event isn't valid, no need to unsubscribed.");
ret = -1;
}
ret = 0;
diag_m.add_recurring_request(diag_req, sig->get_name().c_str(), false, sig->get_decoder(), sig->get_callback(), event_filter.frequency);
if(can_subscription->create_rx_filter(sig) < 0)
{return -1;}
- DEBUG("Signal: %s subscribed", sig->get_name().c_str());
+ AFB_DEBUG("Signal: %s subscribed", sig->get_name().c_str());
if(it == s.end() && add_to_event_loop(can_subscription) < 0)
{
diag_m.cleanup_request(
diag_m.find_recurring_request(*diag_req), true);
- WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str());
+ AFB_WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str());
return -1;
}
}
else
{
if(sig->get_supported())
- {DEBUG("%s cancelled due to unsubscribe", sig->get_name().c_str());}
+ {AFB_DEBUG("%s cancelled due to unsubscribe", sig->get_name().c_str());}
else
{
- WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str());
+ AFB_WARNING("signal: %s isn't supported. Canceling operation.", sig->get_name().c_str());
return -1;
}
}
{return -1;}
rets++;
- DEBUG("signal: %s subscribed", sig->get_name().c_str());
+ AFB_DEBUG("signal: %s subscribed", sig->get_name().c_str());
}
return rets;
}
openxc_DynamicField search_key = build_DynamicField(tag);
sf = utils::signals_manager_t::instance().find_signals(search_key);
if (sf.can_signals.empty() && sf.diagnostic_messages.empty())
- NOTICE("No signal(s) found for %s.", tag.c_str());
+ AFB_NOTICE("No signal(s) found for %s.", tag.c_str());
else
ret = subscribe_unsubscribe_signals(request, subscribe, sf, event_filter);
if(application_t::instance().get_diagnostic_manager().initialize())
return 0;
- ERROR("There was something wrong with CAN device Initialization.");
+ AFB_ERROR("There was something wrong with CAN device Initialization.");
return 1;
}
};
{
std::lock_guard<std::mutex> decoded_can_message_lock(decoded_can_message_mutex_);
push_new_vehicle_message(subscription_id, vehicle_message);
- DEBUG("%s CAN signals processed.", sig->get_name().c_str());
+ AFB_DEBUG("%s CAN signals processed.", sig->get_name().c_str());
}
}
}
{
std::lock_guard<std::mutex> decoded_can_message_lock(decoded_can_message_mutex_);
push_new_vehicle_message(subscription_id, vehicle_message);
- DEBUG("%s CAN signals processed.", s[subscription_id]->get_name().c_str());
+ AFB_DEBUG("%s CAN signals processed.", s[subscription_id]->get_name().c_str());
}
}
}
{
can_msg = can_message_q_.front();
can_message_q_.pop();
- DEBUG("Here is the next can message : id %X, length %X, data %02X%02X%02X%02X%02X%02X%02X%02X", can_msg.get_id(), can_msg.get_length(),
+ AFB_DEBUG("Here is the next can message : id %X, length %X, data %02X%02X%02X%02X%02X%02X%02X%02X", can_msg.get_id(), can_msg.get_length(),
can_msg.get_data()[0], can_msg.get_data()[1], can_msg.get_data()[2], can_msg.get_data()[3], can_msg.get_data()[4], can_msg.get_data()[5], can_msg.get_data()[6], can_msg.get_data()[7]);
return can_msg;
}
{
v_msg = vehicle_message_q_.front();
vehicle_message_q_.pop();
- DEBUG("next vehicle message poped");
+ AFB_DEBUG("next vehicle message poped");
return v_msg;
}
if(can_devices_.empty())
{
- ERROR("No mapping found in config file: '%s'. Check it that it have a CANbus-mapping section.",
+ AFB_ERROR("No mapping found in config file: '%s'. Check it that it have a CANbus-mapping section.",
conf_file_.filepath().c_str());
}
}
if(signal_state.size() <= 0)
{
*send = false;
- ERROR("No state found with index: %d", (int)value);
+ AFB_ERROR("No state found with index: %d", (int)value);
}
return decoded_value;
}
const std::vector<std::shared_ptr<can_signal_t> >& signals, bool* send)
{
float value = decoder_t::parseSignalBitfield(signal, message);
- DEBUG("Decoded message from parseSignalBitfield: %f", value);
+ AFB_DEBUG("Decoded message from parseSignalBitfield: %f", value);
// Must call the decoders every time, regardless of if we are going to
// decide to send the signal or not.
float decoder_t::decode_obd2_response(const DiagnosticResponse* response, float parsed_payload)
{
return diagnostic_decode_obd2_pid(response);
-}
\ No newline at end of file
+}
if(new_format == can_message_format_t::STANDARD || new_format == can_message_format_t::EXTENDED || new_format == can_message_format_t::INVALID)
format_ = new_format;
else
- ERROR("Can set format, wrong format chosen");
+ AFB_ERROR("Can set format, wrong format chosen");
}
/// @brief Take a canfd_frame struct to initialize class members
switch(nbytes)
{
case CANFD_MTU:
- DEBUG("Got an CAN FD frame");
+ AFB_DEBUG("Got an CAN FD frame");
maxdlen = CANFD_MAX_DLEN;
break;
case CAN_MTU:
- DEBUG("Got a legacy CAN frame");
+ AFB_DEBUG("Got a legacy CAN frame");
maxdlen = CAN_MAX_DLEN;
break;
default:
- ERROR("unsupported CAN frame");
+ AFB_ERROR("unsupported CAN frame");
break;
}
data.push_back(frame.data[i]);
};
- DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
+ AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
if(nbytes <= CAN_MTU)
{
- DEBUG("Got a legacy CAN frame");
+ AFB_DEBUG("Got a legacy CAN frame");
maxdlen = CAN_MAX_DLEN;
}
else
{
- ERROR("unsupported CAN frame");
+ AFB_ERROR("unsupported CAN frame");
}
if (frame.can_id & CAN_ERR_FLAG)
data.push_back(frame.data[i]);
};
-// DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
+// AFB_DEBUG("Found id: %X, format: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X",
// id, (uint8_t)format, length, data[0], data[1], data[2], data[3], data[4], data[5], data[6], data[7]);
}
::memcpy(frame.data, get_data(), length_);
}
else
- ERROR("can_message_t not correctly initialized to be sent");
+ AFB_ERROR("can_message_t not correctly initialized to be sent");
return frame;
}
::memcpy(frame.data, get_data(), length_);
}
else
- ERROR("can_message_t not correctly initialized to be sent");
+ AFB_ERROR("can_message_t not correctly initialized to be sent");
return frame;
}
#include "../binding/application.hpp"
-#define ERROR_PID 0xFF
+#define AFB_ERROR_PID 0xFF
std::string active_diagnostic_request_t::prefix_ = "diagnostic_messages";
{
if (handle_->request.has_pid)
return handle_->request.pid;
- return ERROR_PID;
+ return AFB_ERROR_PID;
}
DiagnosticRequestHandle* active_diagnostic_request_t::get_handle()
reset();
initialized_ = true;
- DEBUG("Diagnostic Manager initialized");
+ AFB_DEBUG("Diagnostic Manager initialized");
return initialized_;
}
void diagnostic_manager_t::init_diagnostic_shims()
{
shims_ = diagnostic_init_shims(shims_logger, shims_send, NULL);
- DEBUG("Shims initialized");
+ AFB_DEBUG("Shims initialized");
}
/// @brief Force cleanup all active requests.
void diagnostic_manager_t::reset()
{
- DEBUG("Clearing existing diagnostic requests");
+ AFB_DEBUG("Clearing existing diagnostic requests");
cleanup_active_requests(true);
}
char buffer[256];
vsnprintf(buffer, 256, format, args);
- DEBUG("%s", buffer);
+ AFB_DEBUG("%s", buffer);
va_end(args);
}
{
cancel_request(entry);
find_and_erase(entry, recurring_requests_);
- DEBUG("Cancelling completed, recurring request: %s", request_string);
+ AFB_DEBUG("Cancelling completed, recurring request: %s", request_string);
}
else if (!entry->get_recurring())
{
- DEBUG("Cancelling completed, non-recurring request: %s", request_string);
+ AFB_DEBUG("Cancelling completed, non-recurring request: %s", request_string);
cancel_request(entry);
find_and_erase(entry, non_recurring_requests_);
}
// Erase any existing request not already cleaned.
cleanup_request(entry, true);
- DEBUG("Added one-time diagnostic request on bus %s: %s",
+ AFB_DEBUG("Added one-time diagnostic request on bus %s: %s",
bus_.c_str(), request_string);
non_recurring_requests_.push_back(entry);
}
else
{
- WARNING("There isn't enough request entry. Vector exhausted %d/%d", (int)non_recurring_requests_.size(), MAX_SIMULTANEOUS_DIAG_REQUESTS);
+ AFB_WARNING("There isn't enough request entry. Vector exhausted %d/%d", (int)non_recurring_requests_.size(), MAX_SIMULTANEOUS_DIAG_REQUESTS);
non_recurring_requests_.resize(MAX_SIMULTANEOUS_DIAG_REQUESTS);
}
return entry;
bool diagnostic_manager_t::validate_optional_request_attributes(float frequencyHz)
{
if(frequencyHz > MAX_RECURRING_DIAGNOSTIC_FREQUENCY_HZ) {
- DEBUG("Requested recurring diagnostic frequency %lf is higher than maximum of %d",
+ AFB_DEBUG("Requested recurring diagnostic frequency %lf is higher than maximum of %d",
frequencyHz, MAX_RECURRING_DIAGNOSTIC_FREQUENCY_HZ);
return false;
}
}
else
{
- WARNING("There isn't enough request entry. Vector exhausted %d/%d", (int)recurring_requests_.size(), MAX_SIMULTANEOUS_DIAG_REQUESTS);
+ AFB_WARNING("There isn't enough request entry. Vector exhausted %d/%d", (int)recurring_requests_.size(), MAX_SIMULTANEOUS_DIAG_REQUESTS);
recurring_requests_.resize(MAX_SIMULTANEOUS_DIAG_REQUESTS);
}
}
else
- { DEBUG("Can't add request, one already exists with same key");}
+ { AFB_DEBUG("Can't add request, one already exists with same key");}
return entry;
}
found_signals = utils::signals_manager_t::instance().find_signals(build_DynamicField(adr->get_name()));
found_signals.diagnostic_messages.front()->set_supported(false);
cleanup_request(adr, true);
- NOTICE("PID not supported or ill formed. Please unsubscribe from it. Error code : %d", response.negative_response_code);
+ AFB_NOTICE("PID not supported or ill formed. Please unsubscribe from it. Error code : %d", response.negative_response_code);
message = build_VehicleMessage(build_SimpleMessage(adr->get_name(), build_DynamicField("This PID isn't supported by your vehicle.")));
}
{
if (config_content_.size() <= 0)
{
- ERROR("Can't load the INI config file.");
+ AFB_ERROR("Can't load the INI config file.");
return false;
}
- DEBUG("Configuration file parsed");
+ AFB_DEBUG("Configuration file parsed");
return true;
}
return devices_name;
}
-}
\ No newline at end of file
+}
lookup_signals_by_id(key.numeric_value, application_t::instance().get_diagnostic_messages(), sf.diagnostic_messages);
break;
default:
- ERROR("wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
+ AFB_ERROR("wrong openxc_DynamicField specified. Use openxc_DynamicField_Type_NUM or openxc_DynamicField_Type_STRING type only.");
break;
}
- DEBUG("Found %d signal(s)", (int)(sf.can_signals.size() + sf.diagnostic_messages.size()));
+ AFB_DEBUG("Found %d signal(s)", (int)(sf.can_signals.size() + sf.diagnostic_messages.size()));
return sf;
}
-}
\ No newline at end of file
+}
// Attempts to open a socket to CAN bus
::strcpy(ifr.ifr_name, device_name.c_str());
- DEBUG("BCM socket ifr_name is : %s", ifr.ifr_name);
+ AFB_DEBUG("BCM socket ifr_name is : %s", ifr.ifr_name);
if(::ioctl(socket_, SIOCGIFINDEX, &ifr) < 0)
{
- ERROR("ioctl failed. Error was : %s", strerror(errno));
+ AFB_ERROR("ioctl failed. Error was : %s", strerror(errno));
close();
}
else
if(connect((struct sockaddr *)&tx_address_, sizeof(tx_address_)) < 0)
{
- ERROR("Connect failed. %s", strerror(errno));
+ AFB_ERROR("Connect failed. %s", strerror(errno));
close();
}
// Needed because of using systemD event loop. See sd_event_add_io manual.
ioctl(s.socket(), SIOCGIFNAME, &ifr);
long unsigned int frame_size = nbytes-sizeof(struct bcm_msg_head);
- DEBUG("Data available: %li bytes read. BCM head, opcode: %i, can_id: %i, nframes: %i", frame_size, msg.msg_head.opcode, msg.msg_head.can_id, msg.msg_head.nframes);
- DEBUG("read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", ifr.ifr_name, msg.msg_head.can_id, msg.frames.can_dlc,
+ AFB_DEBUG("Data available: %li bytes read. BCM head, opcode: %i, can_id: %i, nframes: %i", frame_size, msg.msg_head.opcode, msg.msg_head.can_id, msg.msg_head.nframes);
+ AFB_DEBUG("read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", ifr.ifr_name, msg.msg_head.can_id, msg.frames.can_dlc,
msg.frames.data[0], msg.frames.data[1], msg.frames.data[2], msg.frames.data[3], msg.frames.data[4], msg.frames.data[5], msg.frames.data[6], msg.frames.data[7]);
struct timeval tv;
return s;
}
-}
\ No newline at end of file
+}
// Attempts to open a socket to CAN bus
::strcpy(ifr.ifr_name, device_name.c_str());
- DEBUG("ifr_name is : %s", ifr.ifr_name);
+ AFB_DEBUG("ifr_name is : %s", ifr.ifr_name);
if(::ioctl(socket_, SIOCGIFINDEX, &ifr) < 0)
{
- ERROR("ioctl failed. Error was : %s", strerror(errno));
+ AFB_ERROR("ioctl failed. Error was : %s", strerror(errno));
close();
}
else
if(bind((struct sockaddr *)&tx_address_, sizeof(tx_address_)) < 0)
{
- ERROR("Bind failed. %s", strerror(errno));
+ AFB_ERROR("Bind failed. %s", strerror(errno));
close();
}
}
ifr.ifr_ifindex = addr.can_ifindex;
ioctl(s.socket(), SIOCGIFNAME, &ifr);
- DEBUG("Data available: %i bytes read", (int)nbytes);
- DEBUG("read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", ifr.ifr_name, frame.can_id, frame.len,
+ AFB_DEBUG("Data available: %i bytes read", (int)nbytes);
+ AFB_DEBUG("read: Found on bus %s:\n id: %X, length: %X, data %02X%02X%02X%02X%02X%02X%02X%02X", ifr.ifr_name, frame.can_id, frame.len,
frame.data[0], frame.data[1], frame.data[2], frame.data[3], frame.data[4], frame.data[5], frame.data[6], frame.data[7]);
struct timeval tv;
return s;
}
-}
\ No newline at end of file
+}
socketcan_t& operator<<(socketcan_t& s, const T& obj)
{
if (::sendto(s.socket(), &obj, sizeof(obj), 0, (const struct sockaddr*)&s.get_tx_address(), sizeof(s.get_tx_address())) < 0)
- ERROR("Error sending : %i %s", errno, ::strerror(errno));
+ AFB_ERROR("Error sending : %i %s", errno, ::strerror(errno));
return s;
}
}