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