TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Aleksandar Ilioski
NA
345
0
Serial Port problem
Feb 25 2010 11:46 PM
i am making aplication for comunicate with electronic device via serial port..
now the problem is: on buttonClick event i want to send few messages to the device.. but second message shoud be send after the replay of the first is completly receivded.. so how could i know that the first replay is received completly?
the protocol says: the device must replay in 500 ms, so readTimeOut is set to 500 ms.., and last character must be "7", but the replay may be soo long so it takes up to few seconds..
how could i know if the replay take few MiliSeconds or few seconds... so i can send the second message?
i try this, but my application blocks
private void button2_Click(object sender, EventArgs e)
{
serialPort1.Write(Message1, 0, Message1.Length);
prodolzi = false;
while (!prodolzi)
{ }
textBox1.Text = "done!";
serialPort1.Write(Message2, 0, Message2.Length);
}
bool prodolzi;
private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
byte[] odgovor = new byte[serialPort1.BytesToRead];
serialPort1.Read(odgovor, 0, odgovor.Length);
foreach (byte b in odgovor)
{
richTextBox1.AppendText(b.ToString()+", ");
if (b.ToString() == 7.ToString())
{
prodolzi = true;
}
}
}
so can anyone please help me?
Reply
Answers (
1
)
how to sum values in a datagrid 'c column
Problem in converting c# .net project file into exe file or setup file..