home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 8 Other / 08-Other.zip / 40cid_b2.zip / 40cid.txt < prev    next >
Text File  |  1995-12-27  |  14KB  |  428 lines

  1. 40CID.EXE and COM40.SYS
  2.  
  3. o Quick Install:
  4. ---------------
  5. In CONFIG.SYS, comment out COM.SYS, add COM40.SYS:
  6.  
  7.  ...
  8.  REM device=com.sys
  9.  device=com40.sys
  10.  ...
  11.  
  12. Reboot.
  13.  
  14. At prompt, start CID40.EXE program.
  15.  
  16.  C>cid40      (use /h or ? for fast-tips, or read Notes below for more)
  17.  
  18.  
  19. As calls come in, the screen shows the CID info.  Press Ctrl-C to exit
  20. and release the com port.  Restart when com port is free.
  21.  
  22.  == 40CID.EXE requires Warp or later ==
  23.  
  24.  
  25. o Notes:
  26. --------
  27. To use 40CID, the COM40.SYS device driver must be installed.  In CONFIG.SYS
  28. comment out DEVICE=COM.SYS and add DEVICE=COM40.SYS.  Most COM.SYS options
  29. are valid for COM40.SYS (also include the appropriate path).  After the
  30. change, reboot your machine.
  31.  
  32. Start 40CID.EXE (this program).  Optional switches are for the COM port
  33. /COMn where n=1 to 4) and the CID lead byte (/0xHH where HH is a hex byte
  34. value that matches your CID lead byte -- the defaults are 0x80 and 0x04).
  35. So, if your modem is at COM2, and your lead byte is either 0x80 or 4, you
  36. no switches -- the defaults are fine.  Or, for example:
  37.  
  38.         C>40cid /com1  (comport)        or,
  39.         C>40cid -0x08  (CID lead byte)  or,
  40.         C>40cid -bell  (bell at CID)    or a combination of them.
  41.  
  42. To use the com port with another program, press Ctrl-C to exit 40CID.EXE.
  43. If you exit 40CID.EXE, you should activate the modem as soon as possible so
  44. that no CIDs are lost.  Up to 16 CID entries are buffered in COM40.SYS.
  45. As soon as you leave the other program, you should restart 40CID.EXE.  Any
  46. buffered CIDs will be shown, up to 16 (a double beep is sounded if the buffer
  47. queue wrapped around, indicating that only the last 16 entries were saved.
  48.  
  49. To check your CID lead byte, start up an ASCII terminal (e.g., ZOC or Telix)
  50. and enter:
  51.  
  52. ATZ <enter>
  53. [OK]
  54. AT#CID=2 <enter>
  55. [OK]
  56.  
  57. You may need to enter ATE1 to see what you type (check your modem manual).
  58. Dial the terminal's modem (or ask someone to call).  The first byte sent
  59. out by a caller ID modem is the my-called 'lead byte'.  I've seen this
  60. documented as being \x04 (a 'diamond' character on screen, usually), but
  61. I always get a lead byte of \x80.  It may be that you won't be able to
  62. see your lead byte (e.g., if it is \x08, the backspace), so you may need
  63. to write a little ditty to read the hex values.  Ask any programmer you
  64. happen to see...  Your terminal program may already have this (data dump
  65. mode, etc.).  If your lead byte is not \x80 or \x04, use the -0xHH switch
  66. as shown above.
  67.  
  68. The output is to a Vio screen.  The last 16 entries are shown.  The newest
  69. is at the top, and then moving down to oldest.  Initially, the first screen
  70. simply shows:
  71.  
  72.   Use Ctrl-C to exit program and release ComPort
  73.   [40CID]_
  74.  
  75. Upon the first call, between the first and second 'RING', the CID data
  76. is sent.  Depending on the origin and your service, you may not get the 
  77. name, nor the number.  The time is always shown.  A typical call list may 
  78. look like:
  79.  
  80.   NOT AVAILABLE   (999)999-9998  12/09/95 05:01  80|xx
  81.   SNEAK/NOT AVAIL (999)999-9999  12/09/95 05:00  80|xx
  82.   SCUM J G        (512)226-7678  12/09/95 04:58  80|xx=checksum
  83.  
  84. where the most current calls are at the top, followed by earlier calls.
  85. If the name is not available, "NOT AVAILABLE" is used (note number used).
  86. If the call was made anonymously, "SNEAK/NOT AVAIL" is used (note number).
  87. The data and time follow, then the lead byte and record checksum.
  88.  
  89. If the number data is unknown the following is used:
  90.  
  91.   UNK NUMBER DATA (999)999-9998  12/27/95 05:59  80|xx
  92.  
  93.  
  94. Use Ctrl-C to exit the program and release the com port.
  95.  
  96. [27-Dec-1995 -- support at comp.os.os2.misc, Subject: [COM40] ...]
  97.  
  98.  
  99. For those interested in accessing the CID data, the API follows.
  100. This is not supported on an individual basis at this time (i.e.,
  101. you are on your own).
  102.  
  103.  
  104. //
  105. // 40CID API
  106. // 27-Dec-95
  107. //
  108. // Requires COM40.SYS installed as COM device.
  109. // This product is Unsupported at this time, on an individual basis.
  110. //
  111. // Copyright (C)1995 40th Floor Software
  112. // All Rights Reserved.
  113.  
  114. #define IOCTL_40TH      0x40 // func code for IOCTL_ASYNC calls to com40 DD
  115.  
  116. #define RETRIES_40CID   4 // retry routines up to x times
  117.  
  118. #define GET_VER_CID     1 // funcNo codes
  119. #define GET_STATE_CID   2
  120. #define SET_STATE_CID   3
  121. #define RESET_CID       4
  122. #define READ_QUEUE_CID  5
  123.  
  124. #define CID_RQ_LIFO    -1 // read & remove newest entry in queue
  125. #define CID_RQ_FIFO     0 // read & remove oldest entry in queue
  126. #define CID_RQ_PEEKN    0 // read n-oldest entry in queue (1-entries, 1=oldest)
  127.  
  128. // structures
  129.  
  130. typedef struct _VERSION {
  131.  ULONG status;
  132.  ULONG version;
  133.  ULONG queueEntries;
  134.  ULONG entrySize;
  135. } VERSION;
  136. typedef VERSION *PVERSION;
  137.  
  138. typedef struct _STATE {
  139.  ULONG status;
  140.  ULONG flags;
  141.  ULONG count;
  142.  UCHAR leadBytes[4];
  143. } STATE;
  144. typedef STATE *PSTATE;
  145.  
  146. typedef struct _ENTRY {
  147.  ULONG status;
  148.  ULONG flags;
  149.  ULONG mode;
  150.  UCHAR entry[64];
  151. } ENTRY;
  152. typedef ENTRY *PENTRY;
  153.  
  154.  
  155. typedef struct _IOCTLPARM {
  156.  UCHAR parmID[6];
  157.  SHORT funcNo;
  158. } IOCTLPARM;
  159.  
  160.  
  161. // ... CID40 routines
  162.  
  163. ULONG GetVersion40CID (HFILE comID, PVERSION cidVerPtr);
  164. ULONG GetState40CID (HFILE comID, PSTATE statePtr);
  165. ULONG SetState40CID (HFILE comID, PSTATE statePtr);
  166. ULONG ResetActive40CID (HFILE comID, ULONG status);
  167. ULONG ReadQueue40CID (HFILE comID, PENTRY entryPtr);
  168.  
  169.  
  170. /////////////////////////////////////////////////////////////////////////////
  171. //
  172. //
  173. //
  174. // 40CID routines
  175. //
  176. //
  177. //
  178. /////////////////////////////////////////////////////////////////////////////
  179.  
  180.  
  181. //////////////////////////////////////////////////////////////////////////
  182. // ------------------------
  183. // Get 40CID driver version
  184. //
  185. // stk: verPtr: returned version of DD, 0 if error
  186. // out: OS result code of IOCTL call, if 0 VERSION.members set always
  187. //      .status       = active state of driver
  188. //      .version      = driver version * 1000
  189. //      .queueEntries = max CID entries buffered in driver
  190. //      .entrySize    = max length of a single CID entry data
  191. // nts: VERSION.status returns active status (bits0-3: process stage bits)
  192. //      bit0=1 in processing, and if only bit0=1 then scanning for ringStr
  193. //         1=1 ringStr matched, now scanning for lead byte
  194. //         2=1 lead byte matched, now get size byte
  195. //         3=1 size byte stored, now getting all data info, plus checksum
  196. //      When all data of CID is stored, .active bits0-3 are set to 0.
  197. //
  198. //      The other 40CID calls return with bit31=1 when busy, along with 
  199. //      the current active status (in bits0-3).  It may be necessary to
  200. //      force a clear of the active status bits, and that can be done at
  201. //      two different levels with RESET_CID.
  202. //
  203. //      HOWEVER, on next RING (second ring), .active remains in stage 0011y
  204. //      since no lead byte will arrive (unless a data connect, then maybe,
  205. //      and if not a matching lead byte, .active is set back to 0 and all is
  206. //      okay) and so .active remains limbo'ed at .active=3.
  207. //
  208. //      GET_VER_CID always returns not busy since it access R-O data.
  209.  
  210. ULONG GetVersion40CID (HFILE comID, PVERSION cidVerPtr) {
  211.  
  212.    ULONG rc;
  213.    ULONG parmLen = sizeof(IOCTLPARM);
  214.    ULONG dataLen = 0;
  215.    IOCTLPARM parm = {"40CID",GET_VER_CID};
  216.       
  217.    rc = DosDevIOCtl(comID,IOCTL_ASYNC,IOCTL_40TH,
  218.                     &parm,sizeof(parm),&parmLen,
  219.                     cidVerPtr,sizeof(VERSION),&dataLen);
  220.    return rc;           
  221. }   
  222.  
  223.  
  224. // ---------------
  225. // Get 40CID state
  226. //
  227. // stk: HFILE:comID:com port handle
  228. //      PSTATE:statePtr:pointer to STATE structure to set DD to
  229. // out: OS result code of IOCTL call, if 0 STATE.members set, unless busy
  230. // nts: if the DD is busy, STATE.status=0x8000xxxx where xxxx is 1,3,5,9
  231.  
  232. ULONG GetState40CID (HFILE comID, PSTATE statePtr) {
  233.  
  234.    ULONG rc;
  235.    ULONG parmLen = sizeof(IOCTLPARM);
  236.    ULONG dataLen = 0;
  237.    IOCTLPARM parm = {"40CID",GET_STATE_CID};
  238.  
  239.    ULONG times,i;
  240.  
  241.    for (times=1; times <= 2; times++) {
  242.  
  243.       for (i=1; i <= RETRIES_40CID; i++) {
  244.  
  245.          rc = DosDevIOCtl(comID,IOCTL_ASYNC,IOCTL_40TH,
  246.                           &parm,sizeof(parm),&parmLen,
  247.                           statePtr,sizeof(STATE),&dataLen);
  248.  
  249.          if (rc!=0) goto ExitNow; // OS error
  250.  
  251.          // if busy >= 3, wait 0.75 second or so to allow processing to finish
  252.          // if busy = 1, wait 2.1 seconds or so to allow for full processing
  253.  
  254.          rc = statePtr->status;
  255.          if (rc == 0) goto ExitNow;
  256.  
  257.          if ((rc & 0xFF) >= 3) {
  258.             DosSleep(750);      // is processing (probably)
  259.          } else {
  260.             DosSleep(2100);     // may be stuck, or processing (wait longer)
  261.             rc = ResetActive40CID(comID,rc);  // unstick if at <= 3 now
  262.          }
  263.       }
  264.  
  265.       rc = ResetActive40CID(comID,0x8000FFFF);
  266.    }
  267.  
  268. ExitNow:
  269.  
  270.    return rc;           
  271. }   
  272.  
  273.  
  274. // ---------------
  275. // Set 40CID state
  276. //
  277. // stk: HFILE:comID:com port handle
  278. //      PSTATE:statePtr:pointer to STATE structure to set DD to
  279. // out: OS result code of IOCTL call, if 0 STATE.active set
  280. // nts: The DD state cannot be set if the current active state is busy.
  281. //      Currently, only the leadBytes can be changed.
  282. //      < Beta levels require .flags=0x19771959 on entry to activate 40CID >
  283.  
  284. ULONG SetState40CID (HFILE comID, PSTATE statePtr) {
  285.  
  286.    ULONG rc;
  287.    ULONG parmLen = sizeof(IOCTLPARM);
  288.    ULONG dataLen = 0;
  289.    IOCTLPARM parm = {"40CID",SET_STATE_CID};
  290.  
  291.    ULONG times,i;
  292.  
  293.    for (times=1; times <= 2; times++) {
  294.  
  295.       for (i=1; i <= RETRIES_40CID; i++) {
  296.  
  297.          rc = DosDevIOCtl(comID,IOCTL_ASYNC,IOCTL_40TH,
  298.                           &parm,sizeof(parm),&parmLen,
  299.                           statePtr,sizeof(STATE),&dataLen);
  300.  
  301.          if (rc!=0) goto ExitNow; // OS error
  302.  
  303.          // if busy >= 3, wait 0.75 second or so to allow processing to finish
  304.          // if busy = 1, wait 2.1 seconds or so to allow for full processing
  305.  
  306.          rc = statePtr->status;
  307.          if (rc == 0) goto ExitNow;
  308.  
  309.          if ((rc & 0xFF) >= 3) {
  310.             DosSleep(750);      // is processing (probably)
  311.          } else {
  312.             DosSleep(2100);     // may be stuck, or processing (wait longer)
  313.             rc = ResetActive40CID(comID,rc);  // unstick if at <= 3 now
  314.          }
  315.       }
  316.  
  317.       rc = ResetActive40CID(comID,0x8000FFFF);
  318.    }
  319.  
  320. ExitNow:
  321.  
  322.    return rc;           
  323. }   
  324.  
  325.  
  326. // -----------------------
  327. // Reset 40CID active flag
  328. //
  329. // stk: HFILE:comID:com port handle
  330. //      ULONG:status:status to use (0x8000xxxx, xxxx=1, or 3, or FFFF)
  331. // out: OS result code of IOCTL call, if 0 STATE.active reset if <= 3 
  332. // nts:
  333. //      This call typically used after a routine errors out with a busy,
  334. //      and a wait of at least 1/10th second has transpired, but no more
  335. //      than 1 second (or so).  If more than 1 second, then it's possible
  336. //      that this may clear a new CID call just starting.  When called, if
  337. //      the current active state is <=3, the active state is reset (so call
  338. //      this routine only after waiting 0.1 to 1 second after the first busy).
  339. //      If busy still, and active > 3, then that busy state is returned.  You
  340. //      may force a reset by calling with status=0x8000FFFF.
  341. //
  342. //      state.status is typically set to the busy error value returned from the
  343. //      original call that indicated the DD was busy (0x8000xxxx, xxxx=1 or 3).
  344. //      This after waiting appoximately 1/10th to 1 second from the busy
  345. //      indication, so that any real processing can complete normally.  If
  346. //      busy is still indicated (as returned from this call), then you may
  347. //      force the DD to become unbusy by set statePtr->status=0x8000FFFF.
  348. //      This should be a last resort -- only if you believe the DD has hung
  349. //      up on bogus caller ID data.  One way to determine this is to
  350. //      repeatedly call this routine, once a second, for 5 seconds or so, 
  351. //      checking the return status.  If always the same (it will be greater
  352. //      than 0x80000003) you should go ahead and force a reset by setting
  353. //      state.status=0x8000FFFF.  This clears the active state at the driver
  354. //      and permits calls to proceed without the 'busy' error returned.
  355.  
  356. ULONG ResetActive40CID (HFILE comID, ULONG status) {
  357.  
  358.    ULONG rc;
  359.    ULONG parmLen = sizeof(IOCTLPARM);
  360.    ULONG dataLen = 0;
  361.    IOCTLPARM parm = {"40CID",RESET_CID};
  362.  
  363.    STATE state;
  364.    state.status = status;  // reset active flag (possibly by force)
  365.  
  366.    rc = DosDevIOCtl(comID,IOCTL_ASYNC,IOCTL_40TH,
  367.                     &parm,sizeof(parm),&parmLen,
  368.                     &state,sizeof(STATE),&dataLen);
  369.  
  370.    if (rc==0) rc = state.status;
  371.    return rc;           
  372. }   
  373.  
  374.  
  375. // --------------
  376. // Read CID Queue
  377. //
  378. // stk: HFILE:comID:com port handle
  379. //      PENTRY:entryPtr:pointer to ENTRY
  380. // out: OS result code of IOCTL call
  381. // nts: 
  382.  
  383. ULONG ReadQueue40CID (HFILE comID, PENTRY entryPtr) {
  384.  
  385.    ULONG rc;
  386.    ULONG parmLen = sizeof(IOCTLPARM);
  387.    ULONG dataLen = 0;
  388.    IOCTLPARM parm = {"40CID",READ_QUEUE_CID};
  389.  
  390.    ULONG times,i;
  391.  
  392.    for (times=1; times <= 2; times++) {
  393.  
  394.       for (i=1; i <= RETRIES_40CID; i++) {
  395.  
  396.          rc = DosDevIOCtl(comID,IOCTL_ASYNC,IOCTL_40TH,
  397.                           &parm,sizeof(parm),&parmLen,
  398.                           entryPtr,sizeof(ENTRY),&dataLen);
  399.  
  400.          if (rc!=0) goto ExitNow; // OS error
  401.  
  402.          // if busy >= 3, wait 0.75 second or so to allow processing to finish
  403.          // if busy = 1, wait 2.1 seconds or so to allow for full processing
  404.  
  405.          rc = entryPtr->status;
  406.          if (rc == 0) goto ExitNow;
  407.  
  408.          // DosBeep(1000,100);
  409.          if ((rc & 0xFF) >= 3) {
  410.             DosSleep(750);      // is processing (probably)
  411.          } else {
  412.             DosSleep(2100);     // may be stuck, or processing (wait longer)
  413.             rc = ResetActive40CID(comID,rc);  // unstick if at <= 3 now
  414.          }
  415.       }
  416.  
  417.       rc = ResetActive40CID(comID,0x8000FFFF);
  418.       DosBeep(60,100);
  419.    }
  420.  
  421. ExitNow:
  422.  
  423.    return rc;           
  424. }   
  425.  
  426. // This is unsupported at this time -- you are on your own, programmer.
  427.  
  428.