Reduced some logging, and added id filter

This commit is contained in:
Dreaded_X 2022-06-21 04:10:43 +02:00
parent 4bb95d2208
commit b4cb413d4c
Signed by: Dreaded_X
GPG Key ID: 76BDEC4E165D8AD9
2 changed files with 7 additions and 8 deletions

View File

@ -50,4 +50,3 @@ extern "C" void app_main() {
/* can::init(); */
twai::init();
}

View File

@ -10,17 +10,13 @@
static void listen(void*) {
for (;;) {
twai_message_t message;
if (twai_receive(&message, portMAX_DELAY) == ESP_OK) {
ESP_LOGI(TWAI_TAG, "Message received");
} else {
if (twai_receive(&message, portMAX_DELAY) != ESP_OK) {
ESP_LOGI(TWAI_TAG, "Failed to receive message");
continue;
}
if (message.extd) {
ESP_LOGI(TWAI_TAG, "Message is in Extended Format");
} else {
ESP_LOGI(TWAI_TAG, "Message is in Standard Format");
}
ESP_LOGI(TWAI_TAG, "ID=%d, Length=%d", message.identifier, message.data_length_code);
@ -28,9 +24,13 @@ static void listen(void*) {
}
void twai::init() {
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_5, GPIO_NUM_19, TWAI_MODE_LISTEN_ONLY);
twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_5, GPIO_NUM_19, TWAI_MODE_NORMAL);
twai_timing_config_t t_config = TWAI_TIMING_CONFIG_125KBITS();
twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL();
twai_filter_config_t f_config = {
.acceptance_code = (0b100100101 << 5) + (0b1000011111 << 21),
.acceptance_mask = (0b011000000 << 5),
.single_filter = false
};
if (twai_driver_install(&g_config, &t_config, &f_config) == ESP_OK) {
ESP_LOGI(TWAI_TAG, "Driver installed");