View Issue Details

IDProjectCategoryView StatusLast Update
0036566FPCRTLpublic2020-02-21 22:12
ReporterArmin Linder Assigned ToFlorian  
Status feedbackResolutionopen 
PlatformRaspberry Pi 3+OSRaspbian 
Product Version3.0.4 
Summary0036566: serReadTimeout hangs indefinitely if serial device is disconnected
DescriptionI use this line of code to read serial data from a serial device (/dev/ttyACM0)

  GAUGE_VALUE_LENGTH = 8; // Sign + 5 Digits + CR + LF
  MAX_BUFFER = 100;

  ByteBuffer: array[0..MAX_BUFFER] of byte;
  StringBuffer: ShortString absolute ByteBuffer;

... (loop until terminated)
    if _ComHandle <> 0 then
      // query the gauge
      StringBuffer := '?';
      SerWrite(_ComHandle, StringBuffer[1], 1);
      // read response
      // For debugging -----
      // End debugging -----
      StringBuffer[0] := chr(SerReadTimeout(_ComHandle, ByteBuffer[1], GAUGE_VALUE_LENGTH, GAUGE_RESPONSE_TIMEOUT));
      // For debugging -----
      // End debugging -----
      if Length(StringBuffer) = GAUGE_VALUE_LENGTH then

Generally this routine works well on WIndows (10) and Raspbian. Unfortunately, on Raspbian, if I disconnect the device, upon next call of this command, it does never return, nor throw any exception --> the program hangs. Re-Plugging the device doesn't help, I need to restart the program. On Windows everything works, after the timeout has expired, the call returns 0.
Steps To ReproduceCall SerReradTimeout in a loop and disconnect the device. the call won't ever return.
Additional InformationIf this info isn't enough to reproduce the problem I will happily drag together a short sample.
TagsNo tags attached.
Fixed in Revision
Attached Files



2020-02-21 22:12

administrator   ~0121187

This is hard to fix without real serial hardware, but maybe you can create yourself a fix based on: and provide it.

Issue History

Date Modified Username Field Change
2020-01-13 16:41 Armin Linder New Issue
2020-02-21 22:12 Florian Assigned To => Florian
2020-02-21 22:12 Florian Status new => feedback
2020-02-21 22:12 Florian FPCTarget => -
2020-02-21 22:12 Florian Note Added: 0121187