Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ABSPOSAO

ABSPOSAO.m

Go to the documentation of this file.
  1. ABSPOSAO ; IHS/FCS/DRS - INITIATE ; [ 09/12/2002 10:05 AM ]
  1. ;;1.0;PHARMACY POINT OF SALE;**3**;JUN 21, 2001;Build 38
  1. Q
  1. ;
  1. ; Future: extra parameter to WAITCHAR to tell it "no big deal if
  1. ; the character doesn't come in" - it looks like an error message
  1. ; when you don't get the ACK after the ENQ but then again, it's
  1. ; rare.
  1. ;
  1. ;
  1. INITIATE() ;EP - wait for the host to initiate communications
  1. ; usually, this is an ENQ
  1. ; sometimes, it may be ACK/ENQ or ENQ/ACK (Envoy 4.1 page 6)
  1. ; Returns 0 if success, error code if failure
  1. ; Error code 30101 - disconnected
  1. ; This probably means that the host system only gives us one
  1. ; transaction per phone call, and we were hoping for an ENQ to
  1. ; let us send a second transaction, but the host sent EOT instead.
  1. ; Error code 30102 - nothing received and we hung up
  1. ;
  1. D LOG("1 - Waiting for host to initiate with ENQ")
  1. N CH S CH=$$WAITCHAR^ABSPOSAM(ENQ_ACK,30)
  1. N RET,OK ; variable OK can probably be gotten rid of
  1. I CH="ENQ" D
  1. . ; the usual case is ENQ, not ENQ ACK, right? so only give 1 sec.
  1. . S CH=$$WAITCHAR^ABSPOSAM(ACK,1)
  1. . I CH="ACK" D S OK=1
  1. . . D LOG("1 - Host sent ENQ ACK to initiate")
  1. . . S RET=0
  1. . E I CH="" D S OK=1
  1. . . D LOG("1 - Host sent ENQ to initiate")
  1. . . S RET=0
  1. . ;E leave RET undef and CH = retval from WAITCHAR
  1. E I CH="ACK" D
  1. . S CH=$$WAITCHAR^ABSPOSAM(ENQ,30)
  1. . I CH="ENQ" D S OK=1
  1. . . D LOG("1 - Host sent ACK ENQ to initiate")
  1. . . S RET=0
  1. . E D ; leave RET undef and CH = retval from WAITCHAR
  1. . . D LOG("1 - Received ACK but not expected ENQ")
  1. I '$D(RET) D ; if RET not set, then something went wrong
  1. . D LOG("1 - Last WAITCHAR returned "_CH)
  1. . I CH="+++" S RET=30101 ; modem disconnected
  1. . E S RET=30102 D HANGUP ; nothing received
  1. I RET D LOG("1 - Unsuccessful attempt to initiate - "_RET)
  1. Q RET
  1. LOG(X) D LOG^ABSPOSL($T(+0)_" - "_X) Q
  1. HANGUP D HANGUP^ABSPOSAB(DIALOUT) Q