Pages: [1]   Go Down
Author Topic: can't compile sketch with include RF12  (Read 759 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
#include <RF12.h>
#include <Ports.h>

void setup(){
}

void loop(){
}


The error message:

Code:
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?
Logged

California
Offline Offline
Faraday Member
**
Karma: 88
Posts: 3382
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like you downloaded the library that was intended for sub 1.0 Arduino and are using the Arduino 1.0+ IDE.
« Last Edit: November 09, 2012, 03:52:16 pm by Arrch » Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12190
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try newer version of each library?  They should refer to "Arduino.h" rather than "WProgram.h"
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

thanks
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12190
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well there are many postings about making a library Arduino 1.0 compatible on here, a simple search here may help.
Logged

[ I won't respond to messages, use the forum please ]

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

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?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
https://github.com/bazingalabs/RF12B
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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).
Logged


Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49372
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 5
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?

« Last Edit: November 10, 2012, 07:19:28 am by sambuls » Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 614
Posts: 49372
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18806
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Code:
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:
class UartPlug : public Print {
...
    virtual size_t write(byte);
};



And in ports.cpp, change:

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

To:

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

Which is pretty-much what I said above.
Logged


Pages: [1]   Go Up
Jump to: