// // File Name: CprApi.h // Description: Header file for the CPR SDK. // Version: 4.3.0.2 // Copyright (C): 2005 - 2008 // #ifndef __CPRAPI_H__ #define __CPRAPI_H__ #define MAX_PORTS 256 #define ID_LEN 4 #define MAC_LEN 6 #define IP_LEN 16 #define IP_MAC_HOST_LEN 64 #define SSID_LEN 40 #define MAX_AES_KEY_LEN 32 #define MAX_INTERFACES 100 #define MAX_SERVICES 8 #define NUM_COM_ULONGS 8 #define CPR_OK 0 #define CPR_INVALID_ARGUMENT (-1) #define CPR_UNKNOWN_EXCEPTION (-2) #define CPR_INSUFFICIENT_RESOURCES (-3) #define CPR_NO_ADAPTERS_FOUND (-4) #define CPR_NO_DEVICES_FOUND (-5) #define CPR_NO_DRIVER_FOUND (-6) #define CPR_PORT_NOT_FOUND (-7) #define CPR_PORT_KEY_NOT_FOUND (-8) #define CPR_NO_DEVICE_PARAMETERS_FOUND (-9) #define CPR_PORT_NAME_NOT_FOUND (-10) #define CPR_EXT_PORT_INFO_NOT_FOUND (-11) #define CPR_REGISTRY_SAVE_ERROR (-12) #define CPR_DRIVER_OPEN_FAILED (-13) #define CPR_DRIVER_COMM_FAILED (-14) #define CPR_DRIVER_CLOSE_FAILED (-15) #define CPR_NO_EVENT_LOG (-16) #define CPR_BUFFER_TOO_SMALL (-17) #define CPR_DEVICE_NOT_FOUND (-18) #define CPR_CPC_FILE_OPEN_ERROR (-19) #define CPR_CPC_INVALID_CPC_FILE (-20) #define CPR_CPC_FILE_WRITE_ERROR (-21) #define CPR_CPC_FILE_READ_ERROR (-22) #define CPR_CPC_FILE_PARSE_ERROR (-23) #define CPR_INVALID_RANGE (-24) #define CPR_PORT_ALREADY_EXISTS (-25) #define CPR_INVALID_PORT_NUMBER (-26) #define CPR_ERROR_OPENING_LOGGING_REGISTRY (-27) #define CPR_ERROR_READING_LOGGING_REGISTRY (-28) #define CPR_ERROR_SAVING_LOGGING_REGISTRY (-29) #define CPR_ERROR_CLASS_INSTANCE_NOT_FOUND (-30) #define CPR_ERROR_PORT_IS_OPEN (-31) #define CPR_DATA_INCOMPLETE (-32) #define CPR_LAST_ERROR (-32) typedef enum CPR_NET_FW_IP_PROTOCOL_ { CPR_NET_FW_IP_PROTOCOL_TCP = 6, CPR_NET_FW_IP_PROTOCOL_UDP = 17 } CPR_NET_FW_IP_PROTOCOL; typedef struct _CPR_SERVICE { int Type; int Port; // TCP Port of device server WCHAR Address[IP_MAC_HOST_LEN]; // IP Address, MAC Address // or Host Name of device server. } CPR_SERVICE, *PCPR_SERVICE; // Define Interface reference/dereference routines for // Interfaces exported by IRP_MN_QUERY_INTERFACE typedef struct _PortAssoc { ULONG portNumber; WCHAR portName[8]; } PortAssoc, *PPortAssoc; typedef struct _PortMap { ULONG numPorts; PortAssoc Map[MAX_PORTS+1]; // port 0 is invalid, ones based } PortMap, *PPortMap; // NIY = Not Implemented Yet typedef struct _PORT_INFO { ULONG portNumber; // 1 to 256 WCHAR portName[8]; // Read Only ULONG AES; // 0 or 1 (NIY) unsigned char AESKey[MAX_AES_KEY_LEN];// (NIY) ULONG AESKeyLength; // (NIY) ULONG AutoReconErr; // 0 or 1 (NIY) ULONG AutoReconPeer; // 0 or 1 (NIY) ULONG CnTmo; // Connection Timeout in seconds ULONG NoDiscon; // 0 or 1 (NIY) ULONG ReconLimit; // (NIY) ULONG UseRFC2217; // 0 or 1 ULONG DtrConnection; // See defines below #define DTR_TO_DCD_DSR_ACTIVE 0 #define DTR_TO_DCD_DSR_INACTIVE 1 #define DTR_TO_DSR_DCD_ACTIVE 2 #define DTR_TO_DSR_DCD_INACTIVE 3 #define DTR_TO_DSR_AND_DCD 4 #define DTR_TO_NONE 5 ULONG WaitOnWrite; // 0 or 1 ULONG BufferWrites; // 0 or 1 ULONG TransmitEmpty; #define TRANSMIT_EMPTY_CPR 0 // CPR to Device Server #define TRANSMIT_EMPTY_DEVICE 1 // Device Server to Device ULONG ListenMode; // See defines below #define LISTEN_MODE_NONE 0 // No Listen Mode #define LISTEN_MODE_ONCE 1 // Listen, connect, when device // server disconnects, don't // listen again. #define LISTEN_MODE_AUTO 2 // Listen, connect, when // device server disconnects, // then listen again ULONG KeepAliveOnOff; // on=1, off=0 ULONG KeepAliveTime; // Sends out KeepAlives every // KeepAliveTime msecs. ULONG KeepAliveInterval; // After a failed KeepAlive // then sends out every // KeepAliveInterval msecs. ULONG NumServices; // Number of Services CPR_SERVICE Services[MAX_SERVICES]; // not to exceed MAX_SERVICES. } PortInfo, *PPortInfo; #define CPR_COM_STATUS_CLOSED 0 #define CPR_COM_STATUS_OPENING 1 #define CPR_COM_STATUS_OPEN 2 #define CPR_COM_STATUS_CLOSING 3 #define CPR_COM_STATUS_CLEANUP 4 #define CPR_COM_STATUS_ERROR 5 #define CPR_COM_STATUS_ADD 6 // Com Port has just been added #define CPR_COM_STATUS_REMOVE 7 // Com Port has just been removed #define CPR_NETWORK_STATUS_DISCONNECTED 0 #define CPR_NETWORK_STATUS_CONNECTING 1 #define CPR_NETWORK_STATUS_RECONNECTING 2 #define CPR_NETWORK_STATUS_CONNECTED 3 #define CPR_NETWORK_STATUS_LISTENING 4 // Listening in Listen Mode #define CPR_NETWORK_STATUS_NEGOTIATING 5 // RFC2217 Negotiations #define CPR_NETWORK_STATUS_VERIFYING 6 // Verifying if Lantronix Device #define CPR_NETWORK_STATUS_ERROR 7 typedef struct _PORT_STATUS { ULONG portNumber; // Com Port Number USHORT status; // Com Port Status USHORT networkStatus; // Status between CPR and device server int Port; // TCP port of remote connection WCHAR Address[IP_MAC_HOST_LEN]; // IP Address, Mac Address // or Host Name of remote connection } PortStatus, *PPortStatus; typedef struct _CPR_PORT_DEVICE { char id[ID_LEN]; UCHAR macAddr[MAC_LEN]; } CprPortDevice, *PCprPortDevice; typedef enum _CPR_TOPOLOGY { CPR_ADHOC = 0, CPR_INFRASTRUCTURE = 1 } CPR_TOPOLOGY; typedef enum _CPR_ENCRYPTION { CPR_NONE = 0, CPR_WEP = 1, CPR_WPA = 2, CPR_TKIP = 3 } CPR_ENCRYPTION; typedef struct _CprSignalStrength { unsigned char macAddr[MAC_LEN]; // MAC address of the wireless device int channel; // Channel used for communication int signalStrength; // Signal strength in dBm CPR_TOPOLOGY topology; // Topology used by the wireless device CPR_ENCRYPTION encryption; // Encyrption used by the wireless device char SSID[SSID_LEN]; // The SSID of the access point the // wireless device is connected to. } CprSignalStrength, *PCprSignalStrength; /////////////////////////////////////////////////////////////////////////////////////////////////// // EVENT LOGGING /////////////////////////////////////////////////////////////////////////////////////////////////// #define CPR_EVENT_MSG_SIZE 128 #define CPR_EVENT_TYPE_NONE 0x00000000 #define CPR_EVENT_TYPE_OPEN 0x00000001 #define CPR_EVENT_TYPE_CLOSE 0x00000002 #define CPR_EVENT_TYPE_READ 0x00000004 #define CPR_EVENT_TYPE_WRITE 0x00000008 #define CPR_EVENT_TYPE_CONNECT 0x00000010 #define CPR_EVENT_TYPE_DISCONNECT 0x00000020 #define CPR_EVENT_TYPE_RECONNECTING 0x00000040 #define CPR_EVENT_TYPE_RECONNECTED 0x00000080 #define CPR_EVENT_TYPE_WRITE_TIMEOUT 0x00000100 #define CPR_EVENT_TYPE_XON 0x00000200 #define CPR_EVENT_TYPE_XOFF 0x00000400 #define CPR_EVENT_TYPE_RFC2217 0x00000800 // _WAIT_ Events added 5/7/07 by DAG #define CPR_EVENT_TYPE_WAIT_RXCHAR 0x00001000 #define CPR_EVENT_TYPE_WAIT_RXFLAG 0x00002000 #define CPR_EVENT_TYPE_WAIT_TXEMPTY 0x00004000 #define CPR_EVENT_TYPE_WAIT_CTS 0x00008000 #define CPR_EVENT_TYPE_WAIT_DSR 0x00010000 #define CPR_EVENT_TYPE_WAIT_RLSD 0x00020000 #define CPR_EVENT_TYPE_WAIT_BREAK 0x00040000 #define CPR_EVENT_TYPE_WAIT_ERR 0x00080000 #define CPR_EVENT_TYPE_WAIT_RING 0x00100000 #define CPR_EVENT_TYPE_WAIT_RX80FULL 0x00200000 // _DATA_ Events added 5/7/07 by DAG #define CPR_EVENT_TYPE_DATA_RECEIVE 0x00400000 #define CPR_EVENT_TYPE_DATA_TRANSMIT 0x00800000 #define CPR_EVENT_TYPE_READ_REQUEST 0x01000000 #define CPR_EVENT_TYPE_READ_TIMEOUT 0x02000000 #define CPR_EVENT_TYPE_PENDED_READ_RELEASED 0x04000000 #define CPR_EVENT_TYPE_READ_OVERFLOW 0x08000000 #define CPR_EVENT_TYPE_DEBUG 0x80000000 #define CPR_EVENT_TYPE_ALL 0xFFFFFFFF #define CPR_ET_IOCTL_PURGE 0x00000001 #define CPR_ET_IOCTL_GET_HANDFLOW 0x00000002 #define CPR_ET_IOCTL_SET_HANDFLOW 0x00000004 #define CPR_ET_IOCTL_GET_MODEM_STATUS 0x00000008 #define CPR_ET_IOCTL_GET_DTRRTS 0x00000010 #define CPR_ET_IOCTL_GET_COMM_STATUS 0x00000020 #define CPR_ET_IOCTL_GET_PROPERTIES 0x00000040 #define CPR_ET_IOCTL_SET_BAUDRATE 0x00000080 #define CPR_ET_IOCTL_GET_BAUDRATE 0x00000100 #define CPR_ET_IOCTL_SET_MODEM_CONTROL 0x00000200 #define CPR_ET_IOCTL_GET_MODEM_CONTROL 0x00000400 #define CPR_ET_IOCTL_SET_LINE_CONTROL 0x00000800 #define CPR_ET_IOCTL_XOFF_COUNTER 0x00001000 #define CPR_ET_IOCTL_GET_STATS 0x00002000 #define CPR_ET_IOCTL_SET_TIMEOUTS 0x00004000 #define CPR_ET_IOCTL_GET_TIMEOUTS 0x00008000 #define CPR_ET_IOCTL_SET_CHARS 0x00010000 #define CPR_ET_IOCTL_GET_CHARS 0x00020000 #define CPR_ET_IOCTL_SET_DTR 0x00040000 #define CPR_ET_IOCTL_CLEAR_DTR 0x00080000 #define CPR_ET_IOCTL_SET_RTS 0x00100000 #define CPR_ET_IOCTL_CLEAR_RTS 0x00200000 #define CPR_ET_IOCTL_SET_XON 0x00400000 #define CPR_ET_IOCTL_SET_XOFF 0x00800000 #define CPR_ET_IOCTL_SET_BREAK_ON 0x01000000 #define CPR_ET_IOCTL_SET_BREAK_OFF 0x02000000 #define CPR_ET_IOCTL_SET_QUEUE_SIZE 0x04000000 #define CPR_ET_IOCTL_GET_WAIT_MASK 0x08000000 #define CPR_ET_IOCTL_SET_WAIT_MASK 0x10000000 #define CPR_ET_IOCTL_WAIT_ON_MASK 0x20000000 #define CPR_ET_IOCTL_IMMEDIATE_CHAR 0x40000000 #define CPR_ET_IOCTL_GET_LINE_CONTROL 0x80000000 #define CPR_EVENT_SUB_TYPE_NONE 0x00000000 #define CPR_EVENT_LEVEL_NONE 0x00000000 #define CPR_EVENT_LEVEL_CRITICAL 0x10000000 #define CPR_EVENT_LEVEL_WARNING 0x20000000 #define CPR_EVENT_LEVEL_INFO 0x40000000 #define CPR_EVENT_LEVEL_TRACE 0x80000000 #define CPR_EVENT_LEVEL_ALL 0xF0000000 #define CPR_EVENT_FLAG_NONE 0x00000000 #define CPR_EVENT_FLAG_PASS_UP 0x00000001 #define CPR_EVENT_FLAG_DBGPRINT 0x00000002 #define CPR_EVENT_FLAG_SEND_READ_DATA 0x00000004 #define CPR_EVENT_FLAG_SEND_WRITE_DATA 0x00000008 #define CPR_EVENT_FLAG_FAIL 0x00000010 #define CPR_EVENT_FLAG_ABORT 0x00000020 #define CPR_EVENT_FLAG_CANCELLED 0x10000000 #define CPR_EVENT_LOG_SIGNATURE 'goLE' #define CPR_EVENT_LOG_NAME _T("EventLogBuffer") typedef struct _CPR_EVENT_LOG { LARGE_INTEGER ticks; // Performance Counter Ticks ULONG type; // Type of Event ULONG subType; // Sub Type (ie IOCTL_CODE) ULONG flags; // Various Flags short comPort; // Com Port short tcpPort; // TCP Port ULONG ipAddr; // IP Address as ULONG ULONG status; // NTSTATUS char msg[CPR_EVENT_MSG_SIZE]; // Message ULONG sessionId; } CPR_EVENT_LOG, *PCPR_EVENT_LOG; typedef struct _CPR_EVENT_LOG_HEADER { ULONG signature; ULONG numEventLogs; ULONG numWrites; ULONG pad; ULONG begNdx; ULONG endNdx; ULONG readNdx; ULONG writeNdx; } CPR_EVENT_LOG_HEADER, *PCPR_EVENT_LOG_HEADER; typedef struct _CPR_EVENT_LOG_BUFFER { CPR_EVENT_LOG_HEADER header; // header CPR_EVENT_LOG eventLogs[1]; // Array of event logs } CPR_EVENT_LOG_BUFFER, *PCPR_EVENT_LOG_BUFFER; // cpa stands for Com Port Array // // Example: CPR_SET_PORT(filter.CprComPorts, 5); #define CPR_SET_PORT(cpa, port) cpa[(port-1) >> 5] |= (1 << ((port-1) % 32)) // Example: CPR_CLR_PORT(filter.CprComPorts, 5); #define CPR_CLR_PORT(cpa, port) cpa[(port-1) >> 5] &= ~(1 << ((port-1) % 32)) // Example: if (CPR_IS_PORT_SET(filter.CprComPorts, 5)) #define CPR_IS_PORT_SET(cpa, port) (cpa[(port-1) >> 5] & (1 << ((port-1) % 32)) ? TRUE : FALSE) typedef struct _CPR_FILTER_DATA { ULONG CprEventLogFilter; // Event Log Filter for Session ULONG CprELIoctlFilter; // Event Log Ioctl Filter for Session ULONG CprTraceFlags; // Trace flags for Session ULONG CprEventFlags; // Event flags for Session ULONG CprComPorts[NUM_COM_ULONGS]; // ((8*4)bytes)*(8 bits)=256 bits // to hold 256 com ports } CPR_FILTER_DATA, *PCPR_FILTER_DATA; /////////////////////////////////////////////////////////////////////////////////////////////////// #if !defined(CPR_DRVR) #ifndef DO_NOT_INCLUDE_WINSOCK2 #include "WinSock2.h" #endif /////////////////////////////////////////////////////////////////////////////////////////////////// // DEBUG PRINTING /////////////////////////////////////////////////////////////////////////////////////////////////// // // Debug Levels // #define DBGIF_NONE 0 #define DBGIF_ERR 1 #define DBGIF_WARN 2 #define DBGIF_TRACE 3 #define DBGIF_INFO 4 #define DBGIF_VERB 5 // // Debug Areas // #define DBGIF_GENERAL (1 << 0) // 0x00000001 #define DBGIF_PORT (1 << 1) // 0x00000002 #define DBGIF_DRIVER (1 << 2) // 0x00000004 #define DBGIF_ENTRY (1 << 3) // 0x00000008 #define DBGIF_FILE (1 << 4) // 0x00000010 #define DBGIF_FIREWALL (1 << 5) // 0x00000020 #define DBGIF_NETWORK (1 << 6) // 0x00000040 #define DBGIF_REGISTRY (1 << 7) // 0x00000080 #define DBGIF_EVENT_LOG (1 << 8) // 0x00000100 #define DBGIF_COM_STATUS (1 << 9) // 0x00000200 #define DBGIF_ALL 0xFFFFFFFF // // Debug Destination // #define DBGIF_DST_NONE 0 // 0x00000000 #define DBGIF_DST_PRINT (1 << 0) // 0x00000001 #define DBGIF_DST_FILE (1 << 1) // 0x00000002 #define DBGIF_DST_POPUP (1 << 2) // 0x00000004 // Name Length includes terminating zero. // So the actual max length is INFO_NAME_LEN - 1. #define INFO_NAME_LEN 34 typedef struct _CprDeviceInfo { unsigned char id[ID_LEN]; // Device type id. unsigned char macAddr[MAC_LEN]; // Device Hardware Address. in_addr inAddr; // IP Address in in_addr form. char ipAddr[IP_LEN]; // IP Address. char devName[INFO_NAME_LEN]; // Device server name. char port1Name[INFO_NAME_LEN]; // Name of port 1 on // device server. char port2Name[INFO_NAME_LEN]; // Name of port 2 on // device server. int tcpPort1; // Currently configured TCP // port of com port 1 on // device server. int tcpPort2; // Currently configured TCP // port of com port 2 on // device server. char interfaceIpAddr[IP_LEN]; // IP Address of the interface // device was discovered on. } CprDeviceInfo, *PCprDeviceInfo; // *************************************************************************** // *************************************************************************** // PROTOTYPES // *************************************************************************** // *************************************************************************** #if defined(CPR_IF_EXPORTS) #if defined(__cplusplus) #define LIBSPEC extern "C" _declspec(dllexport) #else #define LIBSPEC _declspec(dllexport) #endif #elif defined(__cplusplus) #define LIBSPEC extern "C" _declspec(dllimport) #else #define LIBSPEC _declspec(dllimport) #endif // *************************************************************************** // CprAddPort // Add a new virtual CPR com port to the system // // Parameters // // comPortNumber // The port number to create // // updateDriver // Force an update or reload of the driver. // This value should always be FALSE // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // (Also returned are various system error codes) // // Remarks // The function will create a new virtual CPR com port. // The port will be identified by the comPortNumber and will use the // values in the default port info. // To retrieve the default port info, use the GetDefaultPortInfo function. // To change the default port info, use the SetDefaultPortInfo function. // To change the port info values, for example to add IP addresses // and ports, use the SetPortInfo function. // LIBSPEC int CprAddPort( DWORD comPortNumber, BOOL updateDriver ); // *************************************************************************** // CprCancelComStatus // Cancel a wait on status that was initiated via a call // to CprGetComStatus. // // Parameters // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // The function will cancel a wait on status that was // initiated via a call to CprGetComStatus // LIBSPEC int CprCancelComStatus(); // *************************************************************************** // CprDriverPartOnlyCloseComPort // Close the com port by the driver. // Any application that has opened this port is // not notified of the close. // // Parameters // comPortNumber // The port number to close // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // This function will close the com port as far as the CPR driver is // concerned. The application that opened the port will not be able // to be notified. The application that opened the port may experience // problems. The application will still have a connection to the // CPR driver, but the driver will not have a connection to the device // server. This is a dangerous function call and must be used with care. // LIBSPEC int CprDriverPartOnlyCloseComPort( DWORD comPortNumber ); // *************************************************************************** // CprDisconnectNetwork // Disconnects CPR from the Device Server. // // Parameters // // comPortNumber // The port number to disconnect // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // This function will disconnect CPR from the connect Device Server. // The application that opened the port will not be able to be notified. // The application that opened the port may experience problems because // of this disconnect. The application may still have a connection to // the CPR driver, but the driver will not have a connection to the // device server. This is a dangerous function call and must be used // with care. It is used primarily for com ports that have No Net Close // or Listen Mode configured. // LIBSPEC int CprDisconnectNetwork( DWORD comPortNumber ); // *************************************************************************** // CprFindDevices // Find device servers on the network. // // Parameters // // ppDevInfo // This is a pointer to a pointer of a CprDeviceInfo structure. // FindDevices allocates memory for the array of structures. // Once the buffer is no longer needed, FreeBuffer must be called // to free ppDevInfo. // // pNumDevices // FindDevices will set this value to the number of devices // returned in ppDevInfo. // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // The function will allocate enough memory to hold the number of // devices found on the network. The contents of ppDevInfo (*ppDevInfo) // will be a pointer to that memory. Use this value as an array of // CprDeviceInfo structures. The number of devices found will be // returned in the pNumDevices argument. Warning: remember to call // CprFreeBuffer on the contents of ppDevInfo to free the allocated memory. // // Example // // int retval, i; // int numDevices; // PCprDeviceInfo pDevInfo; // // retval = CprFindDevices(&pDevInfo, &numDevices); // if (retval == CPR_OK) // { // for (i=0; i value in the registry. // // Parameters // // appPath // pointer to a string that contains the path of the application. Must end in “\”. // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // A directory called driver must be created underneath the directory described in appPath. // For Example: // If appPath = C:\MyApp\ // Then the directory C:\MyApp\driver must exist // The file C:\MyApp\driver\CprDrvr.inf must exist // The file C:\MyApp\driver\CprDrvr.sys must exist // LIBSPEC int CprRegisterApplicationPath( char *appPath ); // *************************************************************************** // CprReleasePort // Releases a port from the system (Microsoft’s) com port database. // // Parameters // // comNumber // The number of the com port // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // A com port database is maintained by the system. // A com port may inadvertently be reserved. // A call to this function will release it from the com port database. // LIBSPEC int CprReleasePort( DWORD comPortNumber ); // *************************************************************************** // CprRemovePort // Removes a virtual CPR com port from the system. // // Parameters // // comNumber // The number of the com port // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // This functions removes the com port specified by the // parameter; comNumber. // LIBSPEC int CprRemovePort( DWORD comPortNumber ); // *************************************************************************** // CprSetDefaultPortInfo // Sets the default port info values to the registry for later retrieval. // // Parameters // // pPortInfo // A pointer to a PortInfo structure as defined in CprApi.h // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // This function sets the values for the default com port. // The AddPort function uses these values when creating a port. // The user then calls SetPortInfo to change these values if necessary. // LIBSPEC int CprSetDefaultPortInfo( PPortInfo pPortInfo ); // *************************************************************************** // CprSetDeviceAndPortNames // Set the device name and port name and stores it on the device server. // // Parameters // // ipAddress // A pointer to an array of characters which is null terminated // // portNum // The parameter corresponds to the serial ports on the device server. // The value is either a 1 or 2 // // deviceName // The name the user wishes to use for the device server. // Only the first 32 characters will be used // // portName // The name the user wishes to use for the port. // Only the first 32 characters will be used // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // The function is used to name the device server and the serial // ports on the device server. Some device servers only have 1 port, // others have 2. The value of portNum is either a 1 or 2. This // function needs to be called twice if both port names are to be changed. // These names are stored on the device server. // LIBSPEC int CprSetDeviceAndPortNames( char *ipAddress, char *deviceName, char *Port1Name, char *Port2Name, DWORD timeout ); // *************************************************************************** // CprSetPortInfo // Set the port info for the specified port. // // Parameters // // pPortInfo // A pointer to a PortInfo structure as defined in CprApi.h // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // CPR_INSUFFICIENT_RESOURCES // // Remarks // The user usually calls GetPortInfo, changes the data in the Port Info // structure, then calls SetPortInfo to set the Port Info into the // Registry and updates the information for the driver. // LIBSPEC int CprSetPortInfo( PPortInfo pPortInfo ); // *************************************************************************** // CprGetCprIfLoggingState // Get the logging state of CprIf.dll. // // Parameters // // pLoggingTurnedOn // TRUE means logging is turned on. // FALSE(Default) means it is turned off. // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // Logging state of messages from CprIf.dll to debug output. Use // DbgView from www.sysinternals.com to view. // LIBSPEC int CprGetCprIfLoggingState( BOOL *pLoggingTurnedOn ); // *************************************************************************** // CprSetCprIfLoggingState // Set the logging state of CprIf.dll to CprIf.log to on or off. // // Parameters // // loggingTurnedOn // TRUE to turn logging on, FALSE(Default) to turn if off. // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // Set the logging state of CprIf.dll to CprIf.log to on or off. // LIBSPEC int CprSetCprIfLoggingState( BOOL loggingTurnedOn ); // *************************************************************************** // *************************************************************************** // EVENT LOG PROTOTYPES // *************************************************************************** // *************************************************************************** // *************************************************************************** // CprEL_StartEventRead // Starts the event read system. // // Parameters // // None // // Return Value // CPR_OK // CPR_UNKNOWN_EXCEPTION // // Remarks // There must be a filter sent to CPR for events to be returned. // See the CprEL_GetFilterData and CprEL_SetFilterData functions. // LIBSPEC int CprEL_StartEventRead(); // *************************************************************************** // CprEL_WaitOnEventRead // Waits for an event to occur then returns the event in pEventLog. // // Parameters // // pEventLog // A pointer to a CPR_EVENT_LOG structure as defined in CprApi.h // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // LIBSPEC int CprEL_WaitOnEventRead( PCPR_EVENT_LOG pEventLog ); // *************************************************************************** // CprEL_CancelEventRead // Cancels the event read system. // // Parameters // // None // // Return Value // CPR_OK // CPR_UNKNOWN_EXCEPTION // // Remarks // If CprEL_WaitOnEventRead is active, it will be returned with a status // of cancelled. // LIBSPEC int CprEL_CancelEventRead(); // *************************************************************************** // CprEL_SetFilterData // Set the current filter data in CPR. Tells CPR what to filter. // // Parameters // // pFilterData // A pointer to a CPR_FILTER_DATA structure as defined in CprApi.h // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // Sets the filter criteria in the CPR driver. // LIBSPEC int CprEL_SetFilterData( PCPR_FILTER_DATA pFilterData ); // *************************************************************************** // CprEL_GetFilterData // Get the current filter data from CPR. // // Parameters // // pFilterData // A pointer to a CPR_FILTER_DATA structure as defined in CprApi.h // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // Gets the filter criteria from the CPR driver. // LIBSPEC int CprEL_GetFilterData( PCPR_FILTER_DATA pFilterData ); // *************************************************************************** // CprEL_ClearFilterData // Clears the current filter data in CPR. // // Parameters // // None // // Return Value // CPR_OK // CPR_UNKNOWN_EXCEPTION // // Remarks // This will clear the filter data structure in the CPR Driver // This effectively filters out everything, no events will fire. // To stop the Event Logging system, use CprEL_CancelEventRead. // LIBSPEC int CprEL_ClearFilterData(); // *************************************************************************** // CprEL_GetCurrentPerformanceCounter // Get the current performance counter. // // Parameters // // lpCounter // // Return Value // CPR_OK // CPR_INVALID_ARGUMENT // CPR_UNKNOWN_EXCEPTION // // Remarks // . // LIBSPEC int CprEL_GetCurrentPerformanceCounter( LARGE_INTEGER *lpCounter ); // *************************************************************************** // CprGetLastNetworkError // Get the last network error // // Parameters // pError // pointer to an integer where the error code will be placed // // Return Value // CPR_OK // CPR_UNKNOWN_EXCEPTION // CPR_INVALID_ARGUMENT // // Remarks // int __declspec(dllexport) CprGetLastNetworkError( int *pError ); #endif // !defined(CPR_DRVR) #endif // __CPRAPI_H__