[[https://www.revelation.com/|Sign up on the Revelation Software website to have access to the most current content, and to be able to ask questions and get answers from the Revelation community]] ==== Reading Com Port (OpenInsight Specific) ==== === At 25 MAY 1998 12:38:01PM Duane Pekse wrote: === {{tag>"OpenInsight Specific"}} I need to read the current status of a com port. I seem to remember seeing it in the manual once, but I can't find it now. I'm sure it's possible. Can anyone help me? Duane Pekse, Developer Aldata Software ---- === At 28 MAY 1998 04:12AM Colin Rule (CSSP) wrote: === I don't know if the following code is of use. We use it to communicate with a digitiser tablet. There are many other procedures also, but this one may have what you need. Sorry about the wrapping, Revtech should make the edit box resizable. COMPILE SUBROUTINE COMM_ACCESS(MODE,COMM_PORT_HANDLE,COMMDATA) * STANDARD * Open/Close Comm port, Read/Write to port * AG - May 96 * DECLARE FUNCTION BLANK_STRUCT,GET_PROPERTY,STRUCT_TO_VAR,VAR_TO_STRUCT DECLARE FUNCTION OpenComm,CloseComm,BuildCommDCB,SetCommState,ReadComm,WriteComm BEGIN CASE CASE MODE=OPEN" ;GOSUB OPEN_PORT CASE MODE=CLOSE" ;GOSUB CLOSE_PORT CASE MODE=READ" ;GOSUB READ_FROM_PORT CASE MODE=WRITE" ;GOSUB WRITE_TO_PORT END CASE RETURN OPEN_PORT: COMM_ERRORS=" COMM_ERRORS=-1 ;COMM_ERRORS=Invalid or unsupported device" COMM_ERRORS=-2 ;COMM_ERRORS=Device already in use" COMM_ERRORS=-10;COMM_ERRORS=Device already in use" COMM_ERRORS=-12;COMM_ERRORS=Device baud rate is invalid" * PORT =COMMDATA BAUD_RATE=COMMDATA DATA_BITS=COMMDATA STOP_BITS=COMMDATA PARITY =COMMDATA1,1 FLOW_CONTROL=COMMDATA1,1 PORT_SETTINGS=PORT:":":BAUD_RATE:",":PARITY:",":DATA_BITS:",":STOP_BITS:\00\ PORT=PORT:\00\ INQSIZE=1024;OUTQSIZE=128 COMM_PORT_HANDLE=OpenComm(PORT,INQSIZE,OUTQSIZE) LOCATE COMM_PORT_HANDLE IN COMM_ERRORS USING @VM SETTING POS THEN COMM_PORT_HANDLE=COMM_ERRORS RETURN END * DCB_STRUCT=BLANK_STRUCT("DCB") RETVAL=BuildCommDCB(PORT_SETTINGS,DCB_STRUCT) COMM_PARAMS=STRUCT_TO_VAR(DCB_STRUCT,"DCB") BEGIN CASE CASE FLOW_CONTROL=X" COMM_PARAMS=3 CASE FLOW_CONTROL=H" COMM_PARAMS=5 COMM_PARAMS=9 COMM_PARAMS=64 END CASE DCB_STRUCT=VAR_TO_STRUCT(COMM_PARAMS,"DCB") RETVAL=SetCommState(DCB_STRUCT) RETURN CLOSE_PORT: RETVAL=CloseComm(COMM_PORT_HANDLE) RETURN READ_FROM_PORT: BUFF_LEN=50 COMMDATA=STR(\00\,BUFF_LEN) RETVAL=ReadComm(COMM_PORT_HANDLE,COMMDATA,BUFF_LEN) COMMDATA=FIELD(COMMDATA,\00\,1) RETURN WRITE_TO_PORT: COMMDATA=COMMDATA:\00\ BUFF_LEN=LEN(COMMDATA) RETVAL=WriteComm(COMM_PORT_HANDLE,COMMDATA,BUFF_LEN) RETURN ---- === At 28 MAY 1998 04:50PM Duane Pekse wrote: === Thanks for the help. I have just one more question for you. Where did you find the OpenComm, CloseComm, etc Functions? Are they from a DLL, or are they part of OI? I couldn't find anything on them in the help file for OI, so I don't even have the prototype information. Thanks again. Duane Aldata Software ---- === At 29 MAY 1998 05:03AM Colin Rule wrote: === Sorry, forgot this. It is a link to a DLL, all a bit tricky though. I get my programmers to do this for me. Hope this helps Code below: USER * * CSSP Functions Below * SHORT PASCAL OpenComm(LPCHAR,USHORT,USHORT) SHORT PASCAL CloseComm(SHORT) USHORT PASCAL EnableCommNotification(SHORT,USHORT,SHORT,SHORT) SHORT PASCAL BuildCommDCB(LPCHAR,LPCHAR) SHORT PASCAL GetCommState(SHORT,LPCHAR) SHORT PASCAL SetCommState(LPCHAR) SHORT PASCAL ReadComm(SHORT,LPCHAR,SHORT) SHORT PASCAL WriteComm(SHORT,LPCHAR,SHORT) ---- === At 01 JUN 1998 11:27AM Duane Pekse wrote: === Thanks a million for the info. I think I've got it now. Duane ---- === At 15 JUL 1998 02:19PM Mike Hyslop wrote: === Colin, Mike Hyslop here. I'm one of Duane Pekse's co-workers. A couple of months ago, you and he conducted an exchange of information concerning using OI to read and write to a com port. The project has since fallen into my hands. I have been attempting to use the code segment you sent Duane, but I am missing a key element. I need to see what an actual call to the COMM_ACCESS subroutine looks like. Specifically, what the COMMDATA argument looks like. Would yo be so kind as to send an example of a call to this subroutine, with the arguments included. Thanks, in advance. Best Regards, Mike Hyslop, P.Eng. Aldata Software Mgt. Inc. email:hyslopm@coynet.com [[https://www.revelation.com/revweb/oecgi4p.php/O4W_HANDOFF?DESTN=O4W_RUN_FORM&INQID=NONWORKS_READ&SUMMARY=1&KEY=B4A1249C06F7A6318525660F005B5F1B|View this thread on the forum...]]