Hello, everyone.
I'm working with a RFID reader and according to the user's manual, I can connect through a host so I decided to use an Arduino UNO.
So the manual suggests to connect with a 57600bps with one start bit, 8 data bits and 1 stop bit without a parity check bit. In the process, the least significant bit of one byte is transmited first.
The procedure is the Host (Arduino) to send a command and data to the reader, then the reader returns a result status and data to the host after command execution.
Right now, I'm sendig the next command (Picture CommandAndRespond)
So my code looks like this:
#include <AltSoftSerial.h>
#include <SoftwareSerial.h>
#define UInt16 uint16_t
SoftwareSerial antenna(8, 9);
unsigned char data;
char *s = (char *)"040021";
void setup() {
Serial.begin(9600);
antenna.begin(57600);
Serial.println("Starting");
delay(1000);
Serial.println(ModRTU_CRC(t,strlen(t)),HEX);
Serial.println(uiCrc16Cal(s,strlen(s)),HEX);
delay(1000);
sendCommand();
}
void sendCommand() {
Serial.println("Sending...");
antenna.print(0x04); //Length
antenna.print("\t");
antenna.print(0x00); //Address
antenna.print("\t");
antenna.print(0x21); //Command
antenna.print("\t");
antenna.print(0x25); //CRC-LSB
antenna.print("\t");
antenna.print(0x59); //CRC-MSB
antenna.print("\t");
delay(15);
}
void loop() {
//antenna.listen();
while(antenna.available()) {
data = antenna.read();
Serial.print(data, HEX);
Serial.print(" ");
}
}
But the respond I get are indeed, 13 bytes. But not the one I'm looking for:
FF FE FF FF FC FF FE FF FE FF FE FC FF
when I should get:
0D 00 21 00 data data data data data data data 25 53
Ideally.
So I'd like to see if someone could check the code, perhaps I missed something.
If you need more info, feel free to ask me, that includes the whole user's manual with more commands and info for the protocol
Hope you can help, thanks