I save all 12 value in the uint8_t singleTagEPCBytes[12]
singleTagEPCBytes [p] = ((uint8_t) nano.msg[31 + p]);
if((p == tagEPCByteCount) && (counter > 0)) {
find (singleTagEPCBytes, tagEPCBytes); }
nano.msg is a buffer. It is defined as: uint8_t msg[MAX_MSG_SIZE]. I try to find singleTagEPCBytes in the array tagEPCBytes with the following function.
int find(uint8_t *x[], uint8_t *y[][12])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 12; j++) {
if (x[j] != y[i][j]) break;
if ( j == 11) {
Serial.print("exists in row %d\n", i);
return 0;
}
}
}
Serial.print("does not exists\n");
return 1;
}
But I get the following error message
cannot convert 'uint8_t* {aka unsigned char*}' to 'uint8_t** {aka unsigned char**}' for argument '1' to 'int find(uint8_t**, uint8_t* (*)[12])'
find (singleTagEPCBytes, tagEPCBytes); }
I tried this function successfully here GDB online Debugger | Code, Compile, Run, Debug online C, C++
I thought that with singleTagEPCBytes[p] = ((uint8_t) nano.msg[31 + p]); I saved the values from nano.msg as uint8_t.
- Who can explain why the find function does not work.
- What would be the best way to add a row in tagEPCBytes if singleTagEPCBytes was not found.
Another error I get is this
call of overloaded 'print(const char [18], int&)' is ambiguous
Serial.print("exists in row %d\n", i);
- Why is overloaded 'print(const char [18], int&)' ambiguous
Enclosed the full code
#include <SoftwareSerial.h>
#include <stddef.h>
SoftwareSerial softSerial(2, 3);
#include "SparkFun_UHF_RFID_Reader.h"
RFID nano;
#define BUZZER1 10
#define BUZZER2 9
boolean tagDetected;
long lastSeen = 0;
int counter = 0;
void setup()
{
Serial.begin(115200);
pinMode(BUZZER1, OUTPUT);
pinMode(BUZZER2, OUTPUT);
digitalWrite(BUZZER2, LOW);
while (!Serial);
if (setupNano(38400) == false)
{
Serial.println(F("Das Modul hat nicht reagiert. Bitte überprüfen Sie die Anschlüsse."));
while (1);
}
nano.setRegion(REGION_NORTHAMERICA);
nano.setReadPower(2700);
nano.startReading();
Serial.println("Scannprozess läuft!");
lowBeep();
tagDetected = false;
}
void loop()
{
byte myEPC[12];
byte myEPClength;
byte responseType = 0;
uint8_t tagEPCBytes[50][12] = {};
uint8_t singleTagEPCBytes[12] = {};
if (nano.check() == true)
{
byte responseType = nano.parseResponse();
if (responseType == RESPONSE_IS_TAGFOUND)
{
long timeStamp = nano.getTagTimestamp();
byte tagEPCByteCount = nano.getTagEPCBytes();
Serial.print(F("RFID-Tag detektiert: "));
Serial.println(counter);
Serial.print(F("Bin-Daten["));
for (byte p = 0 ; p < tagEPCByteCount ; p++)
{
tagEPCBytes[counter][p] = ((uint8_t) nano.msg[31 + p]);
singleTagEPCBytes [p] = ((uint8_t) nano.msg[31 + p]);
if(p == tagEPCByteCount) {
find (singleTagEPCBytes, tagEPCBytes); }
Serial.print(nano.msg[31 + p]);
if (p != 11) Serial.print(F(" "));
}
Serial.println(F("] "));
if (tagDetected == false)
{
tagDetected = true;
}
else if (millis() - lastSeen > 250)
{
}
lastSeen = millis();
counter++;
}
}
if (tagDetected == true && (millis() - lastSeen) > 1000)
{
Serial.println(F("Kein RFID-Tag gefunden..."));
tagDetected = false;
}
if (Serial.available())
{
nano.stopReading();
Serial.read();
delay(1000);
Serial.println("Array Ausgabe:\n");
delay(333);
int i, j;
for (i = 0; i < 50; i++) {
for (j = 0; j < 12; j++) {
Serial.print(tagEPCBytes[i][j]);
Serial.print(" ");
if (j == 11) {
Serial.println(" ");
}
}
}
delay(333);
Serial.println("Scannen angehalten. Drücken Sie die Taste, um fortzufahren.");
while (!Serial.available());
Serial.read();
nano.startReading();
}
}
boolean setupNano(long baudRate)
{
nano.begin(softSerial);
softSerial.begin(baudRate);
while (!softSerial);
while (softSerial.available()) softSerial.read();
nano.getVersion();
if (nano.msg[0] == ERROR_WRONG_OPCODE_RESPONSE)
{
nano.stopReading();
Serial.println(F("Modul liest kontinuierlich. Modul soll kontinuierlich lesen beenden...."));
delay(1500);
}
else
{
softSerial.begin(115200);
nano.setBaud(baudRate);
softSerial.begin(baudRate);
}
nano.getVersion();
if (nano.msg[0] != ALL_GOOD) return (false);
nano.setTagProtocol();
nano.setAntennaPort();
return (true);
}
void lowBeep()
{
tone(BUZZER1, 130, 150);
}
void highBeep()
{
tone(BUZZER1, 2093, 150);
}
int find(uint8_t *x[], uint8_t *y[][12])
{
int i, j;
for (i = 0; i < 3; i++) {
for (j = 0; j < 12; j++) {
if (x[j] != y[i][j]) break;
if ( j == 11) {
Serial.print("exists in row %d\n", i);
return 0;
}
}
}
Serial.print("does not exists\n");
return 1;
}