Longan-Labs / Serial_CAN_Arduino

MIT License
54 stars 22 forks source link

sketch/Serial_CAN_Module.cpp: In member function 'unsigned char Serial_CAN::exitSettingMode()': #5

Open yigitbacakoglu opened 4 years ago

yigitbacakoglu commented 4 years ago

Hi, could you please help me with the error below;

` Arduino: 1.8.12 (Mac OS X), Board: "Arduino Nano, ATmega328P"

sketch/Serial_CAN_Module.cpp: In member function 'unsigned char Serial_CAN::exitSettingMode()': sketch/Serial_CAN_Module.cpp:172:31: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] int ret = cmdOk("AT+Q\r\n"); ^ sketch/Serial_CAN_Module.cpp: In member function 'unsigned char Serial_CAN::factorySetting()': sketch/Serial_CAN_Module.cpp:286:26: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] if(cmdOk("AT\r\n")) ^ /Users/yigit/Documents/Arduino/libraries/Serial_CAN_Module/Serial_CAN_Module.cpp: In member function 'unsigned char Serial_CAN::exitSettingMode()': /Users/yigit/Documents/Arduino/libraries/Serial_CAN_Module/Serial_CAN_Module.cpp:172:31: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] int ret = cmdOk("AT+Q\r\n"); ^ /Users/yigit/Documents/Arduino/libraries/Serial_CAN_Module/Serial_CAN_Module.cpp: In member function 'unsigned char Serial_CAN::factorySetting()': /Users/yigit/Documents/Arduino/libraries/Serial_CAN_Module/Serial_CAN_Module.cpp:286:26: warning: ISO C++ forbids converting a string constant to 'char' [-Wwrite-strings] if(cmdOk("AT\r\n")) ^ libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofcanSerial' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::begin(int, int, unsigned long)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::send(unsigned long, unsigned char, unsigned char, unsigned char, unsigned char const)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::recv(unsigned long, unsigned char)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::clear()' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::cmdOk(char)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::enterSettingMode()' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::exitSettingMode()' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::canRate(unsigned char)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::baudRate(unsigned char)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofmake8zerochar(int, char, unsigned long)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::setMask(unsigned long)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::setFilt(unsigned long*)' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::factorySetting()' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here libraries/Serial_CAN_Module/Serial_CAN_Module.cpp.o (symbol from plugin): In function canSerial': (.text+0x0): multiple definition ofSerial_CAN::debugMode()' sketch/Serial_CAN_Module.cpp.o (symbol from plugin):(.text+0x0): first defined here collect2: error: ld returned 1 exit status exit status 1 Error compiling for board Arduino Nano.

This report would have more information with "Show verbose output during compilation" option enabled in File -> Preferences. `

yigitbacakoglu commented 4 years ago

@stephen1874 can you please have a look at this issue? your help will be appreciated. Thanks

stephen1874 commented 4 years ago

Hello @yigitbacakoglu , the error is multiple definition, could you pelase check if you have 2 same library in your folder or somethere else. I just with Arduino 1.8.10, everything is ok.

yigitbacakoglu commented 4 years ago

Hello @yigitbacakoglu , the error is multiple definition, could you pelase check if you have 2 same library in your folder or somethere else. I just with Arduino 1.8.10, everything is ok.

Hi Stephen, thanks for quick reply,

Yeap I found this library in the same folder of the .ino file and in the Arduino/libraries folder. and removing one resolved the multiple definition of error but not ISO C++ forbids converting a string constant to error.

So I changed all cmdOk usages from

unsigned char Serial_CAN::exitSettingMode() { clear(); int ret = cmdOk("AT+Q\r\n"); clear(); return ret; }

to

unsigned char Serial_CAN::exitSettingMode() { clear(); int ret = cmdOk((char *)"AT+Q\r\n"); clear(); return ret; } and it was compiled, does it make any sense?

stephen1874 commented 4 years ago

@yigitbacakoglu yes, this make sense, I will modify the code to avoid this wraning as well. Thanks.