<commit_before>/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

/* standard */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#include "utils.h"

#include "canbus.h"

/* application common */
#include "can_inf.h"
#include "spi_inf.h"
#include "common.h"

int run(void)
{
	struct can_frame tx, rx;
	int error = 0;

	/* Initialize CAN controller. */
	printf("Start CAN Loop-back Test\n");
	can_setup(125000);

//	can_id.id = 0xF;
//	can_set_filter(can_id, 0xF);

	/* Prepare CAN frame. */
	tx.ident.id = 0x123;
	tx.ident.exide = 0;
	tx.ident.rtr = 0;
	tx.dlc = 8;
	tx.data[0] = 0x08;
	tx.data[1] = 0x07;
	tx.data[2] = 0x06;
	tx.data[3] = 0x05;
	tx.data[4] = 0x04;
	tx.data[5] = 0x03;
	tx.data[6] = 0x02;
	tx.data[7] = 0x01;

	while (1) {
		/* Send message */
		can_send(tx);
		printf("Send: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n",
			error, tx.ident.id,
			tx.data[0], tx.data[1], tx.data[2], tx.data[3],
			tx.data[4], tx.data[5], tx.data[6], tx.data[7]);

		tx.ident.id++;

		/* Receive message */
		can_recv(&rx);
		printf("Recv: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n",
			error, rx.ident.id,
			rx.data[0], rx.data[1], rx.data[2], rx.data[3],
			rx.data[4], rx.data[5], rx.data[6], rx.data[7]);
	}

	return 0;
}
<commit_msg>CANBUS: Test simple CAN interfaces.<commit_after>/*
 * Copyright 2014, NICTA
 *
 * This software may be distributed and modified according to the terms of
 * the BSD 2-Clause license. Note that NO WARRANTY is provided.
 * See "LICENSE_BSD2.txt" for details.
 *
 * @TAG(NICTA_BSD)
 */

/* standard */
#include <stdio.h>
#include <string.h>
#include <stdbool.h>

#include "utils.h"

#include "canbus.h"

/* application common */
#include "can_inf.h"
#include "spi_inf.h"
#include "common.h"

void txb0_ack_callback(void *arg)
{
	txb0_ack_reg_callback(txb0_ack_callback, NULL);
	printf("%s\n", __func__);
}

void txb1_ack_callback(void *arg)
{
	txb1_ack_reg_callback(txb1_ack_callback, NULL);
	printf("%s\n", __func__);
}

void txb2_ack_callback(void *arg)
{
	txb2_ack_reg_callback(txb2_ack_callback, NULL);
	printf("%s\n", __func__);
}

int run(void)
{
	struct can_frame tx, rx;
	int error = 0;

	error = txb0_ack_reg_callback(txb0_ack_callback, NULL);
	error = txb1_ack_reg_callback(txb1_ack_callback, NULL);
	error = txb2_ack_reg_callback(txb2_ack_callback, NULL);

	/* Initialize CAN controller. */
	printf("Start CAN Loop-back Test\n");
	can_setup(125000);

//	can_id.id = 0xF;
//	can_set_filter(can_id, 0xF);

	/* Prepare CAN frame. */
	tx.ident.id = 0x123;
	tx.ident.exide = 0;
	tx.ident.rtr = 0;
	tx.dlc = 8;
	tx.data[0] = 0x08;
	tx.data[1] = 0x07;
	tx.data[2] = 0x06;
	tx.data[3] = 0x05;
	tx.data[4] = 0x04;
	tx.data[5] = 0x03;
	tx.data[6] = 0x02;
	tx.data[7] = 0x01;

	while (1) {
		/* Send message */
//		can_send(tx);
		tx.ident.id = 0x300;
		error = can_sendto(0, tx);
		if (error) {
			can_abort(0);
			printf("Send error: 0\n");
		}

		tx.ident.id = 0x100;
		error = can_sendto(1, tx);
		if (error) {
			can_abort(1);
			printf("Send error: 1\n");
		}

		tx.ident.id = 0x200;
		error = can_sendto(2, tx);
		if (error) {
			can_abort(2);
			printf("Send error: 2\n");
		}
//		printf("Send: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n",
//			error, tx.ident.id,
//			tx.data[0], tx.data[1], tx.data[2], tx.data[3],
//			tx.data[4], tx.data[5], tx.data[6], tx.data[7]);
//
//		tx.ident.id++;

		/* Receive message */
//		can_recv(&rx);
//		printf("Recv: error(%d), id(%x), data(%x, %x, %x, %x, %x, %x, %x, %x)\n",
//			error, rx.ident.id,
//			rx.data[0], rx.data[1], rx.data[2], rx.data[3],
//			rx.data[4], rx.data[5], rx.data[6], rx.data[7]);
	}

	return 0;
}

{'fraction_non_alphanumeric': 0.2078899558785362, 'fraction_numerical': 0.046716844017648584, 'mean_word_length': 3.4761904761904763, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3077867', 'n_tokens_mistral': 1907, 'n_tokens_neox': 1758, 'n_words': 369}