I really appreciate all the help this community has given me so far. With that said, here is my current problem.
I have an RFID reader hooked up to serial port (USB), and serial port 1. Using SerialPassthrough, I am attempting to send all the incoming data from the 2 RFID readers through the serial(USB). I then want the incoming data to be labelled with reader it came from. I concatenated a title to each array to allow me to do that. Once I did that, everything stopped working. No error codes, no flashing lights, nothing. Here is my code:
int RFIDResetPin = 13;
////////////////////////////////////////////////////////////////////
//this uses the serial passthrough method, that sends data read by the serial1, 2 and 3 ports, sends them throught a TTL to the Serial0 port to be read by the computer
// read more about this method at [url=http://www.arduino.cc/en/Tutorial/SerialPassthrough][color=#1155cc]www.arduino.cc/en/Tutorial/SerialPassthrough[/color][/url]
//////////////////////////////////////////////////////////////////
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
pinMode(RFIDResetPin, OUTPUT);
digitalWrite(RFIDResetPin, HIGH);
}
void loop()
{
char tagString0[13];
int index = 0;
boolean reading = false;
if(Serial.available())
{
int readByte0 = Serial.read(); //read next available byte
if(readByte0 == 2) reading = true; //beginning of tag
if(readByte0 == 3) reading = false; //end of tag
if(reading && readByte0 != 2 && readByte0 != 10 && readByte0 != 13){
//store the tag
tagString0[index] = readByte0;
Serial.println(String("reader1: ") + tagString0); //read out any unknown tag
index ++;
}
}
clearTag(tagString0); //Clear the char of all value
resetReader(); //reset the RFID reader
char tagString1[13];
if(Serial1.available()){
int readByte1 = Serial1.read(); //read next available byte
if(readByte1 == 2) reading = true; //begining of tag
if(readByte1 == 3) reading = false; //end of tag
if(reading && readByte1 != 2 && readByte1 != 10 && readByte1 != 13){
//store the tag
tagString1[index] = readByte1;
Serial.write("Reader2: " + Serial1.read());
index ++;
}
}
clearTag(tagString1); //Clear the char of all value
resetReader(); //eset the RFID reader
}
void resetReader(){
///////////////////////////////////
//Reset the RFID reader to read again.
///////////////////////////////////
digitalWrite(RFIDResetPin, LOW);
digitalWrite(RFIDResetPin, HIGH);
}
void clearTag(char one[]){
///////////////////////////////////
//clear the char array by filling with null – ASCII 0
//Will think same tag has been read otherwise
///////////////////////////////////
for(int i = 0; i < strlen(one); i++){ one[i] = 0; } } boolean compareTag(char one[], char two[]){
///////////////////////////////////
//compare two value to see if same,
//strcmp not working 100% so we do this
///////////////////////////////////
if(strlen(one) == 0) return false;
//empty for(int i = 0; i < 12; i++){ if(one[i] != two[i]) return false; } return true;
//no mismatches
}
thanks again everyone.