Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
06/19/02 06:02
Read: times


 
#24594 - ClearCommError() Help says: \
Please check the code part below (From CPort.pas)

procedure TComThread.Execute;
  repeat
    // wait for event to occur on serial port
    WaitCommEvent(FComPort.Handle, Mask, @Overlapped);
    Signaled := WaitForMultipleObjects(2, @EventHandles, False, INFINITE);
    // if event occurs, dispatch it
    if (Signaled = WAIT_OBJECT_0 + 1)
      and GetOverlappedResult(FComPort.Handle, Overlapped, BytesTrans, False)
    then
    begin
      FEvents := IntToEvents(Mask);
      DispatchComMsg;
<hr>

procedure TComThread.DispatchComMsg;
begin
  case FComPort.SyncMethod of
    smThreadSync: Synchronize(DoEvents); // call events in main thread
    smWindowSync: SendEvents; // call events in thread that opened the port
    smNone:       DoEvents; // call events inside monitoring thread
  end;
end;
<hr>

procedure TComThread.DoEvents;
begin

  if evError in FEvents then
    FComPort.CallError;

end;
<hr>


procedure TCustomComPort.CallError;
begin
  DoError(LastErrors);
end;
<hr>

function TCustomComPort.LastErrors: TComErrors;
  if not ClearCommError(FHandle, Errors, @ComStat) then
    raise EComPort.Create(CError_ClearComFailed, GetLastError);
  Result := [];
  if ((CE_RXPARITY and Errors) <> 0) and FParity.Check then // get around a bug
    Result := Result + [ceRxParity];


</p>
<p>
<p>
From the Borland Help on ClearCommError:

The ClearCommError function retrieves information about a communications error and reports the current status of a communications device. The function is called when a communications error occurs, and it clears the device's error flag to enable additional input and output (I/O) operations.

If a communications port has been set up with a TRUE value for the fAbortOnError member of the setup DCB structure, the communications software will terminate all read and write operations on the communications port when a communications error occurs. No new read or write operations will be accepted until the application acknowledges the communications error by calling the ClearCommError function.

<hr>
Based on these, you should receive the error for the last byte you're sending/receiving. But when I searched the CPort.pas for AbortOnError, I could not find that Dejan had used it.

<hr>
I would try to use it on TCustomComPort.ApplyDCB() procedure, and if it would not help I would try to ask to Dejan.

I think above code parts or Dejan can help you.

List of 26 messages in thread
TopicAuthorDate
Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: easy            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: i'll give it a try            01/01/70 00:00      
RE: Mode 2/3: Multiprocessor Serial (again)            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
RE: Mode 2/3 - Erik            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not easy?            01/01/70 00:00      
RE: not not easy?            01/01/70 00:00      
ClearCommError() Help says: \            01/01/70 00:00      
RE: Buffer->InputSize            01/01/70 00:00      
RE: ClearCommError() Help says:            01/01/70 00:00      
RE: ClearCommError() Help says:            01/01/70 00:00      

Back to Subject List