Diese Seite mit anderen teilen ...

Informationen zum Thema:
WinDev Forum
Beiträge im Thema:
Erster Beitrag:
vor 7 Jahren, 8 Monaten
Letzter Beitrag:
vor 7 Jahren, 8 Monaten
Beteiligte Autoren:
Arie, Manfred, Erik Schwarz

serial port question

Startbeitrag von Arie am 23.11.2010 20:52

I have to communicate with a serial device (pinterminal). After sending some information, the application must wait for an ACK (or NAK). There's also a timeout I have to deal with.

So what is the best way to "wait" for an ACK from a serial device?

Using sInEntryQueue(), in a loop, to see if there is a character?

I could also use sEvent() and save received data in a global var.
And use a loop (together with multitask) to check this variable at a regular base, say every 100ms or so.

Maybe threads and signals?


Arie, U need see the ascii for the ACK and do a bucle with the question of that.


von Manfred - am 23.11.2010 21:09
I know the codes for the ACK (hex6) and NAK (hex15). That's no problem.
I just need a way to wait for ACK/NAK, being able to react on it directly. But stop if it takes too long.

von Arie - am 23.11.2010 21:20
Hi Arie,

I set up a timer and within the timer procedure I am doing the receiving of the serial port.
Having a global variable 'timeout' as integer.

In the send routine I am doing something like this:

-build sendstring
-sending the string
-clr receivebuffer
-set timeout = 0

In the receive routine (called periodically by the timer):

-read the receive buffer
-if characters available do whatever must be done
-if timeout > x (depends on how often your timer is called) do timeout condition.

I use this since 10 years with no problems.

Hope that helps


von Erik Schwarz - am 24.11.2010 08:31
Arie. Mines only suggestion to collaborate, sometimes the solutions dont come but with conversations arrives..



von Manfred - am 24.11.2010 12:32
Zur Information:
MySnip.de hat keinen Einfluss auf die Inhalte der Beiträge. Bitte kontaktieren Sie den Administrator des Forums bei Problemen oder Löschforderungen über die Kontaktseite.
Falls die Kontaktaufnahme mit dem Administrator des Forums fehlschlägt, kontaktieren Sie uns bitte über die in unserem Impressum angegebenen Daten.