Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix:Hangup issue when sending. #118

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions examples/CANSenderTimeout/CANSenderTimeout.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Copyright (c) Sandeep Mistry. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <CAN.h>

void setup() {
Serial.begin(9600);
while (!Serial);

Serial.println("CAN Sender");

// start the CAN bus at 500 kbps
if (!CAN.begin(500E3)) {
Serial.println("Starting CAN failed!");
while (1);
}
}

void loop() {
int error_code = 0;
int count = 0;

// send packet: id is 11 bits, packet can contain up to 8 bytes of data
Serial.print("Sending packet ... ");

CAN.beginPacket(0x12);
CAN.write('h');
CAN.write('e');
CAN.write('l');
CAN.write('l');
CAN.write('o');

while (true)
{
error_code = CAN.endPacket();

Serial.println(error_code);

if (error_code == 1)
{
Serial.print("Transmission complete!");
break;
}

if(count > 5)
{
Serial.print("timeout!");
CAN.sleep();
delay(50);
CAN.wakeup();
break;
}
count++;
delay(50);
}

Serial.println("done");

delay(1000);
}
14 changes: 14 additions & 0 deletions examples/CANSenderTimeout/debug.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Example OpenOCD configuration file for ESP32-WROVER-KIT board.
#
# For example, OpenOCD can be started for ESP32 debugging on
#
# openocd -f board/esp32-wrover-kit-3.3v.cfg
#

# Source the JTAG interface configuration file
source [find interface/ftdi/esp32_devkitj_v1.cfg]
set ESP32_FLASH_VOLTAGE 3.3
# Source the ESP32 configuration file
source [find target/esp32.cfg]
19 changes: 19 additions & 0 deletions examples/CANSenderTimeout/debug_custom.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name":"Arduino on ESP32",
"toolchainPrefix":"xtensa-esp32-elf",
"svdFile":"esp32.svd",
"request":"attach",
"postAttachCommands":[
"set remote hardware-watchpoint-limit 2",
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
],
"overrideRestartCommands":[
"monitor reset halt",
"monitor gdb_sync",
"thb setup",
"c"
]
}
Loading