Interrupts help

Hey,

I have adapted two working codes into one, to use with interrupts. The thing trigger the interrupt is a button and that is working... It just seems to not be long enough? or doesn't read the RFID card? If you have any input or advise it would be great.

The RFID module is from seeeduino http://www.seeedstudio.com/wiki/125Khz_RFID_module_-_UART

#include <SoftwareSerial.h>
SoftwareSerial RFID = SoftwareSerial(4, 12);
int state = LOW;
unsigned long ID;

void setup()
{
  Serial.begin(9600);
  RFID.begin(9600);
  attachInterrupt(0, readID, RISING);
  //attachInterrupt(0, stateChange, CHANGE);
  //pinMode(13,OUTPUT);
  Serial.println("Hello");
}



void loop()
{
  Serial.println("I am here");
  delay(1000);
  
}

/*
void stateChange()
{
  state = !state;
  digitalWrite(13, state);
}
*/


void readID()
{
  Serial.println("are we here?\n\n");
  
  static byte data[4];
  static byte temp[14]; 
  byte len;
  static int i = 0;
  unsigned long currentId;
  if(RFID.available()){
      temp[i++] = RFID.read();
      Serial.println("HERE?");
      if(14 == i){
        if( 0x02 == temp[0] && 0x03 == temp[13]){
          data[0] = Transform(temp[3])*16 + Transform(temp[4]); 
          data[1] = Transform(temp[5])*16 + Transform(temp[6]);
          data[2] = Transform(temp[7])*16 + Transform(temp[8]);
          data[3] = Transform(temp[9])*16 + Transform(temp[10]);
          currentId = (unsigned long)data[0]*16777216 + (unsigned long)data[1]*65536 + (unsigned long)data[2]*256 + (unsigned long)data[3];
          Serial.print("CurrentID:");
          Serial.println(currentId,DEC);
          
          i = 0;
        }
      }
  }
}

byte Transform(byte dat)
{
  if(dat >= 0x30 && dat <= 0x39)
  {
    return (dat - 0x30);
  }else if(dat >= 0x41 && dat <= 0x46)
  {
    return (dat - 55);
  }
}

You shouldn't be doing any form of serial I/O in your interrupt.

It won't work if you do?

You're expecting a stream of characters from the reader.
At 9600 baud, these will arrive just over 1 millisecond apart, but your interrupt service only checks to see if the first as arrived.
Printing serial characters is interrupt driven in IDE 1.0 and above, so that won't work either.

Why do you think you need an interrupt?
At these sorts of speeds, polling should work fine.

Fair enough, its going into a bigger project I'm making...

and I probably could use polling, but I learnt about interrupts at uni.. so thought I might give them a try

Interrupts are intended to be used where events must be noticed and acted upon very quickly, or the information represented by the event will be lost.
Here (I assume) you've got some event to indicate that RFID data is (or is about to be) available.
However, the rate at which the data arrives (one character per millisecond) is very slow in comparison to the speed of the processor, and anyway, character reception is already handled and buffered by an interrupt-driven process,
The only time I can really see interrupts being of benefit here is if the signal that indicates RFID data availability is shorter than some process going on (say an SD buffer write) so polling might miss it, in which case, your interrupt service routine would simply set a flag (declared volatile) that the background process would read later, when the lengthy process was complete.

Don't forget that Serial I/O relies on interrupts being enabled, which is not the case during an ISR.