Skip to content
New issue

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

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

Already on GitHub? # to your account

Dependency on core_version.h in version 1.x #12

Open
lphooge opened this issue Feb 24, 2024 · 8 comments
Open

Dependency on core_version.h in version 1.x #12

lphooge opened this issue Feb 24, 2024 · 8 comments

Comments

@lphooge
Copy link

lphooge commented Feb 24, 2024

I had a bit of trouble compiling this library for an m5stack device, it complained about a missing core_version.h

After some investigation I found this is something thats included with specific boards that are installed via the arduino ide.
However M5 does not include it for their boards, and thats why it fails.

However the definitions in that file are never used inside the library (only in places where it is commented out anyways), so maybe you can consider just removing it? That would allow hassle-free usage with the m5stack boards.

The offending line is in src/ACAN_ESP32.cpp, line 6 of version 1.1.1 and 1.1.2.
Its not there in 1.1.0 and 2.0.0.

As a workaround I placed the following file under DUMMY_CORE_VERSION/core_version.h inside the arduino library folder:
#define ARDUINO_ESP32_GIT_VER 0xae9dae4a
#define ARDUINO_ESP32_GIT_DESC 2.0.11
#define ARDUINO_ESP32_RELEASE_2_0_11
#define ARDUINO_ESP32_RELEASE "2_0_11"

This way it compiles and everything works fine, but it might break things when later using an ESP board that DOES include that file for the board manager and maybe has different contents in it so thats not optimal.

@pierremolinaro
Copy link
Owner

pierremolinaro commented Feb 24, 2024 via email

@lphooge
Copy link
Author

lphooge commented Feb 25, 2024

ACAN_ESP32 is version 1.1.2 (so the latest 1.x version)
Arduino IDE is version 2.

I am not entirely sure what exactly is meant with "board manager".
There is the tool called "boards manager" inside the arduino IDE.

And there are helper tools/libraries for the esp32 platform that are installed via this boards manager.

For example in AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.11\cores\esp32
there is the file core_version.h and the directory seems to refer to a version 2.0.11 of these tools.

However for the m5stack board there is a different directory:
AppData\Local\Arduino15\packages\m5stack\hardware\esp32\2.1.0\cores\esp32
This does NOT include this header file.

@pierremolinaro
Copy link
Owner

pierremolinaro commented Feb 25, 2024 via email

@lphooge
Copy link
Author

lphooge commented Feb 25, 2024

I use an M5stack tough, however I also have a M5 Core 2 and a M5 Stamp C3U here and tried that:
It does not matter which of the M5 boards I select, everyone gives this compile error.

And on all of them it works when I just comment out the line "#include <core_version.h>" in ACAN_ESP32.cpp but not when its in there.
The problem does not show when I select an official ESP32 Board, like "ESP32 Dev Module" (I don't actually own one, but can test compiling it of course), then it compiles fine with that include in there.

Here is a full working sketch for the m5, basically a stripped down version of the loopback example with the m5unified library added for bord specific initialisation and the pins changed to match the Port A Grove Connector on the M5 Tough and Core 2 boards:

`
#include <ACAN_ESP32.h>
#include <M5Unified.h> // needed for proper function, remove for just testing if compiling works

static const uint32_t DESIRED_BIT_RATE = 250UL * 1000UL ; // 250 kb/s

void setup () {

/*
needed for proper function, without this the result is always TXERR 128 - probably some pin initialization that is happening here.
For just testing compilation, can be taken out.
*/
M5.begin();

//--- Start serial
Serial.begin (9600) ;
delay (100) ;
//--- Configure ESP32 CAN
Serial.println ("Configure ESP32 CAN") ;
ACAN_ESP32_Settings settings (DESIRED_BIT_RATE) ;
settings.mRequestedCANMode = ACAN_ESP32_Settings::LoopBackMode ;
settings.mRxPin = GPIO_NUM_33 ; // Optional, default Tx pin is GPIO_NUM_4
settings.mTxPin = GPIO_NUM_32 ; // Optional, default Rx pin is GPIO_NUM_5
const uint32_t errorCode = ACAN_ESP32::can.begin (settings) ;
if (errorCode == 0) {
Serial.println ("Configuration OK!");
}else {
Serial.print ("Configuration error 0x") ;
Serial.println (errorCode, HEX) ;
}
}

//----------------------------------------------------------------------------------------

static uint32_t gBlinkLedDate = 0 ;
static uint32_t gReceivedFrameCount = 0 ;
static uint32_t gSentFrameCount = 0 ;

//----------------------------------------------------------------------------------------
// LOOP
//----------------------------------------------------------------------------------------

void loop () {
CANMessage frame ;
if (gBlinkLedDate < millis ()) {
gBlinkLedDate += 500 ;
// digitalWrite (LED_BUILTIN, !digitalRead (LED_BUILTIN)) ;
Serial.print ("Sent: ") ;
Serial.print (gSentFrameCount) ;
Serial.print (" ") ;
Serial.print ("Receive: ") ;
Serial.print (gReceivedFrameCount) ;
Serial.print (" ") ;
Serial.print (" STATUS 0x") ;
Serial.print (TWAI_STATUS_REG, HEX) ;
Serial.print (" RXERR ") ;
Serial.print (TWAI_RX_ERR_CNT_REG) ;
Serial.print (" TXERR ") ;
Serial.println (TWAI_TX_ERR_CNT_REG) ;
const bool ok = ACAN_ESP32::can.tryToSend (frame) ;
if (ok) {
gSentFrameCount += 1 ;
}
}
while (ACAN_ESP32::can.receive (frame)) {
gReceivedFrameCount += 1 ;
}
}
`

@lphooge
Copy link
Author

lphooge commented Feb 25, 2024

Here is the view of the arduino board manager
board manager m5

@pierremolinaro
Copy link
Owner

pierremolinaro commented Feb 26, 2024 via email

@lphooge
Copy link
Author

lphooge commented Feb 26, 2024

I just tried, installed 2.0.0 and changed that line.
It compiles and uploads to the board, but gives TXERR128 and doesn't receive anything.

With 1.1.2 (+core_version fix) it works.

@lphooge
Copy link
Author

lphooge commented Feb 26, 2024

Ok now it works. I tried to find the problem and compiled a few times and suddently it worked.
Maybe the build directory had old crap in it that messed up the first compilation with the new library.

Edit: I now tried the patched 2.0.0 library with my main project, where it connects via CAN to a electric motor controller. Works fine without any changes to my code.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants