sparkfun / OpenLog

Open Source Hardware Datalogger
https://www.sparkfun.com/products/9530
Other
553 stars 216 forks source link

Won't compile with Arduino 1.6.4 #188

Closed ohhorob closed 9 years ago

ohhorob commented 9 years ago

Per instructions on this GitHub repo, I downloaded SerialPortBeta20120106.zip and unpacked it, moved the SerialPort folder to the libraries directory.

Build options changed, rebuilding all
Using library SdFat in folder: /Applications/Arduino.app/Contents/Java/libraries/SdFat (legacy)
Using library SerialPort in folder: /Applications/Arduino.app/Contents/Java/libraries/SerialPort (legacy)
Using library EEPROM in folder: /Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/EEPROM 

/Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10604 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/cores/arduino -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/variants/standard -I/Applications/Arduino.app/Contents/Java/libraries/SdFat -I/Applications/Arduino.app/Contents/Java/libraries/SerialPort -I/Applications/Arduino.app/Contents/Java/hardware/arduino/avr/libraries/EEPROM /var/folders/8p/8cqdmrl10t79g_7gnkytpqn40000gq/T/build876313168200282986.tmp/OpenLog_v3.cpp -o /var/folders/8p/8cqdmrl10t79g_7gnkytpqn40000gq/T/build876313168200282986.tmp/OpenLog_v3.cpp.o 
In file included from OpenLog_v3.ino:180:0:
/Applications/Arduino.app/Contents/Java/libraries/SerialPort/SerialPort.h: In member function 'size_t SerialPort<PortNumber, RxBufSize, TxBufSize>::write(const __FlashStringHelper*)':
/Applications/Arduino.app/Contents/Java/libraries/SerialPort/SerialPort.h:583:11: error: 'prog_char' does not name a type
     const prog_char* p = (const prog_char*)s;
           ^
/Applications/Arduino.app/Contents/Java/libraries/SerialPort/SerialPort.h:584:25: error: 'p' was not declared in this scope
     size_t n = strlen_P(p);
                         ^
Error compiling.
BrentWilkins commented 9 years ago

I don't have a way to test right now, but you might try replacing const prog_char* p with const PROGMEM char * p or const char* p. prog_char is depreciated in avr-libc. You might first try: #define __PROG_TYPES_COMPAT__

nseidle commented 9 years ago

I have run into piles of problems getting OpenLog to correctly compile under Arduino 1.6.x. At this time it only works under Arduino 1.0.x. Sorry! I'll update the wiki instructions and this issue as things change.

CerealKiller1 commented 9 years ago

Hello, sorry to bring this back up (this is my first ever issue tracker of any project...)

I am trying to compile OpenLog to install it on a custom board I made. I sourced 328P's with the arduino bootloader already installed on them. The problem is I can not compile, I get a LONG LONG list of errors. I reverted back to arduino 1.0.5 and installed the two libraries needed (SerialPort and SdFAT) yet it doesnt even come close to working. I have also tried sellecting differnt board types and tried both the regular and the lite versions.

I will copy/paste the list of error messages below. I hope my intended use is ok, it complies with the CC SA v3 license and is an open source project I'm working on @ RCGroups

Please note I tried both, downloading the linked directory from the "flashing FW" wiki page as well as downloading from the repo, I also tried copying the text from the files in the repo directly into a new sketch, I've also verified the libraries are installed, nothing works. I'm use to going threw and fixing [sometimes a lot] of errors but this just seems like something's fundamentally messed up. Thanks in advance! If this should be split into it's own issue then I'm sorry...

errors: sketch_sep19a:5: error: expected constructor, destructor, or type conversion before '<' token sketch_sep19a:70: error: 'Sd2Card' does not name a type sketch_sep19a:71: error: 'SdVolume' does not name a type sketch_sep19a:72: error: 'SdFile' does not name a type sketch_sep19a.ino: In function 'void systemError(byte)': sketch_sep19a:103: error: 'NewSerial' was not declared in this scope sketch_sep19a.ino: In function 'void setup()': sketch_sep19a:147: error: 'NewSerial' was not declared in this scope sketch_sep19a:159: error: 'card' was not declared in this scope sketch_sep19a:159: error: 'SPI_FULL_SPEED' was not declared in this scope sketch_sep19a:160: error: 'volume' was not declared in this scope sketch_sep19a:160: error: 'card' was not declared in this scope sketch_sep19a:161: error: 'currentDirectory' was not declared in this scope sketch_sep19a:162: error: 'volume' was not declared in this scope sketch_sep19a.ino: In function 'char* newlog()': sketch_sep19a:200: error: 'SdFile' was not declared in this scope sketch_sep19a:200: error: expected ;' before 'newFile' sketch_sep19a:225: error: 'NewSerial' was not declared in this scope sketch_sep19a:239: error: 'newFile' was not declared in this scope sketch_sep19a:239: error: 'currentDirectory' was not declared in this scope sketch_sep19a:239: error: 'O_CREAT' was not declared in this scope sketch_sep19a:239: error: 'O_EXCL' was not declared in this scope sketch_sep19a:239: error: 'O_WRITE' was not declared in this scope sketch_sep19a:242: error: 'newFile' was not declared in this scope sketch_sep19a:242: error: 'currentDirectory' was not declared in this scope sketch_sep19a:242: error: 'O_READ' was not declared in this scope sketch_sep19a:256: error: 'NewSerial' was not declared in this scope sketch_sep19a:260: error: 'newFile' was not declared in this scope sketch_sep19a.ino: In function 'void seqlog()': sketch_sep19a:290: error: 'SdFile' was not declared in this scope sketch_sep19a:290: error: expected;' before 'seqFile' sketch_sep19a:296: error: 'seqFile' was not declared in this scope sketch_sep19a:296: error: 'currentDirectory' was not declared in this scope sketch_sep19a:296: error: 'O_CREAT' was not declared in this scope sketch_sep19a:296: error: 'O_WRITE' was not declared in this scope sketch_sep19a:298: error: 'NewSerial' was not declared in this scope sketch_sep19a:302: error: 'seqFile' was not declared in this scope sketch_sep19a.ino: In function 'byte append_file(char*)': sketch_sep19a:316: error: 'SdFile' was not declared in this scope sketch_sep19a:316: error: expected ;' before 'workingFile' sketch_sep19a:321: error: 'workingFile' was not declared in this scope sketch_sep19a:321: error: 'currentDirectory' was not declared in this scope sketch_sep19a:321: error: 'O_CREAT' was not declared in this scope sketch_sep19a:321: error: 'O_APPEND' was not declared in this scope sketch_sep19a:321: error: 'O_WRITE' was not declared in this scope sketch_sep19a:322: error: 'workingFile' was not declared in this scope sketch_sep19a:329: error: 'NewSerial' was not declared in this scope sketch_sep19a:349: error: 'workingFile' was not declared in this scope sketch_sep19a:363: error: 'workingFile' was not declared in this scope sketch_sep19a.ino: In function 'void check_emergency_reset()': sketch_sep19a:429: error: 'card' was not declared in this scope sketch_sep19a:430: error: 'volume' was not declared in this scope sketch_sep19a:430: error: 'card' was not declared in this scope sketch_sep19a:431: error: 'currentDirectory' was not declared in this scope sketch_sep19a:432: error: 'volume' was not declared in this scope sketch_sep19a.ino: In function 'void read_config_file()': sketch_sep19a:549: error: 'SdFile' was not declared in this scope sketch_sep19a:549: error: expected;' before 'rootDirectory' sketch_sep19a:550: error: expected ;' before 'configFile' sketch_sep19a:551: error: 'rootDirectory' was not declared in this scope sketch_sep19a:551: error: 'volume' was not declared in this scope sketch_sep19a:557: error: 'configFile' was not declared in this scope sketch_sep19a:557: error: 'rootDirectory' was not declared in this scope sketch_sep19a:557: error: 'O_READ' was not declared in this scope sketch_sep19a:580: error: 'configFile' was not declared in this scope sketch_sep19a:584: error: 'configFile' was not declared in this scope sketch_sep19a:585: error: 'rootDirectory' was not declared in this scope sketch_sep19a:677: error: 'NewSerial' was not declared in this scope sketch_sep19a.ino: In function 'void record_config_file()': sketch_sep19a:760: error: 'SdFile' was not declared in this scope sketch_sep19a:760: error: expected;' before 'rootDirectory' sketch_sep19a:761: error: expected `;' before 'myFile' sketch_sep19a:762: error: 'rootDirectory' was not declared in this scope sketch_sep19a:762: error: 'volume' was not declared in this scope sketch_sep19a:768: error: 'myFile' was not declared in this scope sketch_sep19a:768: error: 'rootDirectory' was not declared in this scope sketch_sep19a:768: error: 'O_WRITE' was not declared in this scope sketch_sep19a:770: error: 'NewSerial' was not declared in this scope sketch_sep19a:780: error: 'myFile' was not declared in this scope sketch_sep19a:780: error: 'rootDirectory' was not declared in this scope sketch_sep19a:780: error: 'O_CREAT' was not declared in this scope sketch_sep19a:780: error: 'O_APPEND' was not declared in this scope sketch_sep19a:780: error: 'O_WRITE' was not declared in this scope sketch_sep19a:781: error: 'NewSerial' was not declared in this scope sketch_sep19a:803: error: 'myFile' was not declared in this scope sketch_sep19a:804: error: 'NewSerial' was not declared in this scope sketch_sep19a:806: error: 'myFile' was not declared in this scope sketch_sep19a:816: error: 'rootDirectory' was not declared in this scope

This is when pasted into a new sketch but it's the same list of errors no matter how I go about it. Please help! Thanks again.

argtrak commented 8 years ago

I know it's frowned upon to resurrect old things, but I prefer keeping relevant stuff together instead of looking at dozens of posts for a solution that should be with the question.

I hit the same problem and was able to compile in 1.6.5 by tweaking the code a bit. There are a few different ways we can make things work, but in essence, the compiler must see PROG_TYPES_COMPAT prior to any inclusion of avr/pgmspace.h in the compile process in order for the SerialPort library to compile and be usable (in this context at least).

The easiest way I found is:

  1. Add the PROG_TYPES_COMPAT line in SerialPort.h: #ifndef SerialPort_h #define SerialPort_h #define __PROG_TYPES_COMPAT__ //Needed to get SerialPort.h to work in Arduino 1.6.x
  2. Move the #include <SerialPort.h> statement to the top of the include block OpenLog.ino */ #include <SerialPort.h> #include <SPI.h> ...

This way it seems to fix both the library AND the sketch. Hope it helps. (Now back to trying this thing out!)

joneseym commented 3 years ago

@argtrak it may be 5 years later but thank you, this helped me. I'm surprised that Sparkfun have not fixed this in all that time. The Openlog bundle referenced from the Openlog guide still contains this issue and I wasted a lot of time trying to get it to compile.

Hermesfrank commented 3 years ago

@ohhorob's comment above (May 20, 2015)...

I had same problem today! June, 2021...the "fix", i.e.: _#define PROG_TYPES_COMPAT //Needed to get SerialPort.h to work in Arduino 1.6.x_, was already in the .ino file...

I downloaded IDE V1.6.5 for this purpose, and used it, so not sure what may still be lingering out there to cause such an issue so many years later - I guess @jonesym saw similar a few months ago...

Wonder what will happen if use current IDE?

If anyone has an insight as to another fix, please advise...

Followup: used my current IDE (1.8.13) - exact same result...maybe I'll try 1.0?

Followup2: installed 1.0.6 and it compiled...

markingle commented 2 years ago

This one was tough....I got lucky and found the solution. Simply change the following in Serialport.h.....

const prog_char p = (const prog_char )s to PGM_P p = (PGM_P)s;

There are two lines in the SerialPort.h that need to be changed...here is a screenshot from my header file that has been updated...

Screen Shot 2022-09-11 at 3 59 08 PM