Re: PC Com Port data capture....
- From: Norman Morgan <nmorgan@**nospam**brake.com>
- Date: Tue, 25 Oct 2005 13:51:53 -0000
"sf" <junk@junk> wrote in news:11lsa6nqdui3h90@xxxxxxxxxxxxxxxxxx:
> Looking for someone with experience in PICK D3 to take an
> existing program that runs on a PICK port, "listening" for data
> input and writes the received input to a record in the D3
> database that is then used in other applications. Moving to D3
> windows, we need this application to "listen" on the comm or
> serial port of a PC and take the same information and write it
> to the database record.
>
I don't know if this will help you or not, but here is a program I
did to capture call detail information from a serial port on our
PBX.
* Capture CDR Information From Lucent Definity G3V6 PBX
*
* PROGRAM CALL.RECORDER
*
* Monitors serial port to capture call detail records from PBX,
* reformat and write them to a D3 file for subsequent analysis.
* Serial port may be specified on the command line. If the port
* is not specified, the default port #6 is used. The program is
* intended to be run in a phantom process. It may be brought to
* an orderly halt by writing an empty item with an ID of "STOP"
* to the CALL.DETAIL file. It will be acted on after a record
* is written or after 30 seconds with no call recorded.
*
* ** Program Constants
AM = CHAR(254); VM = CHAR(253); CR = CHAR(13)
MPORT = 57
ERRMSG = ""
FOREVER = 0
* Get command line arguments and store in dynamic array
TCLREAD ARG
SAVEARG = ARG
CONVERT ',' TO ' ' IN ARG
ARG = TRIM(ARG)
CONVERT ' ' TO AM IN ARG
PROGNAME = ARG<1>
DEL ARG<1>
NUMARG = DCOUNT(ARG,AM)
IF NUMARG # 0 THEN MPORT = ARG<1>
* ** Open files
ERMSG = ""
OPEN "CALL.DETAIL" TO F.CDR ELSE ERMSG := " CALL.DETAIL"
IF ERMSG # "" THEN
PRINT "Unable to open:":ERMSG
STOP
END
* ** turn off software handshaking on capture port
VERB = "xonoff (":MPORT:"F"
EXECUTE VERB RETURNING MSG CAPTURING DSP
SLEEP 1
* ** turn off carrier detect on capture port
VERB = "dcd-off ":MPORT
EXECUTE VERB RETURNING MSG CAPTURING DSP
SLEEP 1
* ** unlink the capture port from its normal Pick process
VERB = "unlink-pibdev ":MPORT:",":MPORT
EXECUTE VERB RETURNING MSG CAPTURING DSP
SLEEP 1
* ** attach capture port to this process
VERB = "dev-att ":MPORT
EXECUTE VERB RETURNING MSG CAPTURING DSP
SLEEP 1
* ** Main Processing Logic
LOOP UNTIL FOREVER
TEMP = ""
* ** read characters from the port until a carriage return
* ** is seen or until we have been idle for 60 seconds
GET TEMP FROM MPORT UNTIL CR WAITING 60 THEN
* ** format and write the output record
CDR = ""
C.DATE = TEMP[1,2]:"/":TEMP[3,2]:"/":TEMP[5,2]
CDR<1> = ICONV(C.DATE,'d2/'); * date
CDR<2> = ICONV(TEMP[8,4],'mt'); * time
CDR<3> = TRIM(TEMP[13,5],"0","L"); * call duration
CDR<4> = TRIM(TEMP[19,15]); * calling #
CDR<5> = TRIM(TEMP[35,18]); * dialled #
CDR<6> = TRIM(TEMP[54,4]); * trunk
CDR<7> = TRIM(TEMP[59,5]); * vdn
CDR.ID = SYSTEM(21)
WRITE CDR ON F.CDR,CDR.ID
END
* ** check for the STOP flag and shutdown if found
READ JUNK FROM F.CDR,"STOP" THEN
FOREVER = 1
DELETE F.CDR,"STOP"
END
REPEAT
* ** Detach the capture port from this process
VERB = "dev-det ":MPORT
EXECUTE VERB RETURNING MSG CAPTURING DSP
SLEEP 1
* ** relink capture port to its own process
VERB = "link-pibdev ":MPORT:",":MPORT
EXECUTE VERB RETURNING MSG CAPTURING DSP
STOP
Feel free to use any parts that are helpful.
--
===========================================================
Norman Morgan <> http://www.norm-morgan.com
===========================================================
Sometimes I wake up grumpy. Other times I let her sleep.
===========================================================
.
- Follow-Ups:
- Re: PC Com Port data capture....
- From: GVP
- Re: PC Com Port data capture....
- References:
- PC Com Port data capture....
- From: sf
- PC Com Port data capture....
- Prev by Date: Re: Attempt to de-mystify AJAX
- Next by Date: Re: How do we get there from here?
- Previous by thread: PC Com Port data capture....
- Next by thread: Re: PC Com Port data capture....
- Index(es):
Relevant Pages
|