Problem with loop in VB.NET

  • Thread starter Thread starter David
  • Start date Start date
D

David

I am wanting to step through a series of commands to send via the serial
port
to a target device. The program sets a 100mS ReplyTimer. The timer routine
sets the ProcessedRX upon timeout. If data arrives, the timer is reset for
another
50mS. This continues until there are no more characters within 50ms .

The problem is that the program locks in the Do Loop and ReplyTimer never
times out.

Code shown below...

Serial.Write(TXBuf, 0, 4) 'send packet
ReplyTimer.Enabled = True
ProcessedRX = False
Do
DoEvents:
Loop Until ProcessedRX

Any help much appreciated. Or a better way to doing this. The system is to
be used to run a test on a radio
by pinging the radio several times for information and dsiplaying the
information in response to each "ping"
If a ping is not replied to, the listview is to display "No Response" for
that ping.

Regards

David
 
David said:
I am wanting to step through a series of commands to send via the serial
port
to a target device. The program sets a 100mS ReplyTimer. The timer routine
sets the ProcessedRX upon timeout. If data arrives, the timer is reset for
another
50mS. This continues until there are no more characters within 50ms .

The problem is that the program locks in the Do Loop and ReplyTimer never
times out.

Code shown below...

Serial.Write(TXBuf, 0, 4) 'send packet
ReplyTimer.Enabled = True
ProcessedRX = False
Do
DoEvents:
Loop Until ProcessedRX

Try removing the colon after the DoEvents. The colon is forcing VB to interpret the DoEvents as a line label. DoEvents() is in the
System.Windows.Forms.Application namespace.

This may or may not solve the problem.
 
David said:
I am wanting to step through a series of commands to send via the serial
port
to a target device. The program sets a 100mS ReplyTimer. The timer routine
sets the ProcessedRX upon timeout. If data arrives, the timer is reset for
another
50mS. This continues until there are no more characters within 50ms .

The problem is that the program locks in the Do Loop and ReplyTimer never
times out.

Code shown below...

Serial.Write(TXBuf, 0, 4) 'send packet
ReplyTimer.Enabled = True
ProcessedRX = False
Do
DoEvents:

Replace the line above with 'Application.DoEvents'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top