Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
deleted 42 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

getting rfid Getting RFID tag data using C#

I am trying to get rfidan RFID tag number using winforma WinForms application. But whenever I click the Button the application stops responding. pleasePlease help regarding this.

Arduino code

void setup()
  {
  Serial.begin(9600);
  SPI.begin();
  rfid.init();
}

void loop()
  {
  if(rfid.isCard())
  {
    if(rfid.readCardSerial())
    {
        Serial.print(rfid.serNum[0], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[1], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[2], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[3], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[4], HEX);
        Serial.println("");
        delay(1000);
    }
  }
  rfid.halt();
}

C# code

 private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            serialPort1.Open();
            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
            textBox2.Text = "connected";
            serialPort1.Close();
        }
        catch(Exception ex)
        {
            textBox2.Text = "Com port disconnected";
        }
    }
     
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
         SerialPort sp = (SerialPort)sender;
         string indata = sp.ReadExisting();
         textBox1.Text = indata;
    
    }

getting rfid tag data using C#

I am trying to get rfid tag number using winform application. But whenever I click Button the application stops responding. please help regarding this.

Arduino code

void setup()
 {
Serial.begin(9600);
SPI.begin();
rfid.init();
}

void loop()
 {
if(rfid.isCard())
 {
    if(rfid.readCardSerial())
    {
        Serial.print(rfid.serNum[0], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[1], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[2], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[3], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[4], HEX);
        Serial.println("");
        delay(1000);
    }
}
rfid.halt();
}

C# code

 private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            serialPort1.Open();
            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
            textBox2.Text = "connected";
            serialPort1.Close();
        }
        catch(Exception ex)
        {
            textBox2.Text = "Com port disconnected";
        }
    }
    private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
         SerialPort sp = (SerialPort)sender;
         string indata = sp.ReadExisting();
         textBox1.Text = indata;
    
    }

Getting RFID tag data using C#

I am trying to get an RFID tag number using a WinForms application. But whenever I click the Button the application stops responding. Please help regarding this.

Arduino code

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.init();
}

void loop() {
  if(rfid.isCard()) {
    if(rfid.readCardSerial()) {
      Serial.print(rfid.serNum[0], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[1], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[2], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[3], HEX);
      Serial.print(" ");
      Serial.print(rfid.serNum[4], HEX);
      Serial.println("");
      delay(1000);
    }
  }
  rfid.halt();
}

C# code

private void button1_Click(object sender, EventArgs e) {
  try {
    serialPort1.Open();
    serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
    textBox2.Text = "connected";
    serialPort1.Close();
  }
  catch(Exception ex) {
    textBox2.Text = "Com port disconnected";
  }
}
 
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e) {
  SerialPort sp = (SerialPort)sender;
  string indata = sp.ReadExisting();
  textBox1.Text = indata;
}
Source Link
Ravi
  • 41
  • 1
  • 6

getting rfid tag data using C#

I am trying to get rfid tag number using winform application. But whenever I click Button the application stops responding. please help regarding this.

Arduino code

void setup()
{
Serial.begin(9600);
SPI.begin();
rfid.init();
}

void loop()
{
if(rfid.isCard())
{
    if(rfid.readCardSerial())
    {
        Serial.print(rfid.serNum[0], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[1], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[2], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[3], HEX);
        Serial.print(" ");
        Serial.print(rfid.serNum[4], HEX);
        Serial.println("");
        delay(1000);
    }
}
rfid.halt();
}

C# code

 private void button1_Click(object sender, EventArgs e)
    {
        try
        {
            serialPort1.Open();
            serialPort1.DataReceived += new SerialDataReceivedEventHandler(serialPort1_DataReceived);
            textBox2.Text = "connected";
            serialPort1.Close();
        }
        catch(Exception ex)
        {
            textBox2.Text = "Com port disconnected";
        }
    }
    private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
    {
         SerialPort sp = (SerialPort)sender;
         string indata = sp.ReadExisting();
         textBox1.Text = indata;
    
    }