Re: Async Pro for serial communications




"Godfrey" <none> wrote
I poll the pumps and depending on what pump I am addressing
in the loop, that pump responds. The pump will only respond
if it is addressed otherwise it just stays idle.

For either point-to-point or multi-drop, I would
prefer to use event driven reception of the chars
and with timeouts to detect lost packets.

I am looking for more detailed examples using triggers and
timeouts, do you have any?

Here is a sophisticated example:
_Inside-out programming for serial ports_
http://cc.codegear.com/Item/23954

Here below is the beginning of a simple example with a ComPort1
and a Timer1.

HTH, JohnH

Timer1 is not Enabled.
Define port state type maybe like this:
Type tPortState =
(psIdle, psXmitting, psWaitingResp, psReceiving);

procedure SetupAndStartTransmittingRequest:
If State <> psIdle then raise Error.
ClearReceiverBuffer;
Prep request string.
Set State to psXmitting; Start timer to wait for response in 200 milliseconds.
StartComportTransmission;
Exit;
end;

procedure Timer1.Timer();
Timer1.Enabled := false;
Case State of
psIdle: {nothing};
psXmitting: Log transmiting timeout;
psWaitingResp: Log no reception;
psReceiving:Log receiving timeout;
end;
end;

procedure Comport1.OnTransmitBufEmpty;
Set State to psWaitingResp; Start timer to wait for response in 300 milliseconds
end;

procedure Comport1.OnReceivedChars
For each received char:
Case State of
psXmitting, psWaitingResp:
If char signals beginning of message from pump
then State := psReceiving;
Set received buffer to first char.
psReceiving:
If char signals end of message from pump
then begin
Timer1.Enabled := false;
State := psIdle;
Process received message.
end
else accumulate char to received buffer.
end;
end;

.



Relevant Pages

  • Re: CAsyncSocket and Send
    ... The sending side sends an 'f' char immediately before a file is sent. ... > Are you using TCP/IP or UDP? ... > Are you making sure that, if you are handling strings, that you insert a terminating NUL ... >>in C and the receiving side is MFC. ...
    (microsoft.public.vc.mfc)
  • Re: typecasting
    ... there are n number of options in buffer type char* ... have created a char array of pointers to point to all these n ... struct authProt auth; ... Adjust for the endianness of the incoming data (you do not need to worry about the endianness of the receiving machine doing it this way). ...
    (comp.lang.c)
  • Re: Clarification required about select vs wake_up race condition
    ... Our char driverdoes a ... In our poll(), ... it looks like it can set the state of the receiving ... any) or just getting back (iow, the task doesn't lose a cpu). ...
    (Linux-Kernel)
  • Ebay/PayPal - Do we need legislation against this monster!
    ... In late May my injection pump packed up in Italy. ... I contacted the vendor who told me he had not seen the pump but had ... forwarded it on receiving it! ... claiming that I dad bought the pump 'OFF' Ebay and as long as the item ...
    (uk.people.consumers.ebay)
  • Re: Read/Write socket Problem
    ... > receiving at the byte level. ... I am always writing 3 bytes from client, reading 3 bytes from server, ... char givenNo; ...
    (comp.unix.programmer)