<commit_before>#include "usbutil.h"
#include "log.h"

void sendMessage(UsbDevice* usbDevice, uint8_t* message, int messageSize) {
    for(int i = 0; i < messageSize; i++) {
        if(!QUEUE_PUSH(uint8_t, &usbDevice->sendQueue, (uint8_t)message[i])) {
            debug("Dropped incoming CAN message -- send queue full for USB");
            return;
        }
    }
    QUEUE_PUSH(uint8_t, &usbDevice->sendQueue, (uint8_t)'\n');<commit_msg>Only queue a message to send over USB if queue has room for the whole thing.<commit_after>#include "usbutil.h"
#include "log.h"

void sendMessage(UsbDevice* usbDevice, uint8_t* message, int messageSize) {
    if(queue_available(&usbDevice->sendQueue) < messageSize + 1) {
            debug("Dropped incoming CAN message -- send queue full for USB");
            return;
    }

    for(int i = 0; i < messageSize; i++) {
        QUEUE_PUSH(uint8_t, &usbDevice->sendQueue, (uint8_t)message[i]);
    }
    QUEUE_PUSH(uint8_t, &usbDevice->sendQueue, (uint8_t)'\n');
{'fraction_non_alphanumeric': 0.13786213786213786, 'fraction_numerical': 0.012987012987012988, 'mean_word_length': 3.4732142857142856, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, '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': '4284900', 'n_tokens_mistral': 351, 'n_tokens_neox': 345, 'n_words': 83}