Looking for additions or improvements on my first Arduino library.

i foolishly posted this in the Bar, for some odd reason. the library works with the RDM630 125Khz reader from eBay, like THIS. the intendid use is to match the RFID tag ID from the RDM630, convert it from hex to a unsigned long, and match it against a provided list of stored numbers.

it is very quick and dirty, and i mainly wrote it because i needed it for my alarm project. if anybody has one of those readers, feel free to test the code, beat it into submission, and let me know how i could make it better.

it is located on my GitHub.

i have tested it to work, in optimum conditions. Known issues:

  • if the sketches other programming is blocking, then the serial data will lose alignment.
  • it does use the dreaded String object.

Thanks,

~Travis

travis_farmer:
Known issues:

  • if the sketches other programming is blocking, then the serial data will lose alignment.
  • it does use the dreaded String object.

both are solvable problems.

it is hungry:

unsigned long RFIDlist[100];

learn to use your constructors and consider a template class:

template <class T> class Example{
  public:
    Example(const size_t size){
      arry = new uint32_t[size];
    }
  private:
    uint32_t* arry;
    size_t numElements;
};

Example<uint32_t> example(5); // creates an [b]arry[/b] buffer of 5 elements

void setup() {
  Serial.begin(9600);
}

void loop() {
  
}

BulldogLowell:
learn to use your constructors and consider a template class:

template <class T> class Example{

public:
   Example(const size_t size){
     arry = new uint32_t[size];
   }
 private:
   uint32_t* arry;
   size_t numElements;
};

Example<uint32_t> example(5); // creates an arry buffer of 5 elements

void setup() {
 Serial.begin(9600);
}

void loop() {
 
}

What value does the template add? “T” isn’t used anywhere. Did you mean:

template <class T> class Example{
  public:
    Example(const size_t size){
      arry = new T[size];
    }
  private:
    T* arry;
    size_t numElements;
};

travis_farmer:
I have updated on my GitHub to remove the String object use, with C strings.

~Travis

 RFID_Read(const size_t size) { RFIDarry = new uint32_t[size]; } // <<<< heap allocation
~RFID_Read() {}

The destructor will be created by default; you could (should) call delete on the objects created (on the heap) using new.

Though it isn’t critical if you never plan on using this with objects created at run time, it at least shows you knew what’s what if/when you go to look at it again.