Reduced some logging, and added id filter
This commit is contained in:
parent
4bb95d2208
commit
b4cb413d4c
|
@ -50,4 +50,3 @@ extern "C" void app_main() {
|
|||
/* can::init(); */
|
||||
twai::init();
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in New Issue
Block a user