Advertisement
Guest User

Untitled

a guest
Mar 20th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO.Ports;
  11.  
  12. namespace RFID_Transfer_Final
  13. {
  14.     public partial class Form1 : Form
  15.     {
  16.         SerialPort myport;
  17.         string data_rx;
  18.  
  19.         public Form1()
  20.         {
  21.             InitializeComponent();
  22.         }
  23.  
  24.         private void RetrieveInfo_Click(object sender, EventArgs e)
  25.         {
  26.             myport = new SerialPort();
  27.             myport.BaudRate = 9600;
  28.             myport.PortName = "COM9";
  29.  
  30.            
  31.             myport.Open();
  32.             myport.DiscardInBuffer();
  33.             myport.DiscardOutBuffer();
  34.  
  35.             data_rx = myport.ReadLine();
  36.  
  37.             myport.Close();
  38.        
  39.             if (data_rx.Length == 9)
  40.             {
  41.                 infoBox.Items.Add(data_rx);
  42.             }
  43.  
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement