-
January 3rd, 2012, 05:48 PM
#1
Read from rs232??
Please help me with this code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO.Ports;
namespace Terminal
{
public partial class MainForm : Form
{
byte[] Receive_Buffer;
int a;
public MainForm()
{
InitializeComponent();
}
private void MainForm_Load(object sender, EventArgs e)
{
serialPort1.Open();
serialPort1.DataReceived += new System.IO.Ports.SerialDataReceivedEventHandler(this.serialPort1_DataReceived);
text1.Text = System.Text.ASCIIEncoding.ASCII.GetString(Receive_Buffer);
}
private void serialPort1_DataReceived (object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
{
a=serialPort1.Read(Receive_Buffer, 0, 1);
}
private void but_r_file_Click(object sender, EventArgs e)
{
}
private void but_s_file_Click(object sender, EventArgs e)
{
}
/// ////////////
private void button1_Click(object sender, EventArgs e)
{
serialPort1.Write(text2.Text);
text1.Text = text1.Text + Environment.NewLine + text2.Text;
}
private void but_ers_Click(object sender, EventArgs e)
{
text1.Text = "";
}
}
}
///////////////////////////
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|