From: Martin H. <mh...@us...> - 2005-09-30 11:12:09
|
Update of /cvsroot/opengtoolkit/serial/c_source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19855/c_source Modified Files: lvserial.c lvserial.def lvserial.h lvserial.rc Log Message: New functions to handle communication events. New ogComm function, most of them are wrappers around the lvComm function. These functions are using a labview handle (pointer to handle). Lots of imrovements when executing parallel operations on the same serial port. Index: lvserial.rc =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/lvserial.rc,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** lvserial.rc 23 Jul 2005 09:19:26 -0000 1.5 --- lvserial.rc 30 Sep 2005 11:11:59 -0000 1.6 *************** *** 54,59 **** VS_VERSION_INFO VERSIONINFO ! FILEVERSION 0,0,5,2 ! PRODUCTVERSION 0,0,5,2 FILEFLAGSMASK 0x17L #ifdef _DEBUG --- 54,59 ---- VS_VERSION_INFO VERSIONINFO ! FILEVERSION 1,0,1,6 ! PRODUCTVERSION 1,0,1,6 FILEFLAGSMASK 0x17L #ifdef _DEBUG *************** *** 72,81 **** VALUE "CompanyName", "MH-Systemtechnik, www.mhst.de" VALUE "FileDescription", "Serial Port API" ! VALUE "FileVersion", "0, 0, 5, 2" VALUE "InternalName", "lvserial" VALUE "LegalCopyright", "Martin Henz Systemtechnik, 2004" VALUE "OriginalFilename", "lvserial.dll" VALUE "ProductName", "Serial Port API" ! VALUE "ProductVersion", "0, 0, 5, 2" END END --- 72,81 ---- VALUE "CompanyName", "MH-Systemtechnik, www.mhst.de" VALUE "FileDescription", "Serial Port API" ! VALUE "FileVersion", "1, 0, 1, 6" VALUE "InternalName", "lvserial" VALUE "LegalCopyright", "Martin Henz Systemtechnik, 2004" VALUE "OriginalFilename", "lvserial.dll" VALUE "ProductName", "Serial Port API" ! VALUE "ProductVersion", "1, 0, 1, 6" END END Index: lvserial.def =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/lvserial.def,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** lvserial.def 12 Apr 2005 08:31:37 -0000 1.3 --- lvserial.def 30 Sep 2005 11:11:59 -0000 1.4 *************** *** 1,85 **** LIBRARY lvserial ! EXPORTS CommOpenPort ! EXPORTS CommClosePort ! EXPORTS CommClosePort2 ! EXPORTS CommCloseAll ! EXPORTS CommWrite ! EXPORTS CommWriteAndReceiveEcho ! EXPORTS CommRead ! EXPORTS CommBreak ! EXPORTS CommBuffer ! EXPORTS CommFlush ! EXPORTS CommStatus ! EXPORTS CommBytesAtPort ! EXPORTS CommModemStatus ! EXPORTS CommGetCTS ! EXPORTS CommGetDSR ! EXPORTS CommGetRING ! EXPORTS CommGetRLSD ! EXPORTS CommSetXOFF ! EXPORTS CommSetXON ! EXPORTS CommSetRTS ! EXPORTS CommClrRTS ! EXPORTS CommSetDTR ! EXPORTS CommClrDTR ! EXPORTS CommSetBreak ! EXPORTS CommClearBreak ! EXPORTS CommConfig ! EXPORTS CommFlowControl ! EXPORTS CommConfig ! EXPORTS CommTermination ! EXPORTS CommTermination2 ! EXPORTS CommWriteMode ! EXPORTS CommTimeout ! EXPORTS CommTimeout2 ! EXPORTS CommOptions ! EXPORTS CommLock ! EXPORTS CommUnLock ! EXPORTS CommSetUserData ! EXPORTS CommGetUserData ! EXPORTS CommListPorts ! EXPORTS CommFree ! EXPORTS CommFreePortList ! EXPORTS CommGetHandles ! EXPORTS CommGetPortName ! EXPORTS lvCommOpenPort ! EXPORTS lvCommClosePort ! EXPORTS lvCommClosePort2 ! EXPORTS lvCommCloseAll ! EXPORTS lvCommWrite ! EXPORTS lvCommWriteAndReceiveEcho ! EXPORTS lvCommRead ! EXPORTS lvCommBreak ! EXPORTS lvCommBuffer ! EXPORTS lvCommFlush ! EXPORTS lvCommStatus ! EXPORTS lvCommBytesAtPort ! EXPORTS lvCommModemStatus ! EXPORTS lvCommGetCTS ! EXPORTS lvCommGetDSR ! EXPORTS lvCommGetRING ! EXPORTS lvCommGetRLSD ! EXPORTS lvCommSetXOFF ! EXPORTS lvCommSetXON ! EXPORTS lvCommSetRTS ! EXPORTS lvCommClrRTS ! EXPORTS lvCommSetDTR ! EXPORTS lvCommClrDTR ! EXPORTS lvCommSetBreak ! EXPORTS lvCommClearBreak ! EXPORTS lvCommConfig ! EXPORTS lvCommFlowControl ! EXPORTS lvCommControl ! EXPORTS lvCommTermination ! EXPORTS lvCommTermination2 ! EXPORTS lvCommWriteMode ! EXPORTS lvCommTimeout ! EXPORTS lvCommTimeout2 ! EXPORTS lvCommOptions ! EXPORTS lvCommLock ! EXPORTS lvCommUnLock ! EXPORTS lvCommSetUserData ! EXPORTS lvCommGetUserData ! EXPORTS lvCommListPorts ! EXPORTS lvCommGetHandles ! EXPORTS lvCommGetPortName --- 1,153 ---- LIBRARY lvserial ! EXPORTS ! CommOpenPort ! CommClosePort ! CommClosePort2 ! CommCloseAll ! CommWrite ! CommWriteAndReceiveEcho ! CommRead ! CommBreak ! CommBuffer ! CommFlush ! CommStatus ! CommBytesAtPort ! CommModemStatus ! CommGetCTS ! CommGetDSR ! CommGetRING ! CommGetRLSD ! CommSetXOFF ! CommSetXON ! CommSetRTS ! CommClrRTS ! CommSetDTR ! CommClrDTR ! CommSetBreak ! CommClearBreak ! CommConfig ! CommFlowControl ! CommConfig ! CommTermination ! CommTermination2 ! CommWriteMode ! CommTimeout ! CommTimeout2 ! CommOptions ! CommLock ! CommUnLock ! CommSetUserData ! CommGetUserData ! CommSetUserDataBuffer ! CommGetUserDataBuffer ! CommListPorts ! CommFree ! CommFreePortList ! CommGetHandles ! CommGetPortName ! CommEnableEvent ! CommWaitForEvent ! CommDisableEvent ! CommSetEventChar ! CommTransmitChar ! CommSetDefaultConfig ! ! lvCommOpenPort ! lvCommClosePort ! lvCommClosePort2 ! lvCommCloseAll ! lvCommWrite ! lvCommWriteAndReceiveEcho ! lvCommRead ! lvCommBreak ! lvCommBuffer ! lvCommFlush ! lvCommStatus ! lvCommBytesAtPort ! lvCommModemStatus ! lvCommGetCTS ! lvCommGetDSR ! lvCommGetRING ! lvCommGetRLSD ! lvCommSetXOFF ! lvCommSetXON ! lvCommSetRTS ! lvCommClrRTS ! lvCommSetDTR ! lvCommClrDTR ! lvCommSetBreak ! lvCommClearBreak ! lvCommConfig ! lvCommFlowControl ! lvCommControl ! lvCommTermination ! lvCommTermination2 ! lvCommWriteMode ! lvCommTimeout ! lvCommTimeout2 ! lvCommOptions ! lvCommLock ! lvCommUnLock ! lvCommSetUserData ! lvCommGetUserData ! lvCommSetUserDataBuffer ! lvCommGetUserDataBuffer ! lvCommListPorts ! lvCommGetHandles ! lvCommGetPortName ! lvCommEnableEvent ! lvCommWaitForEvent ! lvCommDisableEvent ! lvCommSetEventChar ! lvCommTransmitChar ! lvCommSetDefaultConfig ! ! ogCommOpenPort ! ogCommClosePort ! ogCommClosePort2 ! ogCommCloseAll ! ogCommWrite ! ogCommWriteAndReceiveEcho ! ogCommRead ! ogCommBreak ! ogCommBuffer ! ogCommFlush ! ogCommStatus ! ogCommBytesAtPort ! ogCommModemStatus ! ogCommGetCTS ! ogCommGetDSR ! ogCommGetRING ! ogCommGetRLSD ! ogCommSetXOFF ! ogCommSetXON ! ogCommSetRTS ! ogCommClrRTS ! ogCommSetDTR ! ogCommClrDTR ! ogCommSetBreak ! ogCommClearBreak ! ogCommConfig ! ogCommFlowControl ! ogCommControl ! ogCommTermination ! ogCommTermination2 ! ogCommWriteMode ! ogCommTimeout ! ogCommTimeout2 ! ogCommOptions ! ogCommLock ! ogCommUnLock ! ogCommSetUserData ! ogCommGetUserData ! ogCommSetUserDataBuffer ! ogCommGetUserDataBuffer ! ogCommListPorts ! ogCommGetHandles ! ogCommGetPortName ! ogCommEnableEvent ! ogCommWaitForEvent ! ogCommDisableEvent ! ogCommSetEventChar ! ogCommTransmitChar ! ogCommSetDefaultConfig \ No newline at end of file Index: lvserial.h =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/lvserial.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** lvserial.h 23 Jul 2005 09:21:40 -0000 1.6 --- lvserial.h 30 Sep 2005 11:11:59 -0000 1.7 *************** *** 33,36 **** --- 33,37 ---- #include "pcre.h" + //internal data structure typedef struct { HANDLE hC; //the OS handle of the opened serial port *************** *** 54,65 **** unsigned long ulNOpened; //number of CommOpenPort calls for this port HANDLE hLock; //lock handle for external use HANDLE hInternalLock; //lock handle for internal use unsigned long ulUserData; //user specified data HANDLE hEvRead; //read event handle HANDLE hEvWrite; //write event handle } COMM, *PCOMM; ! #endif //LVSERIAL_COMPILE_LIBRARY #ifndef LV_LSTRARRAY #define LV_LSTRARRAY --- 55,75 ---- unsigned long ulNOpened; //number of CommOpenPort calls for this port HANDLE hLock; //lock handle for external use + HANDLE hReadLock; //read lock handle for internal use + HANDLE hWriteLock; //write lock handle for internal use HANDLE hInternalLock; //lock handle for internal use unsigned long ulUserData; //user specified data + char * pcUserData; //user data buffer + long lUserDataSize; //size of user data buffer HANDLE hEvRead; //read event handle HANDLE hEvWrite; //write event handle + OVERLAPPED osEvent; //overlapped structure for comm event monitoring + int fWaitOnEvent; //event monitoring actually waiting for an event + unsigned long ulEventMask; //location where to store an event } COMM, *PCOMM; ! #endif //#ifdef LVSERIAL_COMPILE_LIBRARY ! + //labview array of labview string handles #ifndef LV_LSTRARRAY #define LV_LSTRARRAY *************** *** 73,76 **** --- 83,88 ---- #endif + + //labview array of unsigned long numbers #ifndef LV_ULONGARRAY #define LV_ULONGARRAY *************** *** 84,100 **** #endif ! #endif //LVSERIAL_CONST_ONLY //serial port parity configuration ! #define COMM_PARITY_NONE 0 ! #define COMM_PARITY_ODD 1 ! #define COMM_PARITY_EVEN 2 ! #define COMM_PARITY_MARK 3 ! #define COMM_PARITY_SPACE 4 //serial port stop bit configuration ! #define COMM_ONESTOPBIT 0 ! #define COMM_ONE5STOPBITS 1 ! #define COMM_TWOSTOPBITS 2 //option flags for the CommFlush function --- 96,133 ---- #endif ! #endif //#ifndef LVSERIAL_CONST_ONLY ! ! ! //common serial port baud rates ! #define COMM_BR_110 110 ! #define COMM_BR_300 300 ! #define COMM_BR_600 600 ! #define COMM_BR_1200 1200 ! #define COMM_BR_2400 2400 ! #define COMM_BR_4800 4800 ! #define COMM_BR_9600 9600 ! #define COMM_BR_14400 14400 ! #define COMM_BR_19200 19200 ! #define COMM_BR_38400 38400 ! #define COMM_BR_56000 56000 ! #define COMM_BR_57600 57600 ! #define COMM_BR_115200 115200 ! #define COMM_BR_128000 128000 ! #define COMM_BR_256000 256000 ! //serial port parity configuration ! #define COMM_PARITY_NONE 0 // no parity ! #define COMM_PARITY_ODD 1 // odd parity ! #define COMM_PARITY_EVEN 2 // even parity ! #define COMM_PARITY_MARK 3 // mark parity ! #define COMM_PARITY_SPACE 4 // space parity ! //serial port stop bit configuration ! #define COMM_ONESTOPBIT 0 // one stop bit ! #define COMM_ONE5STOPBITS 1 // 1.5 stop bits ! #define COMM_TWOSTOPBITS 2 // two stop bits ! //option flags for the CommFlush function *************** *** 104,107 **** --- 137,141 ---- #define COMM_FLUSH_RXCLEAR 0x0008 // Kill the typeahead buffer if there. + //serial port error flags #define COMM_ERRF_RXOVER 0x0001 // Receive Queue overflow *************** *** 117,205 **** #define COMM_ERRF_MODE 0x8000 // Requested mode unsupported //serial port status flags #define COMM_STAT_CTS 0x0001 #define COMM_STAT_DSR 0x0002 #define COMM_STAT_RLSD 0x0004 #define COMM_STAT_XOFFHOLD 0x0008 #define COMM_STAT_XOFFSENT 0x0010 #define COMM_STAT_EOF 0x0020 #define COMM_STAT_TXIM 0x0040 //serial port modem status flags ! #define COMM_MSTAT_CTS_ON ((DWORD)0x0010) ! #define COMM_MSTAT_DSR_ON ((DWORD)0x0020) ! #define COMM_MSTAT_RING_ON ((DWORD)0x0040) ! #define COMM_MSTAT_RLSD_ON ((DWORD)0x0080) //serial port flow control configuration ! #define COMM_FLOW_NONE 0 ! #define COMM_FLOW_XONXOFF 1 ! #define COMM_FLOW_RTSCTS 2 ! #define COMM_FLOW_DTRDSR 3 //serial port advanced control flags (used for CommControl) #define COMM_CTRL_OUTXCTSFLOW 0x00000001 #define COMM_CTRL_OUTXDSRFLOW 0x00000002 #define COMM_CTRL_DTRENABLE 0x00000004 #define COMM_CTRL_DTRHANDSHAKE 0x00000008 #define COMM_CTRL_DSRSENSITIVITY 0x00000010 #define COMM_CTRL_TXCONTINUEONXOFF 0x00000020 #define COMM_CTRL_OUTX 0x00000040 #define COMM_CTRL_INX 0x00000080 #define COMM_CTRL_ERRORCHAR 0x00000100 #define COMM_CTRL_NULL 0x00000200 #define COMM_CTRL_RTSENABLE 0x00000400 #define COMM_CTRL_RTSHANDSHAKE 0x00000800 #define COMM_CTRL_RTSTOGGLE 0x00001000 #define COMM_CTRL_ABORTONERROR 0x00002000 //serial port read termination modes ! #define COMM_TERM_NONE 0 ! #define COMM_TERM_CHAR 1 ! #define COMM_TERM_STRING 2 ! #define COMM_TERM_REGEX 3 //serial port write mode ! #define COMM_WRITE_NORMAL 0 ! #define COMM_WRITE_STX 1 ! #define COMM_WRITE_ETX 2 #define COMM_WRITE_STXETX (COMM_WRITE_STX | COMM_WRITE_ETX) //serial port error codes ! #define COMM_MIN_ERROR -65100 ! #define COMM_MAX_ERROR -65060 #define COMM_WARN_NYBTES 65060 #define COMM_WARN_TERMCHAR 65061 #define COMM_SUCCESS 0 #define COMM_ERR_NYBTES -65060 #define COMM_ERR_TERMCHAR -65061 #define COMM_ERR_INVALIDLENGTH -65062 #define COMM_ERR_NOTIMPLEMENTED -65063 #define COMM_ERR_ACCESS -65064 #define COMM_ERR_OVERFLOW -65065 #define COMM_ERR_FRAMING -65066 #define COMM_ERR_PARITY -65067 #define COMM_ERR_TIMEOUT -65068 #define COMM_ERR_HANDLE -65069 #define COMM_ERR_SYSTEM -65070 #define COMM_ERR_RESOURCE -65071 #define COMM_ERR_ARGUMENT -65072 #define COMM_ERR_OUTOFMEMORY -65073 #define COMM_ERR_ABORTED -65074 #define COMM_ERR_RESERVED1 -65075 #define COMM_ERR_LOCKTIMEOUT -65076 #define COMM_ERR_NOTLOCKED -65077 #define COMM_ERR_WRITE -65078 #define COMM_ERR_OVERRUN -65079 #define COMM_ERR_TXBUFFERFULL -65080 #define COMM_ERR_WRONGECHO -65081 #define COMM_ERR_BREAK -65082 #define COMM_ERR_DNS -65083 #define COMM_ERR_IOE -65084 #define COMM_ERR_MODE -65085 #define COMM_ERR_OOP -65086 #define COMM_ERR_PTO -65087 #ifndef LVSERIAL_CONST_ONLY --- 151,412 ---- #define COMM_ERRF_MODE 0x8000 // Requested mode unsupported + //serial port status flags + + //Indicates whether transmission is waiting for the CTS (clear-to-send) + //signal to be sent. If this flag is true, transmission is waiting. #define COMM_STAT_CTS 0x0001 + + //Indicates whether transmission is waiting for the DSR (data-set-ready) + //signal to be sent. If this flag is set, transmission is waiting. #define COMM_STAT_DSR 0x0002 + + //Indicates whether transmission is waiting for the RLSD (receive-line- + //signal-detect) signal to be sent. If this flag is set, transmission is + //waiting. #define COMM_STAT_RLSD 0x0004 + + //Indicates whether transmission is waiting because the XOFF character was + //received. If this flag is set, transmission is waiting. #define COMM_STAT_XOFFHOLD 0x0008 + + //Indicates whether transmission is waiting because the XOFF character was + //transmitted. If this flag is set, transmission is waiting. Transmission + //halts when the XOFF character is transmitted to a system that takes the + //next character as XON, regardless of the actual character. #define COMM_STAT_XOFFSENT 0x0010 + + //Indicates whether the end-of-file (EOF) character has been received. If + //this flag is set, the EOF character has been received. This flag is only + //valid if a single termination character is specified. #define COMM_STAT_EOF 0x0020 + + //If this flag is set, there is a character queued for transmission that + //has come to the communications device by way of the CommTransmitChar + //function. The communications device transmits such a character ahead of + //other characters in the device's output buffer. #define COMM_STAT_TXIM 0x0040 + //serial port modem status flags ! #define COMM_MSTAT_CTS_ON ((DWORD)0x0010) // CTS signaled ! #define COMM_MSTAT_DSR_ON ((DWORD)0x0020) // DSR signaled ! #define COMM_MSTAT_RING_ON ((DWORD)0x0040) // RING signaled ! #define COMM_MSTAT_RLSD_ON ((DWORD)0x0080) // RLSD signaled ! //serial port flow control configuration ! #define COMM_FLOW_NONE 0 // no flow control ! #define COMM_FLOW_XONXOFF 1 // XON/XOFF ! #define COMM_FLOW_RTSCTS 2 // RTS/CTS ! #define COMM_FLOW_DTRDSR 3 // DTR/DSR ! //serial port advanced control flags (used for CommControl) + + //Indicates whether the CTS (clear-to-send) signal is monitored for output + //flow control. If this flag is used and CTS is turned off, output is + //suspended until CTS is sent again. #define COMM_CTRL_OUTXCTSFLOW 0x00000001 + + //Indicates whether the DSR (data-set-ready) signal is monitored for + //output flow control. If this flag is used and DSR is turned off, + //output is suspended until DSR is sent again. #define COMM_CTRL_OUTXDSRFLOW 0x00000002 + + //Enables the DTR line when the device is opened and leaves it on. #define COMM_CTRL_DTRENABLE 0x00000004 + + //Enables DTR handshaking. If handshaking is enabled, it is an error + //for the application to adjust the line. #define COMM_CTRL_DTRHANDSHAKE 0x00000008 + + //Indicates whether the communications driver is sensitive to the + //state of the DSR signal. If this flag is set, the driver ignores any + //bytes received, unless the DSR modem input line is high. #define COMM_CTRL_DSRSENSITIVITY 0x00000010 + + //Indicates whether transmission stops when the input buffer is full and + //the driver has transmitted the XoffChar character. If this member is + //TRUE, transmission continues after the input buffer has come within + //XoffLim bytes of being full and the driver has transmitted the XoffChar + //character to stop receiving bytes. If this flag is set, transmission + //does not continue until the input buffer is within XonLim bytes of being + //empty and the driver has transmitted the XonChar character to resume + //reception. #define COMM_CTRL_TXCONTINUEONXOFF 0x00000020 + + //Indicates whether XON/XOFF flow control is used during transmission. If + //this flag is set, transmission stops when the XoffChar character is + //received and starts again when the XonChar character is received. #define COMM_CTRL_OUTX 0x00000040 + + //Indicates whether XON/XOFF flow control is used during reception. If + //this flag is used, the XoffChar character is sent when the input buffer + //comes within XoffLim bytes of being full, and the XonChar character is + //sent when the input buffer comes within XonLim bytes of being empty. #define COMM_CTRL_INX 0x00000080 + + //Indicates whether bytes received with parity errors are replaced with + //the character specified by the ErrorChar member. If this flag is set + //and the fParity flag is set, replacement occurs. #define COMM_CTRL_ERRORCHAR 0x00000100 + + //Indicates whether null bytes are discarded. If this flag is set, null + //bytes are discarded when received. #define COMM_CTRL_NULL 0x00000200 + + //Enables the RTS line when the device is opened and leaves it on. #define COMM_CTRL_RTSENABLE 0x00000400 + + //Enables RTS handshaking. The driver raises the RTS line when the + //"type-ahead" (input) buffer is less than one-half full and lowers the + //RTS line when the buffer is more than three-quarters full. If handshaking + //is enabled, it is an error for the application to adjust the line. #define COMM_CTRL_RTSHANDSHAKE 0x00000800 + + //Windows NT/2000/XP: Specifies that the RTS line will be high if bytes are + //available for transmission. After all buffered bytes have been sent, the + //RTS line will be low. #define COMM_CTRL_RTSTOGGLE 0x00001000 + + //Indicates whether read and write operations are terminated if an error + //occurs. If this flag is set, the driver terminates all read and write + //operations with an error status if an error occurs. #define COMM_CTRL_ABORTONERROR 0x00002000 + //serial port read termination modes ! #define COMM_TERM_NONE 0 //no termination ! #define COMM_TERM_CHAR 1 //one or more characters ! #define COMM_TERM_STRING 2 //termination string ! #define COMM_TERM_REGEX 3 //regular expression ! #define COMM_TERM_STRARRAY 4 //string array (not implemented) ! //serial port write mode ! #define COMM_WRITE_NORMAL 0 //normal write mode ! #define COMM_WRITE_STX 1 //write start string ! #define COMM_WRITE_ETX 2 //write end string #define COMM_WRITE_STXETX (COMM_WRITE_STX | COMM_WRITE_ETX) + + //communication events + #define COMM_EV_NONE 0x0000 // no event + #define COMM_EV_RXCHAR 0x0001 // Any Character received + #define COMM_EV_RXFLAG 0x0002 // Received certain character + #define COMM_EV_TXEMPTY 0x0004 // Transmitt Queue Empty + #define COMM_EV_CTS 0x0008 // CTS changed state + #define COMM_EV_DSR 0x0010 // DSR changed state + #define COMM_EV_RLSD 0x0020 // RLSD changed state + #define COMM_EV_BREAK 0x0040 // BREAK received + #define COMM_EV_ERR 0x0080 // Line status error occurred + #define COMM_EV_RING 0x0100 // Ring signal detected + #define COMM_EV_PERR 0x0200 // Printer error occured + #define COMM_EV_RX80FULL 0x0400 // Receive buffer is 80 percent full + #define COMM_EV_EVENT1 0x0800 // Provider specific event 1 + #define COMM_EV_EVENT2 0x1000 // Provider specific event 2 + + //serial port error codes ! #define COMM_MIN_ERROR -65100 // min. error code ! #define COMM_MAX_ERROR -65060 // max. error code + //The number of bytes transferred is equal to the specified maximum. #define COMM_WARN_NYBTES 65060 + + //One of the termination characters received. #define COMM_WARN_TERMCHAR 65061 + + //success #define COMM_SUCCESS 0 + + //The number of bytes transferred is equal to the specified maximum. #define COMM_ERR_NYBTES -65060 + + //Termination character not received. #define COMM_ERR_TERMCHAR -65061 + + //Invalid length or byte count specified. #define COMM_ERR_INVALIDLENGTH -65062 + + //The given operation is not implemented. #define COMM_ERR_NOTIMPLEMENTED -65063 + + //The device is valid, but you cannot currently access it. #define COMM_ERR_ACCESS -65064 + + //An input buffer overflow has occurred. There is either no room in the + //input buffer, or a character was received after the end-of-file (EOF) + //character. #define COMM_ERR_OVERFLOW -65065 + + //Framing error occurred during transfer. #define COMM_ERR_FRAMING -65066 + + //Parity error occurred during transfer. #define COMM_ERR_PARITY -65067 + + //Timeout expired. #define COMM_ERR_TIMEOUT -65068 + + //The given device reference is invalid. #define COMM_ERR_HANDLE -65069 + + //Unknown system error. #define COMM_ERR_SYSTEM -65070 + + //Device not found. #define COMM_ERR_RESOURCE -65071 + + //Argument error. #define COMM_ERR_ARGUMENT -65072 + + //Out of memory. #define COMM_ERR_OUTOFMEMORY -65073 + + //Operation aborted. #define COMM_ERR_ABORTED -65074 + + //Unable to create the semaphore. #define COMM_ERR_RESERVED1 -65075 + + //Can't lock the serial port (timeout). #define COMM_ERR_LOCKTIMEOUT -65076 + + //The serial port is not locked. #define COMM_ERR_NOTLOCKED -65077 + + //The system was unable to write the specified number of bytes. #define COMM_ERR_WRITE -65078 + + //A character-buffer overrun has occurred. The next character is lost. #define COMM_ERR_OVERRUN -65079 + + //The application tried to transmit a character, but the output buffer was full. #define COMM_ERR_TXBUFFERFULL -65080 + + //The received character is not equal to the transmitted character. #define COMM_ERR_WRONGECHO -65081 + + //The hardware detected a break condition. #define COMM_ERR_BREAK -65082 + + //A parallel device is not selected. #define COMM_ERR_DNS -65083 + + //An I/O error occurred during communications with the device. #define COMM_ERR_IOE -65084 + + //The requested mode is not supported, or the handle is invalid. #define COMM_ERR_MODE -65085 + + //A parallel device signaled that it is out of paper. #define COMM_ERR_OOP -65086 + + //A time-out occurred on a parallel device. #define COMM_ERR_PTO -65087 + #ifndef LVSERIAL_CONST_ONLY *************** *** 208,211 **** --- 415,419 ---- #endif + //function prototypes *************** *** 264,269 **** HANDLE hComm, unsigned short usFlowControl, ! unsigned char cXOFFCharacter, ! unsigned char cXONCharacter); long CommControl( HANDLE hComm, --- 472,477 ---- HANDLE hComm, unsigned short usFlowControl, ! unsigned char ucXOFFCharacter, ! unsigned char ucXONCharacter); long CommControl( HANDLE hComm, *************** *** 271,277 **** unsigned short usXonLim, unsigned short usXoffLim, ! char cXonChar, ! char cXoffChar, ! char cErrorChar); long CommTermination( HANDLE hComm, --- 479,485 ---- unsigned short usXonLim, unsigned short usXoffLim, ! unsigned char ucXonChar, ! unsigned char ucXoffChar, ! unsigned char ucErrorChar); long CommTermination( HANDLE hComm, *************** *** 304,307 **** --- 512,517 ---- long CommSetUserData(HANDLE hComm, unsigned long ulUserData); long CommGetUserData(HANDLE hComm, unsigned long *pulUserData); + long CommSetUserDataBuffer(HANDLE hComm, char *pcUserData, long lUserDataSize); + long CommGetUserDataBuffer(HANDLE hComm, char *pcUserData, long *plUserDataSize); long CommListPorts(char ***ports); void CommFree(LPVOID ptr); *************** *** 309,312 **** --- 519,528 ---- long CommGetHandles(HANDLE **ppHandles, int *piSize); long CommGetPortName(HANDLE hComm, char **ppszName, char **ppszOriginal); + long CommEnableEvent(HANDLE hComm, unsigned long ulEventMask); + long CommWaitForEvent(HANDLE hComm, unsigned long ulTimeout, unsigned long *pulEventMask); + long CommDisableEvent(HANDLE hComm); + long CommSetEventChar(HANDLE hComm, unsigned char ucEventChar); + long CommTransmitChar(HANDLE hComm, unsigned char ucChar); + long CommSetDefaultConfig(char *pszPort, char *pszOptions); /* -----------------------------------------------------------------------------------*/ *************** *** 377,383 **** unsigned short usXonLim, unsigned short usXoffLim, ! char cXonChar, ! char cXoffChar, ! char cErrorChar, pErrC pError); void lvCommTermination( --- 593,599 ---- unsigned short usXonLim, unsigned short usXoffLim, ! unsigned char ucXonChar, ! unsigned char ucXoffChar, ! unsigned char ucErrorChar, pErrC pError); void lvCommTermination( *************** *** 414,420 **** void lvCommSetUserData(HANDLE hComm, unsigned long ulUserData, pErrC pError); void lvCommGetUserData(HANDLE hComm, unsigned long *pulUserData, pErrC pError); void lvCommListPorts(LStrArrayHandle *phalsPorts, pErrC pError); ! void lvCommGetHandles(ULongArrayHandle *haulHandles, pErrC pError); void lvCommGetPortName(HANDLE hComm, LStrHandle shName, LStrHandle shOriginal, pErrC pError); #if defined(__cplusplus) || defined(__cplusplus__) --- 630,764 ---- void lvCommSetUserData(HANDLE hComm, unsigned long ulUserData, pErrC pError); void lvCommGetUserData(HANDLE hComm, unsigned long *pulUserData, pErrC pError); + void lvCommSetUserDataBuffer(HANDLE hComm, LStrHandle shUserData, pErrC pError); + void lvCommGetUserDataBuffer(HANDLE hComm, LStrHandle shUserData, pErrC pError); void lvCommListPorts(LStrArrayHandle *phalsPorts, pErrC pError); ! void lvCommGetHandles(ULongArrayHandle *phaulHandles, pErrC pError); void lvCommGetPortName(HANDLE hComm, LStrHandle shName, LStrHandle shOriginal, pErrC pError); + void lvCommEnableEvent(HANDLE hComm, unsigned long ulEventMask, pErrC pError); + void lvCommWaitOnEvent(HANDLE hComm, unsigned long *pulEventMask, pErrC pError); + void lvCommEnableEvent(HANDLE hComm, unsigned long ulEventMask, pErrC pError); + void lvCommWaitForEvent(HANDLE hComm, unsigned long ulTimeout, unsigned long *pulEventMask, pErrC pError); + void lvCommDisableEvent(HANDLE hComm, pErrC pError); + void lvCommSetEventChar(HANDLE hComm, unsigned char ucEventChar, pErrC pError); + void lvCommTransmitChar(HANDLE hComm, unsigned char ucChar, pErrC pError); + void lvCommSetDefaultConfig(LStrHandle shPort, LStrHandle shOptions, pErrC pError); + + /* -----------------------------------------------------------------------------------*/ + + void ogCommOpenPort(PHANDLE phComm, LStrHandle shPort, LVBoolean *plfDuplicate, pErrC pError); + void ogCommClosePort(PHANDLE phComm, pErrC pError); + void ogCommClosePort2(PHANDLE phComm, LVBoolean *plfCloseAll, pErrC pError); + void ogCommCloseAll(pErrC pError); + void ogCommWrite( + PHANDLE phComm, + LStrHandle shBuffer, + unsigned long * pulBytesWritten, + pErrC pError); + void ogCommWriteAndReceiveEcho( + PHANDLE phComm, + LStrHandle shWriteBuffer, + unsigned long * pulBytesWritten, + LStrHandle shReadBuffer, + unsigned long * pulBytesRead, + LVBoolean *plfStopIfNotEqual, + pErrC pError); + void ogCommRead( + PHANDLE phComm, + LStrHandle shBuffer, + unsigned long ulBytesToRead, + unsigned long * pulBytesRead, + pErrC pError); + void ogCommBreak(PHANDLE phComm, unsigned long ulMilliseconds, pErrC pError); + void ogCommBuffer(PHANDLE phComm, unsigned long ulInQueueSize, unsigned long ulOutQueueSize, pErrC pError); + void ogCommFlush(PHANDLE phComm, unsigned long ulFlags, pErrC pError); + void ogCommStatus( + PHANDLE phComm, + unsigned long * pulErrorFlags, + unsigned long * pulStatusFlags, + unsigned long * pulInQueue, + unsigned long * pulOutQueue, + pErrC pError); + void ogCommBytesAtPort(PHANDLE phComm, unsigned long * pulBytesAtPort, pErrC pError); + void ogCommModemStatus(PHANDLE phComm, unsigned long * pulModemStatus, pErrC pError); + void ogCommGetCTS(PHANDLE phComm, LVBoolean *plfCTS, pErrC pError); + void ogCommGetDSR(PHANDLE phComm, LVBoolean *plfDSR, pErrC pError); + void ogCommGetRING(PHANDLE phComm, LVBoolean *plfRING, pErrC pError); + void ogCommGetRLSD(PHANDLE phComm, LVBoolean *plfRLSD, pErrC pError); + void ogCommSetXOFF(PHANDLE phComm, pErrC pError); + void ogCommSetXON(PHANDLE phComm, pErrC pError); + void ogCommSetRTS(PHANDLE phComm, pErrC pError); + void ogCommClrRTS(PHANDLE phComm, pErrC pError); + void ogCommSetDTR(PHANDLE phComm, pErrC pError); + void ogCommClrDTR(PHANDLE phComm, pErrC pError); + void ogCommSetBreak(PHANDLE phComm, pErrC pError); + void ogCommClearBreak(PHANDLE phComm, pErrC pError); + void ogCommConfig( + PHANDLE phComm, + unsigned long ulBaudRate, + unsigned short usDataBits, + unsigned short usParity, + unsigned short usStopBits, + pErrC pError); + void ogCommFlowControl( + PHANDLE phComm, + unsigned short usFlowControl, + unsigned char ucXOFFCharacter, + unsigned char ucXONCharacter, + pErrC pError); + void ogCommControl( + PHANDLE phComm, + unsigned long lFlags, + unsigned short usXonLim, + unsigned short usXoffLim, + unsigned char ucXonChar, + unsigned char ucXoffChar, + unsigned char ucErrorChar, + pErrC pError); + void ogCommTermination( + PHANDLE phComm, + LVBoolean *plfTermCharEnable, + LStrHandle shTermCharacter, + pErrC pError); + void ogCommTermination2( + PHANDLE phComm, + long lTerminationMode, + LStrHandle shTermination, + pErrC pError); + void ogCommWriteMode( + PHANDLE phComm, + long lWriteMode, + LStrHandle shStartOfTransmission, + LStrHandle shEndOfTransmission, + pErrC pError); + void ogCommTimeout( + PHANDLE phComm, + unsigned long ulTimeout, + pErrC pError); + void ogCommTimeout2( + PHANDLE phComm, + unsigned long ulReadIntervalTimeout, + unsigned long ulReadTotalTimeoutMultiplier, + unsigned long ulReadTotalTimeoutConstant, + unsigned long ulWriteTotalTimeoutMultiplier, + unsigned long ulWriteTotalTimeoutConstant, + pErrC pError); + void ogCommOptions(PHANDLE phComm, LStrHandle shOptions, pErrC pError); + void ogCommLock(PHANDLE phComm, unsigned long ulTimeout, pErrC pError); + void ogCommUnLock(PHANDLE phComm, pErrC pError); + void ogCommSetUserData(PHANDLE phComm, unsigned long ulUserData, pErrC pError); + void ogCommGetUserData(PHANDLE phComm, unsigned long *pulUserData, pErrC pError); + void ogCommSetUserDataBuffer(PHANDLE phComm, LStrHandle shUserData, pErrC pError); + void ogCommGetUserDataBuffer(PHANDLE phComm, LStrHandle shUserData, pErrC pError); + void ogCommListPorts(LStrArrayHandle *phalsPorts, pErrC pError); + void ogCommGetHandles(ULongArrayHandle hapulHandles, pErrC pError); + void ogCommGetPortName(PHANDLE phComm, LStrHandle shName, LStrHandle shOriginal, pErrC pError); + void ogCommEnableEvent(PHANDLE phComm, unsigned long ulEventMask, pErrC pError); + void ogCommWaitOnEvent(PHANDLE phComm, unsigned long *pulEventMask, pErrC pError); + void ogCommEnableEvent(PHANDLE phComm, unsigned long ulEventMask, pErrC pError); + void ogCommWaitForEvent(PHANDLE phComm, unsigned long ulTimeout, unsigned long *pulEventMask, pErrC pError); + void ogCommDisableEvent(PHANDLE phComm, pErrC pError); + void ogCommSetEventChar(PHANDLE phComm, unsigned char ucEventChar, pErrC pError); + void ogCommTransmitChar(PHANDLE phComm, unsigned char ucChar, pErrC pError); + void ogCommSetDefaultConfig(LStrHandle shPort, LStrHandle shOptions, pErrC pError); #if defined(__cplusplus) || defined(__cplusplus__) *************** *** 422,424 **** #endif ! #endif //LVSERIAL_CONST_ONLY --- 766,768 ---- #endif ! #endif // #ifndef LVSERIAL_CONST_ONLY Index: lvserial.c =================================================================== RCS file: /cvsroot/opengtoolkit/serial/c_source/lvserial.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** lvserial.c 28 Aug 2005 13:26:55 -0000 1.2 --- lvserial.c 30 Sep 2005 11:11:59 -0000 1.3 *************** *** 1,3 **** ! /* lvserial.cpp * * Serial Port API --- 1,3 ---- ! /* lvserial.c * * Serial Port API *************** *** 29,41 **** #include <crtdbg.h> [...6221 lines suppressed...] + lvCommTransmitChar(*phComm, ucChar, pError); + } + + /* ogCommSetDefaultConfig + * + * The ogCommSetDefaultConfig function sets the default configuration for + * a communications device. + * + * parameter + * shPort serial port name + * shOptions options string (see mode command) + * + * return + * error code + */ + void ogCommSetDefaultConfig(LStrHandle shPort, LStrHandle shOptions, pErrC pError) + { + lvCommSetDefaultConfig(shPort, shOptions, pError); + } \ No newline at end of file |