/*--------------------------------------------------------------------
 * Noregon Systems - JPRO(tm) J1708 RP1210A-Compliant API Include File
 *--------------------------------------------------------------------
 *
 * Name:                NSIRP32.h
 * API Version:         2.0
 * Date:                January 31, 2001
 *
 * Written by:
 *                      Noregon Systems
 *                      500 Shepherd Street
 *                      Winston-Salem, NC 27103
 *                      (336) 768-4337 Phone
 *                      (336) 760-2540 Fax
 *                      http://www.noregon.com
 *                      noregon@noregon.com
 *
 * Decription:  
 *              This is the main include file for the
 *              JPRO(tm) J1708 RP1210A-Compliant API.
 *
 * Purpose:
 *              List all definitions and functions associated with 
 *              the TMC document RP1210A and the Noregon extensions
 *              to the recommended practice.
 * Notes:
 *              You may need to comment out the #include <commcrtl.h>
 *              file is using a compiler other than Microsoft C.
 *
 *=====================================================================
 * COPYRIGHT NOTICE:  
 * 
 * UNPUBLISHED AND CONFIDENTIAL.  COPYRIGHT NOREGON SYSTEMS INC.  
 * CREATED 2000/2001, ALL RIGHTS RESERVED.  THIS CODE IS NOT TO BE 
 * REPRODUCED, DISSEMINATED, TRANSFERRED, OR USED IN ANY WAY WITHOUT 
 * THE EXPRESS WRITTEN PERMISSION OF NOREGON SYSTEMS, INC.
 *
 *=====================================================================
 * API Header File Revisions
 *
 * Date        Change
 * --------------------------------------------------------------------
 * 01/31/2001  Changed to support features of the Version 2.0 API.
 *
 *===================================================================*/

#ifndef NSIRP32_H
#define NSIRP32_H

#include <windows.h>
#include <commctrl.h>
#include <process.h>

#define DLLEXPORT __declspec(dllexport)

//--------------------------------------------------------------
// JPRO(tm) J1708 RP1210 Version 1.0 Defines
//--------------------------------------------------------------

#define Clear_All_Filters                              3
#define Set_J1708_Message_Filter                       7

//--------------------------------------------------------------
// JPRO(tm) J1708 RP1210 Version 2.0 Defines
//--------------------------------------------------------------

#define RP1210_Set_All_Filters_States_to_Pass          3
#define RP1210_Set_Message_Filtering_For_J1708         7
#define RP1210_Set_J1708_Mode                         15
#define RP1210_Echo_Transmitted_Messages              16
#define RP1210_Set_All_Filters_States_to_Discard      17
#define RP1210_Set_Message_Receive                    18
#define RP1210_Reset_Device                            0

//--------------------------------------------------------------
// TMC RP1210A Defined Error Codes
//--------------------------------------------------------------

#define NO_ERRORS                                      0
#define ERR_DLL_NOT_INITIALIZED                      128
#define ERR_INVALID_CLIENT_ID                        129
#define ERR_CLIENT_ALREADY_CONNECTED                 130
#define ERR_CLIENT_AREA_FULL                         131
#define ERR_FREE_MEMORY                              132
#define ERR_NOT_ENOUGH_MEMORY                        133
#define ERR_INVALID_DEVICE                           134
#define ERR_DEVICE_IN_USE                            135
#define ERR_INVALID_PROTOCOL                         136
#define ERR_TX_QUEUE_FULL                            137
#define ERR_TX_QUEUE_CORRUPT                         138
#define ERR_RX_QUEUE_FULL                            139
#define ERR_RX_QUEUE_CORRUPT                         140
#define ERR_MESSAGE_TOO_LONG                         141
#define ERR_HARDWARE_NOT_RESPONDING                  142
#define ERR_COMMAND_NOT_SUPPORTED                    143
#define ERR_INVALID_COMMAND                          144
#define ERR_TXMESSAGE_STATUS                         145
#define ERR_ADDRESS_CLAIM_FAILED                     146
#define ERR_CANNOT_SET_PRIORITY                      147
#define ERR_CLIENT_DISCONNECTED                      148
#define ERR_CONNECT_NOT_ALLOWED                      149
#define ERR_CHANGE_MODE_FAILED                       150
#define ERR_BUS_OFF                                  151
#define ERR_COULD_NOT_TX_ADDRESS_CLAIMED             152
#define ERR_ADDRESS_LOST                             153
#define ERR_CODE_NOT_FOUND                           154
#define ERR_BLOCK_NOT_ALLOWED                        155
#define ERR_MULTIPLE_CLIENTS_CONNECTED               156
#define ERR_ADDRESS_NEVER_CLAIMED                    157
#define ERR_WINDOW_HANDLE_REQUIRED                   158
#define ERR_MESSAGE_NOT_SENT                         159
#define ERR_MAX_NOTIFY_EXCEEDED                      160
#define ERR_MAX_FILTERS_EXCEEDED                     161
#define ERR_HARDWARE_STATUS_CHANGE                   162

//--------------------------------------------------------------
// JPRO(tm) J1708 RP1210A-Compliant API Extensions to RP1210A
//--------------------------------------------------------------

#define NSI_Clear_J1708_Filter                       200
#define NSI_Request_Queue_Stats                      205
#define NSI_Reset_Queue_Stats                        206
#define NSI_Request_Bus_Stats                        207
#define NSI_Reset_Bus_Stats                          208
#define NSI_Get_Hardware_Status                      213
#define NSI_Set_Block_Wait_Time                      215
#define NSI_GetVersionInfo                           301

//--------------------------------------------------------------
// The following definitions are given for backwards
// compatibility.  Noregon recommends that the developer
// use the NSI_* extensions.
//--------------------------------------------------------------

#define PCS_Clear_J1708_Filter                       200
#define PCS_Request_Queue_Stats                      205
#define PCS_Reset_Queue_Stats                        206
#define PCS_Request_Bus_Stats                        207
#define PCS_Reset_Bus_Stats                          208
#define PCS_Request_DLA_Stats                        207
#define PCS_Reset_DLA_Stats                          208
#define PCS_Get_Hardware_Status                      213
#define PCS_Set_Block_Wait_Time                      215
#define PCS_GetVersionInfo                           301

//--------------------------------------------------------------
// Noregon API Specific Error Codes
//--------------------------------------------------------------

#define ERR_INVALID_BUFFER_PARAM                     200    
#define ERR_INVALID_FLAG_PARAM                       201    
#define ERR_INI_FILE_NOT_IN_WIN_DIR                  202    
#define ERR_SERIAL_SERVICE_NOT_STARTED               203 
#define ERR_INI_SECTION_NOT_FOUND                    204    
#define ERR_INI_KEY_NOT_FOUND                        205    
#define ERR_INVALID_KEY_STRING                       206    
#define ERR_DEVICE_NOT_SUPPORTED                     207
#define ERR_INVALID_PORT_PARAM                       208
#define ERR_CANNOT_BLOCK_NOTIFY                      209
#define ERR_INVALID_FILTER_SIZE                      210
#define ERR_DATA_LENGTH_EXCEEDS_PROTOCOL_LIMITS      211
#define ERR_COMMAND_BUFFER_TOO_SMALL                 212
#define ERR_COMMAND_TIMED_OUT                        213
#define ERR_9X_SJ1708_DRIVER_NOTLOADED               214
#define ERR_2K_SJ1708_DRIVER_NOTLOADED               215
#define ERR_NT_PORT_SERVICE_NOTSTARTED               216
#define ERR_NT_SERIAL_DRIVER_NOTSTARTED              217
#define ERR_NT_SJ1708_DRIVER_NOTLOADED               218
#define ERR_SECURITY_CHECK                           219
#define ERR_ATLEAST_ONE_COMPORT_IS_INUSE             251
#define ERR_MULTIPLE_COMPORT_CONNECTION              252
#define ERR_HOOKING_IRQ								 253

//--------------------------------------------------------------
// Error codes between 220 - 250 and 441 are reserved for the
// Noregon JPRO(tm) CAN/J1939/J1708/J1587 Data Link Adapter 
// API drivers.
//
// Error codes added within this range are provide for 
// compatiblity with version 1.9 or higher of the DLA drivers.
//--------------------------------------------------------------

#define ERR_OS_NOT_SUPPORTED                         220
#define ERR_COMMAND_QUEUE_IS_FULL                    222
#define ERR_COMM_DEVICE_IN_USE                       230
#define ERR_DATA_LINK_CONFLICT                       441
#define ERR_ADAPTER_NOT_RESPONDING                   453

#ifdef __cplusplus
extern "C" {
#endif
short DLLEXPORT WINAPI RP1210_ClientConnect(  
                                HWND   hwndClient,
                                short  nDeviceId,
                                char  *fpchProtocol,
                                long   lSendBuffer,
                                long   lReceiveBuffer,
                                short  nIsAppPacketizingIncomingMsgs );

short DLLEXPORT WINAPI RP1210_ClientDisconnect( short  nClientID );

short DLLEXPORT WINAPI RP1210_SendMessage(  
                                short  nClientID,
                                char  *fpchClientMessage,
                                short  nMessageSize,
                                short  nNotifyStatusOnTx,
                                short  nBlockOnSend );

short DLLEXPORT WINAPI RP1210_ReadMessage(  
                                short  nClientID,
                                char  *fpchAPIMessage,
                                short  nBufferSize,
                                short  nBlockOnSend );

short DLLEXPORT WINAPI RP1210_SendCommand(  
                                short  nCommandNumber,
                                short  nClientID,
                                char  *fpchClientCommand,
                                short  nMessageSize );

void  DLLEXPORT WINAPI RP1210_ReadVersion(  
                                char  *fpchDLLMajorVersion,
                                char  *fpchDLLMinorVersion,
                                char  *fpchAPIMajorVersion,
                                char  *fpchAPIMinorVersion );

short DLLEXPORT WINAPI RP1210_GetHardwareStatus(  
                                short  nClientID,
                                char  *fpchClientInfo,
                                short  nInfoSize,
                                short  nBlockOnRequest);

short DLLEXPORT WINAPI RP1210_GetErrorMsg( 
                                short  err_code,
                                char  *fpchMessage );
#ifdef __cplusplus
}
#endif

#endif // NSIRP32_H
