Go Down

Topic: can't compile sketch with include RF12 (Read 793 times) previous topic - next topic

sambuls

I try to compile a test program for the RF12 module.
I've download the RF12 and ports library from jeelabs

These two folders I've copied to Applications/Arduino/Contents/Resources/Java/libraries
When I restart the Arduino software I see the the libraries under the 'open' drop down menu.

When I try to compile the most simple program I get lots of error.
The compiler complines that he cannot find the most basic functions??

Code: [Select]
#include <RF12.h>
#include <Ports.h>

void setup(){
}

void loop(){
}



The error message:

Code: [Select]

In file included from pingPong.pde:2:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In member function 'void Port::mode(uint8_t) const':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:29: error: 'pinMode' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In member function 'uint8_t Port::digiRead() const':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:31: error: 'digitalRead' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In member function 'void Port::digiWrite(uint8_t) const':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:33: error: 'digitalWrite' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:33: error: return-statement with a value, in function returning 'void'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In member function 'void Port::anaWrite(uint8_t) const':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:35: error: 'analogWrite' was not declared in this scope
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In member function 'uint32_t Port::pulse(uint8_t, uint32_t) const':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:37: error: 'pulseIn' was not declared in this scope

.....

/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:255: error: 'word' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:258: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:259: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:260: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:261: error: 'word' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In constructor 'MemoryStream::MemoryStream(MemoryPlug&, int, char)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:256: error: class 'MemoryStream' does not have any field named 'start'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:256: error: class 'MemoryStream' does not have any field named 'curr'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:256: error: class 'MemoryStream' does not have any field named 'pos'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:266: error: expected class-name before '{' token
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:269: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:271: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:271: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:272: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:275: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:279: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:282: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In constructor 'UartPlug::UartPlug(PortI2C&, int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:276: error: class 'UartPlug' does not have any field named 'in'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:276: error: class 'UartPlug' does not have any field named 'out'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:297: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:301: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:302: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:302: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:303: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:308: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:308: error: 'word' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:317: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:326: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:328: error: ISO C++ forbids declaration of 'word' with no type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:328: error: expected ';' before '*' token
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:330: error: 'word' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:335: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:388: error: 'word' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:389: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:391: error: 'byte' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:393: error: 'word' does not name a type
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: In constructor 'HeadingBoard::HeadingBoard(int)':
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:398: error: class 'HeadingBoard' does not have any field named 'setReset'
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h: At global scope:
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:415: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:420: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:420: error: 'byte' has not been declared
/Applications/Arduino.app/Contents/Resources/Java/libraries/Ports/Ports.h:421: error: 'byte' does not name a type


I'm probably making a basic mistake?

Can anyone guide me?

Arrch

#1
Nov 09, 2012, 09:38 pm Last Edit: Nov 09, 2012, 09:52 pm by Arrch Reason: 1
Looks like you downloaded the library that was intended for sub 1.0 Arduino and are using the Arduino 1.0+ IDE.

MarkT

Try newer version of each library?  They should refer to "Arduino.h" rather than "WProgram.h"
[ I won't respond to messages, use the forum please ]

sambuls

I'm searching for a newer version for RF12.
Apparently not so evident as I thought it would be...

thanks

MarkT

Well there are many postings about making a library Arduino 1.0 compatible on here, a simple search here may help.
[ I won't respond to messages, use the forum please ]

sambuls

Thank you for your reply.

I try to make the libraries compatible with the newer version of Arduino.
I've copied the Arduino.h to WProgram.h

Now the compiler give me the following errors:

Code: [Select]


In file included from pingPong.pde:2:
/Users/sambuls/Documents/Arduino/libraries/Ports/Ports.h:282: error: conflicting return type specified for 'virtual void UartPlug::write(byte)'
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:48: error:   overriding 'virtual size_t Print::write(uint8_t)'



What am I doing wrong?

sambuls

I would like to thank you all for the previous fast replies.

I discarded previous library that was not compatible with the newest version of Arduino.

I have found an other RM12 library that is compatible with the newest version of Arduino.

Code: [Select]
https://github.com/bazingalabs/RF12B

Nick Gammon

You aren't doing anything wrong.

Edit the library (Ports.h) and change the return type for "write" to be size_t. You probably need to change Ports.cpp as well. Make it return the number of bytes written (eg. 1).
http://www.gammon.com.au/electronics

PaulS

Quote
I've copied the Arduino.h to WProgram.h

Bad idea. It would have been better to have simply edited the library to change what file it was trying to include. You ARE going to have to do that, anyway.

sambuls

#9
Nov 10, 2012, 12:38 pm Last Edit: Nov 10, 2012, 01:19 pm by sambuls Reason: 1

You aren't doing anything wrong.

Edit the library (Ports.h) and change the return type for "write" to be size_t. You probably need to change Ports.cpp as well. Make it return the number of bytes written (eg. 1).


Could you be a little bit more explicite on the change that I have to do on the return type?
If I change something in the cpp file, do I have to compile it with some kind of other compiler?


PaulS

Quote
Could you be a little bit more explicite on the change that I have to do on the return type?

No. You know the name of the function that has the wrong return type. You know the file that that function is in. You know the line number of the function in the file. If you can't open the file, find the appropriate line, recognize the current return type, and tap the appropriate keys to change it, then programming is not for you.

Nick Gammon

In the copy of ports.h I happened to have on my disk I see:


Code: [Select]

class UartPlug : public Print {
...
    virtual void write(byte);
};


That's the spot. You change the return type of the write function to size_t, like this:

Code: [Select]

class UartPlug : public Print {
...
    virtual size_t write(byte);
};





And in ports.cpp, change:

Code: [Select]

void UartPlug::write (byte data) {
    regSet(THR, data);
    dev.stop();
}


To:

Code: [Select]

size_t UartPlug::write (byte data) {
    regSet(THR, data);
    dev.stop();
    return 1;
}


Which is pretty-much what I said above.
http://www.gammon.com.au/electronics

Go Up