Ian DD

Ian DD

  • NA
  • 10
  • 0

Serial Port problems

Sep 16 2009 7:17 AM

Hey guys,
I need help with my serial port routine. if I send any character above 0x7F it send out the serial port as 0x3F. What am I doing wrong? here's my code
 
namespace
SerialCounter
{
public partial class frmSerialCNT : Form
{
SerialPort Rs232 = new SerialPort();
public frmSerialCNT()
{
InitializeComponent();
}
private void frmSerialCNT_Load(object sender, EventArgs e)
{
Rs232.PortName =
"COM2";
Rs232.BaudRate = 9600;
Rs232.DataBits = 8;
Rs232.Parity = 0;
Rs232.Open();
}
private void btnCounter_Click(object sender, EventArgs e)
{
int i;
string str;
for (i = 0; i < 256; i++)
{
Rs232.Write(
""+Convert.ToChar(i));
}
Thread.Sleep(200);
str=Rs232.ReadExisting();
MessageBox.Show(str.Substring(100,50));
}
}
}
 
Thanks

 
 
 
 
 

Answers (1)