home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 3 Comm / 03-Comm.zip / comsuite.zip / pbook_r.cmd < prev    next >
OS/2 REXX Batch file  |  2001-10-21  |  4KB  |  157 lines

  1. /* Script for save Phone Book from Phone */
  2.  
  3. Call RxFuncAdd 'SysSleep', 'RexxUtil', 'SysSleep'
  4. Call RxFuncAdd 'SysGetKey', 'RexxUtil', 'SysGetKey'
  5. Call RxFuncAdd 'SysCls', 'RexxUtil', 'SysCls'
  6. Call RxFuncAdd 'SysTempFileName', 'RexxUtil', 'SysTempFileName'
  7. Call RxFuncAdd 'SysFileDelete', 'RexxUtil', 'SysFileDelete'
  8. Call RxFuncAdd 'RxAsyncRead', 'RXASYNC', 'RxAsyncRead'
  9. Call RxFuncAdd 'RxAsyncWait', 'RXASYNC', 'RxAsyncWait'
  10. Call RxFuncAdd 'RxAsyncSetMdmOutput', 'RXASYNC', 'RxAsyncSetMdmOutput'
  11. call RxFuncAdd 'RxAsyncLoadFuncs', 'RXASYNC', 'RxAsyncLoadFuncs'
  12. call RxAsyncLoadFuncs
  13.  
  14. signal on halt
  15.  
  16. /* [Global] */
  17. comport="com1"
  18. init="ATE0"
  19. command_delay=0.5    /* delay between AT commands (sec) */
  20. phonevol=7
  21.  
  22. /* [Internal] Don't modify w/o necessity !!! */
  23. PortHandle=''
  24. remaining=''
  25. debug=1
  26. mainlog=1
  27. crlf=d2c(13)d2c(10)
  28.  
  29. /* ------------- Entry Point -------------- */
  30. Call SysCls
  31.  
  32. rc=crlf "    Automatic Ericsson Pbook Changer v 1.01 (c) By Alek Winner." crlf
  33. say rc
  34. if mainlog then call charout rclog,rc
  35.  
  36. call comport_check
  37.  
  38.  
  39. patrol:
  40.  
  41. parse arg pbook
  42.  
  43. if pbook="" then
  44.   do
  45.   say "Filename required..."
  46.   exit
  47.   end
  48.  
  49. rc = RxAsyncWrite( PortHandle, 0, init||crlf, 'Remaining' )
  50. if rc <> 0 then signal err1
  51.  
  52. call check_string "Init", "OK", "  Modem not ready... Exitting... ;("
  53.  
  54.  
  55. rc=" "date()"ú  " time() "  Phone Modem Initialized OK" crlf
  56. say rc
  57. if mainlog then call charout rclog,rc
  58.  
  59. rc = RxAsyncWrite( PortHandle, 0, 'AT+CPBS="SM"'||crlf, 'Remaining' )
  60. if rc <> 0 then signal err1
  61.  
  62. call check_string "AT*CPBS", "OK", "  Modem not ready... Exitting... ;("
  63.  
  64. rc = RxAsyncWrite( PortHandle, 0, 'AT+CPBR=?'||crlf, 'Remaining' )
  65. if rc <> 0 then signal err1
  66.  
  67. do 2
  68. rc = RxAsyncRead( PortHandle, 0, 3000, 'InpStr' )
  69. end
  70.  
  71. parse value inpstr with id_1 '(' beg_el '-' end_el '),' pl ',' nl nop
  72. if id_1 <> '+CPBR: ' then signal err1
  73.  
  74. call check_string "AT+CPBR=?", "OK", "  Modem not ready... Exitting... ;("
  75.  
  76. say "Detected SIM Card with capasity   " end_el 
  77. say "Phone Number length is            " pl     
  78. say "Abonent Name length is            " nl     
  79.  
  80. rc = RxAsyncWrite( PortHandle, 0, 'AT+CPBR='||beg_el||','||end_el||crlf, 'Remaining' )
  81. if rc <> 0 then signal err1
  82.  
  83.  
  84. do until inpstr = 'OK'||crlf
  85.  
  86. rc = RxAsyncRead( PortHandle, 0, 3000, 'InpStr' )
  87.  
  88. parse value inpstr with id_2 poz ',"' number '",' unc ',"' name '"'
  89. if id_2 <> '+CPBR:' then iterate
  90. rc=left(poz,4)||left(number,24)||left(unc,4)||name
  91. say rc
  92. call lineout pbook,rc
  93.  
  94. end
  95.  
  96. call RxAsyncClose PortHandle
  97. exit
  98.  
  99.  
  100. /* --- Check Port State --------*/
  101. comport_check:
  102. if stream(comport,'c','open') = 'NOTREADY:32' then signal err0
  103.  
  104. call stream comport,'c','close'
  105. rc = RxAsyncOpen( Comport, 'PortHandle' )
  106.  
  107. com_init:
  108.  
  109. rc = RxAsyncSetLnCtrl( PortHandle, 57600, 8, 'N', 1 )
  110. if rc <> 0 then signal err0
  111.  
  112. rc=RxAsyncSetDcbInfo(PortHandle,400,50,'00001001','10000000','','','','','' )
  113. return
  114.  
  115. err0:
  116. rc=" "date()"ú  " time() "  Comport is not respond... ;(" crlf
  117. say rc
  118. if mainlog then call charout rclog,rc
  119. /* call beep 262,250 */
  120. exit
  121. /* -----------------------------*/
  122.  
  123.  
  124.  
  125. /* -- Check Modem String --------- */
  126. check_string:
  127. PARSE ARG deb_str, ok_str, err_str
  128.  
  129. InpStr = ""
  130. do until InpStr=ok_str||crlf | InpStr='ERROR'||crlf
  131. rc = RxAsyncRead( PortHandle, 0, 3000, 'InpStr' )
  132. if rc <> 0 then signal err1
  133. db=deb_str InpStr crlf
  134. if debug then call charout debug.log,db
  135. end
  136.  
  137. if InpStr = ok_str||crlf then return
  138.  
  139. err1:
  140. rc=" "date()"ú  " time() err_str crlf
  141. say rc
  142. if mainlog then call charout rclog,rc
  143. /* call beep 262,250 */
  144. signal term
  145. /* -- Check Modem String - Ends -- */
  146.  
  147.  
  148.  
  149. /* ----- Close All Files -------*/
  150. close_all:
  151. call stream rclog,'c','close'
  152. call stream debug.log,'c','close'
  153. return
  154. /* -----------------------------*/
  155.  
  156. term:
  157.