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

Conflicting Declaration with tNMEA2000_esp32 NMEA2000; #26

Open
atestani opened this issue Jun 6, 2024 · 6 comments
Open

Conflicting Declaration with tNMEA2000_esp32 NMEA2000; #26

atestani opened this issue Jun 6, 2024 · 6 comments

Comments

@atestani
Copy link

atestani commented Jun 6, 2024

I am porting a Teensy3.2 NMEA2000 application to ESP32. I'm using PlatformIO and an ESP32-WROOM-32E.

platformio.ini is:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
lib_deps = 
	ttlappalainen/NMEA2000-library@^4.21.5
	ttlappalainen/NMEA2000_esp32@^1.0.3
....

The start of the code looks like this:

// Set up your NMEA2000 CAN pins
#define ESP32_CAN_RX_PIN GPIO_NUM_7
#define ESP32_CAN_TX_PIN GPIO_NUM_4

#include <Arduino.h>
#include <NMEA2000_CAN.h>  // This will automatically include NMEA2000 library
#include <NMEA2000_esp32.h>  
...

// Create NMEA2000 instance
tNMEA2000_esp32 NMEA2000;

The last line is giving a conflicting declaration error. I have searched throughout the code several times and cannot find why this is happening. Also, I have been unable to find a documented example for use of these libraries on an ESP32. Any advice?

Thanks


@atestani
Copy link
Author

atestani commented Jun 7, 2024

I found more information from the error in the build output:

In file included from src/main.cpp:39:
.pio/libdeps/esp32dev/NMEA2000-library/src/NMEA2000_CAN.h:278:12: note: previous declaration as 'tNMEA2000& NMEA2000'
 tNMEA2000 &NMEA2000=*(new tNMEA2000_esp32()); 

So I don't need to declare the main object?

@ttlappalainen
Copy link
Owner

if you use
#include <NMEA2000_CAN.h> // This will automatically include NMEA2000 library
you do not explicitely include specific MCU driver and define NMEA2000 object.

@atestani
Copy link
Author

atestani commented Jun 7, 2024

Do I still use #include <NMEA2000_esp32.h>?

@ttlappalainen
Copy link
Owner

No. When you use #include <NMEA2000_CAN.h>, it includes necessary driver, if it can. If it can not then you do not #include <NMEA2000_CAN.h> and you have to explicitely include driver and define NMEA2000 object.

@atestani
Copy link
Author

atestani commented Jun 7, 2024 via email

@atestani
Copy link
Author

atestani commented Jun 7, 2024 via email

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

No branches or pull requests

2 participants