Go Down

Topic: ~./P_rfid.cpp:19: error: ‘P_rfid’ has not been declared (Read 913 times) previous topic - next topic

amsit

I am a complete novice  on library creation and I get the errors below when trying to compile a  sketch.

Quote

/home/andrew/arduino-0022/libraries/P_rfid/P_rfid.cpp:19: error: 'P_rfid' has not been declared
/home/andrew/arduino-0022/libraries/P_rfid/P_rfid.cpp:19: error: expected constructor, destructor, or type conversion before '(' token


the attached files are the  library files.
brlow is the  test sketch
Quote

#include <AF_XPort.h>
#include <string.h>
#include <avr/io.h>
#include <NewSoftSerial.h>
#include <P_rfid.h>



#define rxPin 8
#define txPin 9
#define enabl  11
// RFID reader SOUT pin connected to Serial RX pin at 2400bps to pin8
P_rfid RFID = P_rfid(rxPin,txPin, enabl);
char code[11];

void setup()
{
  Serial.begin(57600);  // Hardware serial for Monitor 2400bps
 

  RFID.begin(2400);
}


void loop()
{

int avail = 100;
  if(RFID.available(avail)>0){
    RFID.readcode(code);
 
  }
}


PaulS

#1
Jul 08, 2011, 07:51 am Last Edit: Jul 08, 2011, 07:58 am by PaulS Reason: 1
Typically, the source code needs to include the header file. Yours doesn't. Without it, the compiler has no idea that P_rfid is a class, or that P_rfid::P_rfid() is a constructor.

Why does the begin() method take an argument that is not used?

The available() method should return the number of bytes available, not true or false. The timeout function will not do what it appears that you think it will, unless you plan on calling it with a very, very large number.

What kind of type is unit_8? I've heard of uint_8 (unsigned int, 8 bits), but not unit_8 or unit_16.
The art of getting good answers lies in asking good questions.

amsit

Thanks PaulS

I did discover that I needed to include the header in my .cpp file and that resolved the error.

Quote

What kind of type is unit_8? I've heard of uint_8 (unsigned int, 8 bits), but not unit_8 or unit_16.

my typo - I have changed these to just straight int

Quote

Why does the begin() method take an argument that is not used?


I was basing it on the root function in NewSoftSerial but could just as easily scrap that

Quote
The available() method should return the number of bytes available, not true or false. The timeout function will not do what it appears that you think it will, unless you plan on calling it with a very, very large number.


Once again based on a code snippet - I will clean this up a bit , I do have the library working now and will try to clean things up based on your observations. 








Go Up