Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO.Ports;
- namespace RFID_Transfer_Final
- {
- public partial class Form1 : Form
- {
- SerialPort myport;
- string data_rx;
- bool start = false;
- Timer t = new Timer();
- public Form1()
- {
- InitializeComponent();
- }
- private void Form1_Load(object sender, EventArgs e)
- {
- t.Interval = 1000;
- t.Tick += new EventHandler(timer1_Tick);
- }
- private void timer1_Tick(object sender, EventArgs e)
- {
- while (start == true)
- {
- myport = new SerialPort();
- myport.BaudRate = 9600;
- myport.PortName = "COM9";
- myport.Open();
- myport.DiscardInBuffer();
- myport.DiscardOutBuffer();
- data_rx = myport.ReadLine();
- myport.Close();
- if (data_rx.Length == 9)
- {
- infoBox.Items.Add(data_rx);
- }
- }
- }
- private void RetrieveInfo_Click(object sender, EventArgs e)
- {
- if (start == true)
- {
- RetrieveInfo.Text = "Start";
- t.Start();
- start = false;
- }
- else
- {
- RetrieveInfo.Text = "Stop";
- t.Stop();
- start = true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement