home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / AUTODOWN.MOD < prev    next >
Text File  |  1988-03-18  |  7KB  |  145 lines

  1. (*----------------------------------------------------------------------*)
  2. (*         Handle_Zmodem_Autodownload --- Handle Zmodem autodownload    *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. FUNCTION Handle_Zmodem_Autodownload : BOOLEAN;
  6.  
  7. (*----------------------------------------------------------------------*)
  8. (*                                                                      *)
  9. (*     Procedure:  Handle_Zmodem_Autodownload;                          *)
  10. (*                                                                      *)
  11. (*     Purpose:    Handles Zmodem autodownload.                         *)
  12. (*                                                                      *)
  13. (*     Calling Sequence:                                                *)
  14. (*                                                                      *)
  15. (*        Found_Zmodem := Handle_Zmodem_Autodownload;                   *)
  16. (*                                                                      *)
  17. (*           Found_Zmodem --- TRUE if Zmodem packet found and           *)
  18. (*                            Zmodem transfer executed.                 *)
  19. (*                                                                      *)
  20. (*     Remarks:                                                         *)
  21. (*                                                                      *)
  22. (*        This routine should be called when Zmodem autodownload        *)
  23. (*        mode is in effect and the terminal emulation has received     *)
  24. (*        a "CAN" character.                                            *)
  25. (*                                                                      *)
  26. (*     Calls:                                                           *)
  27. (*                                                                      *)
  28. (*        Async_Peek                                                    *)
  29. (*        PibDownLoad                                                   *)
  30. (*                                                                      *)
  31. (*----------------------------------------------------------------------*)
  32.  
  33. VAR
  34.    TT  : Transfer_Type;
  35.    Ch1 : CHAR;
  36.    Ch2 : CHAR;
  37.    Ch3 : CHAR;
  38.  
  39. BEGIN (* Handle_Zmodem_Autodownload *)
  40.  
  41.                                    (* Pick up transfer type for Zmodem *)
  42.    TT := Get_Zmodem_Type;
  43.                                    (* If none defined, return to caller. *)
  44.    IF ( TT <> None ) THEN
  45.                                    (* If Zmodem type defined, then *)
  46.                                    (* peek ahead for 'B00' marking *)
  47.                                    (* ZRQINIT packet.              *)
  48.       BEGIN
  49.                                    (* Make sure rest of packet arrives  *)
  50.  
  51.          DELAY( One_Second_Delay );
  52.  
  53.                                    (* Peek ahead and pick up the next   *)
  54.                                    (* three characters after the CAN.   *)
  55.          Ch1 := Async_Peek( 0 );
  56.          Ch2 := Async_Peek( 1 );
  57.          Ch3 := Async_Peek( 2 );
  58.  
  59.          IF ( ( Ch1 = 'B' ) AND
  60.               ( Ch2 = '0' ) AND
  61.               ( Ch3 = '0' ) ) THEN
  62.             BEGIN
  63.                Handle_Zmodem_Autodownload := TRUE;
  64.                PibDownload( TT );
  65.             END;
  66.  
  67.       END
  68.    ELSE
  69.       Handle_Zmodem_Autodownload := FALSE;
  70.  
  71. END   (* Handle_Zmodem_Autodownload *);
  72.  
  73. (*----------------------------------------------------------------------*)
  74. (*         Handle_Kermit_Autodownload --- Handle Kermit autodownload    *)
  75. (*----------------------------------------------------------------------*)
  76.  
  77. FUNCTION Handle_Kermit_Autodownload : BOOLEAN;
  78.  
  79. (*----------------------------------------------------------------------*)
  80. (*                                                                      *)
  81. (*     Function:   Handle_Kermit_Autodownload;                          *)
  82. (*                                                                      *)
  83. (*     Purpose:    Handles Kermit autodownload.                         *)
  84. (*                                                                      *)
  85. (*     Calling Sequence:                                                *)
  86. (*                                                                      *)
  87. (*        Found_Kermit := Handle_Kermit_Autodownload;                   *)
  88. (*                                                                      *)
  89. (*           Found_Kermit --- TRUE if Kermit packet found and           *)
  90. (*                            Kermit transfer executed.                 *)
  91. (*                                                                      *)
  92. (*     Remarks:                                                         *)
  93. (*                                                                      *)
  94. (*        This routine should be called when Kermit autodownload        *)
  95. (*        mode is in effect and the terminal emulation has received     *)
  96. (*        an "SOH" character.                                           *)
  97. (*                                                                      *)
  98. (*     Calls:                                                           *)
  99. (*                                                                      *)
  100. (*        Async_Peek                                                    *)
  101. (*        PibDownLoad                                                   *)
  102. (*                                                                      *)
  103. (*----------------------------------------------------------------------*)
  104.  
  105. VAR
  106.    Ch1 : CHAR;
  107.    Ch2 : CHAR;
  108.    Ch3 : CHAR;
  109.  
  110. BEGIN (* Handle_Kermit_Autodownload *)
  111.  
  112.                                    (* Wait 1 second to ensure arrival   *)
  113.                                    (* of rest of Kermit packet.         *)
  114.    DELAY( One_Second_Delay );
  115.                                    (* Peek ahead and pick up the next   *)
  116.                                    (* three characters after the SOH.   *)
  117.    Ch1 := Async_Peek( 0 );
  118.    Ch2 := Async_Peek( 1 );
  119.    Ch3 := Async_Peek( 2 );
  120.                                    (* "Ch1" should be a packet length   *)
  121.                                    (* in the range CHR(32) to CHR(96).  *)
  122.                                    (* If not, then this can't be the    *)
  123.                                    (* start of a Kermit packet.         *)
  124.                                    (*                                   *)
  125.                                    (* "Ch2" should be a blank, since    *)
  126.                                    (* the first packet number must be   *)
  127.                                    (* zero.                             *)
  128.                                    (*                                   *)
  129.                                    (* "Ch3" should be an "S", since     *)
  130.                                    (* the first packet of a SEND is a   *)
  131.                                    (* "Send Init".                      *)
  132.  
  133.    IF ( ( ORD( Ch1 ) IN [32..96] ) AND
  134.         ( Ch2 = ' '              ) AND
  135.         ( Ch3 = 'S'              ) ) THEN
  136.       BEGIN
  137.          Handle_Kermit_Autodownload := TRUE;
  138.          Doing_Kermit_Autodown      := TRUE;
  139.          PibDownLoad( Kermit );
  140.       END
  141.    ELSE
  142.       Handle_Kermit_Autodownload := FALSE;
  143.  
  144. END   (* Handle_Kermit_Autodownload *);
  145.