Silverfrost Forums

Welcome to our forums

%dl to avoid program hanging?

27 Jul 2012 2:04 #10520

G'day, folks 😄

The program I'm developing interacts with a set of thermocouples via the serial port. Different subroutine calls are used to open the port, to collect data through it, and to close the port. However, if any of these calls fails to complete (for example, thermocouples are not connected) then the program 'hangs', requiring intervention by the Task Manager. This can be highly frustrating for an operator, particularly if they've just searched the entire building looking for the Task Manager's office.

I'm wondering if the delay function %dl ...

ia=winio@('%dl', interval, cb_func)

... can be used to avoid operator agitation by limiting the time allowed for the call to complete. The call would be contained within the call-back function cb_func (see above code). The code as written above would produce repeated calls to cb_func. The trick will be to make just one call to cb_func. Perhaps if cb_func has a return value of zero?

Eric

27 Jul 2012 4:04 #10521

Eric,

Are you using FTN95 routines such as OPENCOMMDEVICE@ ? Surely this returns an error code if it can't connect and you don't need to wait. If you get the return code of 1, pop up a window with a message of the 'retry or cancel' variety.

How are you communicating with the serial port ? My last few compters haven't had RS232!

Regards

Eddie

28 Jul 2012 2:57 #10523

Thanks for the suggestion, Eddie 😄

I wish I could use something like OPENCOMMDEVICE@. Unfortunately the only thing I have available is a compiled (C++ language) proprietary function tc08_open_unit(port) that drives the 'black box' into which the thermocouples are connected. Sadly, the days are long-gone when this Perth university built all its electronic equipment and wrote its own drivers.

So my only recourse was to first make the C++ tc08_open_unit(port) Fortran-callable and then repeatedly test the return value until it was non-zero, thus -

100   ok = open_TC08(port)
      if(ok .eq. 0) goto 100

Quite a journey from the days of Z80, with its baud rate, stop bits, parity, etc. Back in those days the latest computers had 3.5 inch floppy drives! 😄

Eric

28 Jul 2012 4:49 #10524

Eric,

If you have to use your routine, it still gives a success/fail message, so how about:

  100 KOUNTER = 0
  110 ok = open_TC08(port)
      IF (ok .ne. 0) GO TO 120
      KOUNTER = KOUNTER + 1 
      if (ok .eq. 0 .AND. KOUNTER .LE 10000) goto 100
      IA=WINIO@ ('%ca[No response from thermocouples]&')
      IA=WINIO@ ('%nl%si!There is no response from the thermocouple '//
     &           'black box&')
      IA=WINIO@ ('%2nl%rj%12bt[Keep trying] %12bt[Give up]')
      if (IA .EQ. 1) GO TO 100

C     ... this is where you get to if the user gives up
.
.
.
  120 CONTINUE ! this is where you get to if the port opens

Instead of counting the number of tries (10,000 was my guess, but it could be more - or fewer) you could allow a certain length of time using one of the timer routines and offer the choice of giving up after (say) 10 seconds.

If starting the black box normally takes some measurable time, there are more user friendly ways of doing it and keeping the user informed of what is happening.

You can probably code it without the ugly GO TOs - not that I mind a few, but this isn't nice ...

Eddie

Please login to reply.