home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / modcomp / sdata. < prev    next >
Text File  |  2020-01-01  |  6KB  |  182 lines

  1.       INTEGER FUNCTION SDATA (X)
  2. C
  3. C     ****************************************************************
  4. C
  5. C              KERMIT for the MODCOMP MAXIV operating system
  6. C
  7. C        Compliments of:
  8. C
  9. C                         SETPOINT, Inc.
  10. C                      10245 Brecksville Rd.
  11. C                      Brecksville, Ohio 44141
  12. C
  13. C
  14. C      KERMIT is a copyrighted protocol of Columbia Univ. The authors
  15. C      of this version hereby grant permission to copy this software
  16. C      provided that it is not used for an explicitly commercial
  17. C      purpose and that proper credit be given. SETPOINT, Inc. makes
  18. C      no warranty whatsoever regarding the accuracy of this package
  19. C      and will assume no liability resulting from it's use.
  20. C
  21. C     ****************************************************************
  22. C
  23. C     Abstract:  Send a data packet to the remote Kermit.
  24. C
  25. C     MODIFICATION HISTORY
  26. C
  27. C     BY            DATE     REASON            PROGRAMS AFFECTED
  28. C
  29. C     ****************************************************************
  30. C
  31. C     Author:  Rick Burke           Version: A.0    Date: Sep-86
  32. C
  33. C     Calling Parameters:
  34. C
  35. C     R    X            - Dummy argument required by FORTRAN
  36. C
  37. C     ****************************************************************
  38. C
  39. C     Messages generated by this module :  None
  40. C
  41. C     ****************************************************************
  42. C
  43. C     Subroutines called directly : BUFILL, MOD, RPACK, SPACK
  44. C
  45. C     ****************************************************************
  46. C
  47. C     Files referenced :  None
  48. C
  49. C     ****************************************************************
  50. C
  51. C     Local variable definitions :
  52. C
  53. C     LEN          - Length of received packet
  54. C     NUM          - Number of received packet
  55. C     TNUM         - Expected packet number
  56. C     TV1          - Temporary variable
  57. C
  58. C     ****************************************************************
  59. C
  60. C     Commons referenced :  KER and  KERPAR local commons
  61. C
  62. C     ****************************************************************
  63. C
  64. C     (*$END.DOCUMENT*)
  65. C
  66. C     ****************************************************************
  67. C     *                                                              *
  68. C     *         D I M E N S I O N   S T A T E M E N T S              *
  69. C     *                                                              *
  70. C     ****************************************************************
  71. C
  72.       IMPLICIT INTEGER (A-Z)
  73. C
  74. C     ****************************************************************
  75. C     *                                                              *
  76. C     *         T Y P E   S T A T E M E N T S                        *
  77. C     *                                                              *
  78. C     ****************************************************************
  79. C
  80. C
  81. C     ****************************************************************
  82. C     *                                                              *
  83. C     *         C O M M O N   S T A T E M E N T S                    *
  84. C     *                                                              *
  85. C     ****************************************************************
  86. C
  87.       INCLUDE USL/KERCOM
  88.       INCLUDE USL/KERPMC
  89. C
  90. C     ****************************************************************
  91. C     *                                                              *
  92. C     *         E Q U I V A L E N C E   S T A T E M E N T S          *
  93. C     *                                                              *
  94. C     ****************************************************************
  95. C
  96. C
  97. C     ****************************************************************
  98. C     *                                                              *
  99. C     *         D A T A   S T A T E M E N T S                        *
  100. C     *                                                              *
  101. C     ****************************************************************
  102. C
  103. C
  104. C     ****************************************************************
  105. C
  106. C     Code starts here :
  107. C
  108. C
  109. C----->  Assume some kind of error.
  110. C
  111.       SDATA = BIGA
  112. C
  113. C----->  Retry counter exceeded?
  114. C
  115.       IF (NUMTRY .GT. MAXTRY) RETURN
  116.       NUMTRY = NUMTRY + 1
  117. C
  118. C----->  Send the data packet.
  119. C
  120.       TNUM = N
  121.       TV1 = BIGD
  122.       CALL SPACK (TV1,TNUM,SIZE,PACKET)
  123. C
  124. C----->  If we are in local mode then display the packet
  125. C----->  sequence number.
  126. C
  127.       IF (HOSTON .EQ. NO) WRITE (LOCALO,100) TNUM
  128. C
  129. C----->  Get the reply from the remote.
  130. C
  131.       STATUS = RPACK (LEN,NUM,RECPKT)
  132. C
  133. C----->  The next statements are to make sure that we are not one
  134. C----->  packet ahead of the other Kermit. This will happen if the
  135. C----->  other Kermit sends a NAK (due to a timeout detection)
  136. C----->  before we send the first SINIT packet.
  137. C
  138.       IF (STATUS .EQ.  BIGY .AND.
  139.      >    N      .EQ. NUM+1      ) STATUS = RPACK (LEN,NUM,RECPKT)
  140.       IF (STATUS .NE. BIGN) GO TO 10
  141. C
  142. C----->  We got a NAK.
  143. C
  144.       IF (N .EQ. NUM-1) GO TO 50
  145.       SDATA = STATE
  146.       RETURN
  147.    10 CONTINUE
  148.       IF (STATUS .NE. BIGY) GO TO 40
  149. C
  150. C----->  We got an ACK.
  151. C
  152.       IF (N .EQ. NUM) GO TO 20
  153. C
  154. C----->  But, it was for the last packet.
  155. C
  156.       SDATA = STATE
  157.       RETURN
  158.    20 CONTINUE
  159.       NUMTRY = 0
  160.       N = MOD((N+1),64)
  161.       SIZE = BUFILL (PACKET)
  162.       IF (SIZE .NE. EOF) GO TO 30
  163.       SDATA = BIGZ
  164.       RETURN
  165.    30 CONTINUE
  166.       SDATA = BIGD
  167.       RETURN
  168.    40 CONTINUE
  169.       IF (STATUS .NE. BAD) GO TO 50
  170. C
  171. C----->  We got a checksum error, try again.
  172. C
  173.       SDATA = STATE
  174.       RETURN
  175.    50 CONTINUE
  176. C
  177. C----->  Here we got an unknown packet type or an error occurred.
  178. C
  179.       RETURN
  180. 100   FORMAT('+PACKET #',I3,'  ')
  181.       END
  182.