0
Offline
Jr. Member
Karma: 0
Posts: 57
Arduino rocks
|
 |
« on: August 24, 2010, 04:29:46 pm » |
I am creating an arduino library, composed of a .cpp file and a header file Header: void getCommand(byte *command);
cpp: void RemoteC::getCommand(byte *command) { //Function Defenition }
Error: \arduino-0019\libraries\RemoteC\RemotC.cpp:10: error: prototype for 'void RemoteC::getCommand(byte**)' does not match any in class 'RemoteC' \arduino-0019\libraries\RemoteC\/RemoteC.h:12: error: candidate is: void RemoteC::getCommand(byte*)
Can anyone point out the problem? Thank you 
|
|
|
|
|
Logged
|
|
|
|
|
Phoenix, Arizona USA
Offline
Faraday Member
Karma: 30
Posts: 5123
Where's the beer?
|
 |
« Reply #1 on: August 24, 2010, 04:34:56 pm » |
Your header needs a class definition, of which your function is declared as a public method.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Online
Brattain Member
Karma: 336
Posts: 36467
Seattle, WA USA
|
 |
« Reply #2 on: August 24, 2010, 06:44:28 pm » |
I think we need to see more of your code. It appears from the error message that the code snippet from the .cpp file is not what is actually in the .cpp file.
The error message says that you are defining a function that takes an array of pointers, while the function is declared to take a single pointer.
Perhaps, though, it is the sketch that is calling the function that is in error. How are you calling the function?
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 57
Arduino rocks
|
 |
« Reply #3 on: August 25, 2010, 04:14:37 am » |
This is the calss header(part of it): #ifndef RemoteC_h #define RemoteC_h #include "WProgram.h" class RemoteC { public: RemoteC(); void execute(int command, int port, int value); void getCommand(byte *command); .. .. .. private: byte _command[2]; byte _port[2]; .. .. }; #endif
I am not calling the function yet. I am constructing the class right now. Thank you.
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #4 on: August 25, 2010, 04:30:33 am » |
Just a guess... \arduino-0019\libraries\RemoteC\RemotC.cpp:10: error: prototype for 'void RemoteC::getCommand(byte**)' does not match any in class 'RemoteC' \arduino-0019\libraries\RemoteC\/RemoteC.h:12: error: candidate is: void RemoteC::getCommand(byte*)
RemotC.cpp and Remot eC.h??? Edit: Nevermind, having problems replicating the issue even with different filenames.
|
|
|
|
« Last Edit: August 25, 2010, 04:39:37 am by Eight »
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #5 on: August 25, 2010, 04:48:17 am » |
I give up already.  RemoteC.h #ifndef RemoteC_h #define RemoteC_h
#include "WProgram.h"
class RemoteC { public: void getCommand(byte *command); };
#endif RemotC.cpp #include "RemoteC.h"
void RemoteC::getCommand(byte *command) { }
Works absolutely fine for me. I suggest posting your complete RemotC.app code.
|
|
|
|
« Last Edit: August 25, 2010, 04:49:41 am by Eight »
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 57
Arduino rocks
|
 |
« Reply #6 on: August 25, 2010, 04:59:50 am » |
Eight.... THANK YOU!  To late to party.. Still having the error.. \arduino-0019\libraries\RemoteC\RemoteC.cpp:10: error: prototype for 'void RemoteC::getCommand(byte**)' does not match any in class 'RemoteC' \arduino-0019\libraries\RemoteC\/RemoteC.h:12: error: candidate is: void RemoteC::getCommand(byte*)
|
|
|
|
« Last Edit: August 25, 2010, 05:07:06 am by BN.barak »
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #7 on: August 25, 2010, 05:01:58 am » |
Lol. If I helped, I don't know how. 
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 57
Arduino rocks
|
 |
« Reply #8 on: August 25, 2010, 05:09:31 am » |
I think you for you help  void RemoteC::getCommand(byte *command[]) { _command[] = {&command[0] , &command[1]}; _port[] = {&command[2] , &command[3]}; _value[] = {&command[4] , &command[5] , &command[6]}; command = atoi(_command); port = atoi(_port); value = atoi(_value); execute(command,port,value); }
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #9 on: August 25, 2010, 05:15:20 am » |
 Ah, ok. In your function there you have overloaded getCommand() with different parameters. Instead of passing in a pointer to a byte, you are asking for a pointer to an array of pointers to byte. byte *command vs byte *command[] So in RemoteC.h, just change it to public: void getCommand(byte *command[]);
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #10 on: August 25, 2010, 05:17:57 am » |
Although... I'm going to guess you want to call the function with something like byte myCommand[] = {0,1,2,3,4}; myRemoteC.getCommand(myCommand);
So: RemoteC.h void getCommand(byte command[]); RemoteC.cpp void RemoteC::getCommand(byte command[]) { } Might work better, and just avoid using pointers altogether. 
|
|
|
|
« Last Edit: August 25, 2010, 05:19:46 am by Eight »
|
Logged
|
|
|
|
|
0
Offline
Jr. Member
Karma: 0
Posts: 57
Arduino rocks
|
 |
« Reply #11 on: August 25, 2010, 05:36:22 am » |
well, now there are some new errors: \arduino-0019\libraries\RemoteC\RemoteC.cpp: In member function 'void RemoteC::getCommand(byte*)': \arduino-0019\libraries\RemoteC\RemoteC.cpp:12: error: expected primary-expression before ']' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:12: error: expected primary-expression before '{' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:12: error: expected `;' before '{' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:13: error: expected primary-expression before ']' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:13: error: expected primary-expression before '{' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:13: error: expected `;' before '{' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:14: error: expected primary-expression before ']' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:14: error: expected primary-expression before '{' token \arduino-0019\libraries\RemoteC\RemoteC.cpp:14: error: expected `;' before '{' token line12: _command[] = {command[0] , command[1]}; _port[] = {command[2] , command[3]}; _value[] = {command[4] , command[5] , command[6]}; And how can I convert byte array to integer? Thank you.
|
|
|
|
« Last Edit: August 25, 2010, 05:37:12 am by BN.barak »
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #12 on: August 25, 2010, 05:43:55 am » |
Try void RemoteC::getCommand(byte command[]) { _command[] = {command[0] , command[1]}; _port[] = {command[2] , command[3]}; _value[] = {command[4] , command[5] , command[6]};
command = atoi(_command); port = atoi(_port); value = atoi(_value); execute(command,port,value); }
No & signs since we're not explicitly using pointers.
|
|
|
|
« Last Edit: August 25, 2010, 05:44:19 am by Eight »
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #13 on: August 25, 2010, 05:48:23 am » |
Missed the second half of your question there.
You want command to be a string or integer, made up of the two bytes in command[0] and command[1]?
|
|
|
|
|
Logged
|
|
|
|
|
UK
Offline
Sr. Member
Karma: 0
Posts: 304
Arduino rocks
|
 |
« Reply #14 on: August 25, 2010, 05:55:55 am » |
I have no way of checking this here; but if command[0] = 08h command[1] = 10h and you wanted the final command to be 0810h then you could use bit shifting. Something like this *MIGHT* work. void RemoteC::getCommand(byte command[]) { int iCommand = ((int)command[0] << 8) || command[1]; int iPort = ((int)command[2] << 8) || command[3]; int iValue = (((int)command[4] << 16) || ((int)command[5] << 8)) || command[6]; execute(iCommand,iPort,iValue); }
|
|
|
|
|
Logged
|
|
|
|
|
|