AIRcable Logo CompanyProductsTechnologiesSupportOEMsContact Us
BackView CartView Cart
AIRcable Industrial Programming Handbook - Part 10

Support : Industrial : AIRcable AIRmotes Programming Handbook : PART 10

PART 10: Writing Interactive Programs

Writing interactive programs is certainly a challenge because the BASIC program can block the execution of other parts in the system. For example, the INPUT functions will hold the BASIC program at that line. If an interrupt occurs (sensor alarms, PIN code requests etc) the request does not get fulfilled until the INPUT times out or finishes.

Basically it means that the programmer should keep in mind:

  • avoid using endless loops
  • use one of the schedulers to run interactive functions
  • always use TIMEOUT during input

Schedulers

There are 5 different schedulers that can be used to schedule operations.

  1. @IDLE, slave
  2. @ALARM
  3. @SENSOR, nextsns
  4. @INQUIRY, inquiry
  5. @PIO_IRQ (external trigger)

The slave function opens the Bluetooth SPP port for incoming connection for a specified time. The function itself returns immediately allowing other operations to continue while the system accepts incoming connections. After this time, the @IDLE routine will be started again. Therefore @IDLE must return before that happens. This little example shows if we want to read a command from the UART while the system is idle (or accepting incoming connections). Note: timeout expires before slave expires to restart @IDLE.

Example:

@IDLE
A = slave 10
TIMEOUTU 8
INPUTU $0
IF $0[0] <> 0 THEN sel:
RETURN

sel: IF $0[0] = 'A' THEN cmd1:
IF $0[0] = 'B' THEN cmd2:
IF $0[0] = 'C' THEN cmd3:

cmd1:
PRINTU "> "
REM real stop
INPUTU A
IF A <> 0 THEN ok:
RETURN

The alarm scheduler can be used the same way, like this.

@ALARM
ALARM 6
TIMEOUTU 5
INPUTU A
RETURN

www.aircables.net/support-ind-program-manual-pt9.html
 
company info | products | technologies | support | applications | contact us | site map
© 2005 Wireless Cables Inc. All Rights Reserved. Wireless Cables, Inc., Santa Cruz, California, U.S.A.
privacy policy | terms of use | site design by macdonald design, inc.