I'm new to this device,
I only tried RFID Mifare RC522 and read its serial ID
This time I'm trying to read the serial ID of RFID card using this Smart Card Encoder (LA118-M1) using C# coding in MS Visual Studio.
What class library should I download.
I tried using this code:
SerialPort _serialPort = new SerialPort("COM2");
_serialPort.Open();
bool _check = _serialPort.IsOpen;
string _string = _serialPort.ReadLine();
_serialPort.Close();
Result: Nothing happens
You are not listening serial port. On your initializing code, open COM port and listen to it (Add DataReceived
delegate). It would be something like this:
public void Open()
{
_serialPort = new SerialPort("COM2");
_serialPort.Open();
_serialPort.DataReceived +=port_DataReceived;
}
void port_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
string line = ((SerialPort)sender).ReadLine();
}
// Close serial port somewhere