Shop OBEX P1 Docs P2 Docs Learn Events
Cannot read any data from my RFID 28340 & 28440 — Parallax Forums

Cannot read any data from my RFID 28340 & 28440

Hi to all,
I'm having trouble to get my RFID code working.
I'm programming with C# and I cannot read any data from my RFID 28340 & 28440
Hereunder my code:


var serialPort = new SerialPort()
{
BaudRate = 9600,
DataBits = 8,
Parity = Parity.None,
PortName = "COM4",
StopBits = StopBits.One
};

var read = 0x01 ;
var firmware = 0x20;
var command = "!RW" + read.ToString() + firmware.ToString() + "\n";

if(!serialPort.IsOpen) serialPort.Open();

byte[] bytes = Encoding.ASCII.GetBytes(command);

serialPort.Write(bytes, 0, bytes.Length);

var data = string.Empty;
while (string.IsNullOrEmpty(data))
{
Thread.Sleep(500);
if(serialPort.BytesToRead > 1)
data = serialPort.ReadExisting();
}

Did I miss something ?
Regards,
Florian
Sign In or Register to comment.