EDN Admin
Well-known member
hi there,
i am trying to write a simple program from scratch trying to get data sent between COMM ports 1 and 2 and displayed in a text box
<pre class="prettyprint 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 Application2
{
public partial class Form1 : Form
{
private SerialPort port1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
private SerialPort port2 = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
port2.Open();
port2.DataReceived += new SerialDataReceivedEventHandler(SerialReceive);
}
public void SerialReceive(object sender, SerialDataReceivedEventArgs e)
{
textBox1.Text = (port2.ReadTo("!%"));
}
private void button1_Click(object sender, EventArgs e)
{
port1.Open();
port1.WriteLine("12345");
port1.Close();
}
}
}
[/code]
i need to be able to compile before i can proceed and make other changes.<br/>
View the full article
i am trying to write a simple program from scratch trying to get data sent between COMM ports 1 and 2 and displayed in a text box
<pre class="prettyprint 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 Application2
{
public partial class Form1 : Form
{
private SerialPort port1 = new SerialPort("COM1", 9600, Parity.None, 8, StopBits.One);
private SerialPort port2 = new SerialPort("COM2", 9600, Parity.None, 8, StopBits.One);
public Form1()
{
InitializeComponent();
port2.Open();
port2.DataReceived += new SerialDataReceivedEventHandler(SerialReceive);
}
public void SerialReceive(object sender, SerialDataReceivedEventArgs e)
{
textBox1.Text = (port2.ReadTo("!%"));
}
private void button1_Click(object sender, EventArgs e)
{
port1.Open();
port1.WriteLine("12345");
port1.Close();
}
}
}
[/code]
i need to be able to compile before i can proceed and make other changes.<br/>
View the full article