<commit_before>#include "can/canutil.h"
#include "can/canwrite.h"
#include "util/timer.h"
#include "util/statistics.h"
#include "util/log.h"

#define BUS_STATS_LOG_FREQUENCY_S 15
#define CAN_MESSAGE_TOTAL_BIT_SIZE 128
#define DYNAMIC_MESSAGE_MAP_CAPACITY 25

namespace time = openxc::util::time;
namespace statistics = openxc::util::statistics;

using openxc::util::log::debugNoNewline;
using openxc::util::statistics::DeltaStatistic;

const int openxc::can::CAN_ACTIVE_TIMEOUT_S = 30;

void openxc::can::initializeCommon(CanBus* bus) {
    debugNoNewline("Initializing CAN node %d...", bus->address);
    QUEUE_INIT(CanMessage, &bus->receiveQueue);
    QUEUE_INIT(CanMessage, &bus->sendQueue);
    bus->writeHandler = openxc::can::write::sendMessage;
    bus->lastMessageReceived = 0;
    // TODO could create this on the fly since most of the time we won't use it
    bus->dynamicMessages = emhashmap_create(DYNAMIC_MESSAGE_MAP_CAPACITY);
#ifdef __LOG_STATS__
    statistics::initialize(&bus->totalMessageStats);
    statistics::initialize(&bus->droppedMessageStats);
    statistics::initialize(&bus->receivedMessageStats);
    statistics::initialize(&bus->receivedDataStats);
    statistics::initialize(&bus->sendQueueStats);
    statistics::initialize(&bus->receiveQueueStats);
#endif // __LOG_STATS__
}

void openxc::can::destroy(CanBus* bus) {
    if(bus->dynamicMessages != NULL) {
        MapIterator iterator = emhashmap_iterator(bus->dynamicMessages);
        MapEntry* next = NULL;
        while((next = emhashmap_iterator_next(&iterator)) != NULL) {
            delete (CanMessageDefinition*)next->value;
        }
        emhashmap_destroy(bus->dynamicMessages);
    }
}

bool openxc::can::busActive(CanBus* bus) {<commit_msg>Space out CAN log messages.<commit_after>#include "can/canutil.h"
#include "can/canwrite.h"
#include "util/timer.h"
#include "util/statistics.h"
#include "util/log.h"

#define BUS_STATS_LOG_FREQUENCY_S 15
#define CAN_MESSAGE_TOTAL_BIT_SIZE 128
#define DYNAMIC_MESSAGE_MAP_CAPACITY 25

namespace time = openxc::util::time;
namespace statistics = openxc::util::statistics;

using openxc::util::log::debugNoNewline;
using openxc::util::statistics::DeltaStatistic;

const int openxc::can::CAN_ACTIVE_TIMEOUT_S = 30;

void openxc::can::initializeCommon(CanBus* bus) {
    debug("Initializing CAN node %d...", bus->address);
    QUEUE_INIT(CanMessage, &bus->receiveQueue);
    QUEUE_INIT(CanMessage, &bus->sendQueue);
    bus->writeHandler = openxc::can::write::sendMessage;
    bus->lastMessageReceived = 0;
    // TODO could create this on the fly since most of the time we won't use it
    bus->dynamicMessages = emhashmap_create(DYNAMIC_MESSAGE_MAP_CAPACITY);
#ifdef __LOG_STATS__
    statistics::initialize(&bus->totalMessageStats);
    statistics::initialize(&bus->droppedMessageStats);
    statistics::initialize(&bus->receivedMessageStats);
    statistics::initialize(&bus->receivedDataStats);
    statistics::initialize(&bus->sendQueueStats);
    statistics::initialize(&bus->receiveQueueStats);
#endif // __LOG_STATS__
}

void openxc::can::destroy(CanBus* bus) {
    if(bus->dynamicMessages != NULL) {
        MapIterator iterator = emhashmap_iterator(bus->dynamicMessages);
        MapEntry* next = NULL;
        while((next = emhashmap_iterator_next(&iterator)) != NULL) {
            delete (CanMessageDefinition*)next->value;
        }
        emhashmap_destroy(bus->dynamicMessages);
    }
}

bool openxc::can::busActive(CanBus* bus) {
{'fraction_non_alphanumeric': 0.1323571633649153, 'fraction_numerical': 0.005742176284811944, 'mean_word_length': 5.380952380952381, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 35, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5244753', 'n_tokens_mistral': 1120, 'n_tokens_neox': 1095, 'n_words': 198}