I have a project but it is in Windows Form and I am a beginner in that environment. I have the following code to try to read data from an RFID proximity card reader and show the ID of said card in a textbox
, the reader is connected by USB, I would like to know if someone can help me.
namespace WindowsFormsApp1
{
public partial class Form1 : Form
{
private SerialPort RFID;
public Form1()
{
InitializeComponent();
SerialPort serialPort = new SerialPort();
RFID = serialPort;
RFID.PortName = "COM1";
RFID.BaudRate = 9600;
RFID.DataBits = 8;
RFID.Parity = Parity.None;
RFID.StopBits = StopBits.One;
RFID.Open();
RFID.DataReceived += new SerialDataReceivedEventHandler(RFID_DataReceived);
prueba();
}
private void prueba()
{
textBox2.Text = "test";
}
private void RFID_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
MessageBox.Show("Inica Componentes");
string data = RFID.ReadExisting();
textBox2 .Text = "77777";
}
}
}
look at this portion of code, I use it to connect and obtain data from a scale through the serial port, I hope it helps guide you to the right side.
Give it a review and adapt it to your needs, this code works for me.
Luck.