////////////////////////////////////////////////////////////////////////////////////
// ICSNVC40.h
// 4/16/2008
// Copyright Intrepid Control Systems, Inc. 2000-2008
// www.intrepidcs.com
////////////////////////////////////////////////////////////////////////////////////


#ifndef ICSNVC40_H
#define ICSNVC40_H

#include "icsSpyData.h"

#define		NEOVI_COMMTYPE_RS232				0
#define		NEOVI_COMMTYPE_USB_BULK				1
#define		NEOVI_COMMTYPE_USB_ISO_DONT_USE		2
#define		NEOVI_COMMTYPE_TCPIP				3
#define		NEOVI_COMMTYPE_USB_2_0				4
#define		NEOVI_COMMTYPE_FIRE_USB				5
#define		NEOVI_COMMTYPE_NEOVISERVER_TCPIP     100
#define     NEOVI_COMMTYPE_NEOVISERVER_SHAREDMEM 101

// Driver Type Constants
#define INTREPIDCS_DRIVER_STANDARD		    0
#define	INTREPIDCS_DRIVER_TEST			    1
#define	INTREPIDCS_DRIVER_CYPRESS		    2
#define INTREPIDCS_DRIVER_SYNCTOPC	    	3
#define INTREPIDCS_DRIVER_ENHANCED_3G    	4

// device Type IDs NOTE: These are only valid for the older icsneoOpenPortEx() function
#define INTREPIDCS_DEVICE_NEO4			0
#define INTREPIDCS_DEVICE_VCAN			1
#define INTREPIDCS_DEVICE_NEO6			2
#define INTREPIDCS_DEVICE_UNKNOWN		3
#define INTREPIDCS_DEVICE_VCAN2_DW		4
#define INTREPIDCS_DEVICE_VCAN2_SW		5
#define INTREPIDCS_DEVICE_VCAN2_LSFT	6
#define INTREPIDCS_DEVICE_VCAN2_WIFI	7
#define INTREPIDCS_DEVICE_VCAN3_CANDOC	8
#define INTREPIDCS_DEVICE_NEOFIRE		10
#define INTREPIDCS_DEVICE_VCAN3		    	11
#define INTREPIDCS_DEVICE_YELLOW		12
#define INTREPIDCS_DEVICE_NEORED		INTREPIDCS_DEVICE_NEOFIRE

#define INTREPIDCS_15765_RX_ERR_GLOBAL			0x0001
#define INTREPIDCS_15765_RX_ERR_CFRX_EXP_FF		0x0002
#define INTREPIDCS_15765_RX_ERR_FCRX_EXP_FF		0x0004
#define INTREPIDCS_15765_RX_ERR_SFRX_EXP_CF		0x0008
#define INTREPIDCS_15765_RX_ERR_FFRX_EXP_CF		0x0010
#define INTREPIDCS_15765_RX_ERR_FCRX_EXP_CF		0x0020
#define	INTREPIDCS_15765_RX_ERR_CF_TIME_OUT		0x0040
#define	INTREPIDCS_15765_RX_COMPLETE			0x0080
#define	INTREPIDCS_15765_RX_IN_PROGRESS			0x0100
#define	INTREPIDCS_15765_RX_ERR_SEQ_ERR_CF		0x0200

#define		NETID_DEVICE	    0
#define		NETID_HSCAN			1
#define		NETID_MSCAN			2
#define		NETID_SWCAN			3
#define		NETID_LSFTCAN		4
#define		NETID_FORDSCP		5
#define		NETID_J1708			6
#define		NETID_AUX			7
#define		NETID_JVPW			8
#define		NETID_ISO			9
#define		NETID_ISOPIC		10
#define		NETID_MAIN51		11
#define		NETID_RED			12
#define     NETID_SCI           13
#define     NETID_ISO2          14
#define     NETID_ISO14230      15
#define		NETID_LIN			16                                               
#define         NETID_ISO3                         41
#define         NETID_HSCAN2                       42
#define         NETID_HSCAN3                       44
#define         NETID_ISO4                         47
#define         NETID_LIN2                         48
#define         NETID_LIN3                         49
#define         NETID_LIN4                         50 

#define	       	NETID_RED_APP_ERROR			52
#define	       	NETID_CGI				53
#define	       	NETID_3G_RESET_STATUS			54
#define	       	NETID_3G_FB_STATUS			55
#define			NETID_3G_APP_SIGNAL_STATUS		56
#define			NETID_3G_READ_DATALINK_CM_TX_MSG   57
#define			NETID_3G_READ_DATALINK_CM_RX_MSG   58  
#define		   NETID_3G_LOGGING_OVERFLOW				59				
#define		   NETID_3G_READ_SETTINGS_EX				60

#define NETID_SWCAN2            61
#define NETID_LSFTCAN2          62

#define NEODEVICE_UNKNOWN       0
#define NEODEVICE_BLUE			1
#define NEODEVICE_SW_VCAN		2
#define NEODEVICE_DW_VCAN		4
#define NEODEVICE_FIRE			8
#define NEODEVICE_VCAN3			16
#define NEODEVICE_YELLOW        32
#define NEODEVICE_RED			64
#define NEODEVICE_ECU			128
#define NEODEVICE_IEVB			256
#define NEODEVICE_PENDANT		512
#define NEODEVICE_ALL          0xFFFFFFFF

//deprecated netids
#define         NETID_FIRE_HSCAN2           NETID_HSCAN2
#define         NETID_FIRE_MSCAN2           NETID_HSCAN3
#define         NETID_FIRE_HSCAN3           NETID_HSCAN3
#define         NETID_FIRE_LIN2             NETID_LIN2
#define         NETID_FIRE_LIN3             NETID_LIN3
#define         NETID_FIRE_LIN4 			NETID_LIN4
#define	       	NETID_FIRE_CGI				NETID_CGI


typedef struct _NeoDevice
{
	unsigned long DeviceType;
	int Handle;
	int NumberOfClients;
	int SerialNumber;
	int MaxAllowedClients;

}NeoDevice;

typedef struct _NeoDeviceEx
{
	NeoDevice neoDevice;

	unsigned long FirmwareMajor;
	unsigned long FirmwareMinor;  

	#define CANNODE_STATUS_COREMINI_IS_RUNNING	(0x1)
	#define CANNODE_STATUS_IN_BOOTLOADER		(0x2)
	unsigned long Status;  // Bitfield, see defs above 

	unsigned long Reserved[16];   // may be expanded in future revisions

}NeoDeviceEx;

typedef union tagOptionsOpenNeoEx
{
	struct
	{
		int iNetworkID; //!< Network ID indicating which CAN network to communicate over.
	}CANOptions;
	unsigned long Reserved[16];   //!< may be expanded in future revisions.
}OptionsOpenNeoEx,*POptionsOpenNeoEx;

typedef union tagOptionsFindNeoEx
{
	struct
	{
		int iNetworkID; //!< Network ID indicating which CAN network to communicate over.
	}CANOptions;
	unsigned long Reserved[16];   //!< may be expanded in future revisions.

}OptionsFindNeoEx,*POptionsFindNeoEx;


// Structure for firmware info
//#include <pshpack1.h>//removed for sake of v413_prep
struct stAPIFirmwareInfo
{
	int iType;  // 1,2,3 for Generation of HW.
	
	// Date and Time (only valid for type 1 and 2
	int  iMainFirmDateDay;
	int  iMainFirmDateMonth;
	int  iMainFirmDateYear;
	int  iMainFirmDateHour;
	int  iMainFirmDateMin;
	int  iMainFirmDateSecond;
	int  iMainFirmChkSum;

	// Version data (only valid for type 3)
	unsigned char iAppMajor;
	unsigned char iAppMinor;

	unsigned char iManufactureDay;
	unsigned char iManufactureMonth;
	unsigned short iManufactureYear;

	unsigned char iBoardRevMajor;
	unsigned char iBoardRevMinor;

	unsigned char iBootLoaderVersionMajor;
	unsigned char iBootLoaderVersionMinor;

};
///#include <poppack.h>//removed for sake of v413_prep

// HSCAN neoVI or ValueCAN
#define		NEO_CFG_MPIC_HS_CAN_CNF1 (512 + 10)
#define		NEO_CFG_MPIC_HS_CAN_CNF2 (512 + 9)
#define		NEO_CFG_MPIC_HS_CAN_CNF3 (512 + 8)
#define		NEO_CFG_MPIC_HS_CAN_MODE (512 + 54)

// med speed neoVI CAN
#define		NEO_CFG_MPIC_MS_CAN_CNF1 (512 + 22)
#define		NEO_CFG_MPIC_MS_CAN_CNF2 (512 + 21)
#define		NEO_CFG_MPIC_MS_CAN_CNF3 (512 + 20)

// med speed neoVI CAN
#define		NEO_CFG_MPIC_SW_CAN_CNF1 (512 + 34)
#define		NEO_CFG_MPIC_SW_CAN_CNF2 (512 + 33)
#define		NEO_CFG_MPIC_SW_CAN_CNF3 (512 + 32)

// med speed neoVI CAN
#define		NEO_CFG_MPIC_LSFT_CAN_CNF1 (512 + 46)
#define		NEO_CFG_MPIC_LSFT_CAN_CNF2 (512 + 45)
#define		NEO_CFG_MPIC_LSFT_CAN_CNF3 (512 + 44)

// neoVI Error Constants ///////////////////////////////////////////////////////////
const unsigned long NEOVI_ERROR_DLL_TX_BUFFER_OVERFLOW = 0;
const unsigned long NEOVI_ERROR_DLL_ERROR_BUFFER_OVERFLOW = 1;
const unsigned long NEOVI_ERROR_DLL_USB_SEND_DATA_ERROR = 2;
const unsigned long NEOVI_ERROR_DLL_ISO_DATA_BUFFER_ALLOC = 3;
const unsigned long NEOVI_ERROR_DLL_ISO_DATA_READ_BUFFER = 4;
const unsigned long NEOVI_ERROR_DLL_ISO_DATA_ZERO_PACKETS =5;
const unsigned long NEOVI_ERROR_DLL_RX_MSG_BUFFER_OVERFLOW =6;
const unsigned long NEOVI_ERROR_DLL_STOP_ISO_STREAM =7;
const unsigned long NEOVI_ERROR_DLL_INVALID_NETID =8;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_RX_THREAD =9;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_TX_THREAD =10;
const unsigned long NEOVI_ERROR_DLL_MAIN_PIC_BUFFER_OVERFLOW =11;
const unsigned long NEOVI_ERROR_DLL_INVALID_DEVICE_RESPONSE =12;
const unsigned long NEOVI_ERROR_DLL_ISOTX_DATA_BUFFER_ALLOC =13;
const unsigned long NEOVI_ERROR_DLL_RX_CMD_BUFFER_OVERFLOW=14;
const unsigned long NEOVI_ERROR_DLL_RS232_RX_BUFFER_OVERFLOW=15;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_READCOMERR =16;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_READ=17;
const unsigned long NEOVI_ERROR_DLL_RS232_BUFFER_ALLOC=18;
const unsigned long NEOVI_ERROR_DLL_RS232_TX_BUFFER_OVERFLOW=19;
const unsigned long NEOVI_ERROR_DLL_RS232_MISC_ERROR=20;
const unsigned long NEOVI_ERROR_DLL_RS232_FIND_WRITE=21;
const unsigned long NEOVI_ERROR_DLL_RS232_FIND_BUFFER_ALLOC=22;
const unsigned long NEOVI_ERROR_DLL_RS232_FIND_CLEARCOMM=23;
const unsigned long NEOVI_ERROR_DLL_RS232_FIND_READCOMM=24;
const unsigned long NEOVI_ERROR_DLL_RS232_FIND_TIMEOUT=25;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_BREAK=26;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_FRAME=27;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_IOE=28;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_OVERRUN=29;
const unsigned long NEOVI_ERROR_DLL_RS232_ERR_PARITY=30;
const unsigned long NEOVI_ERROR_DLL_RS232_TXBUFFER_ALLOC=31; 
const unsigned long NEOVI_ERROR_DLL_USB_TX_RS232_ERROR=32;
const unsigned long NEOVI_ERROR_DLL_RS232_CREATE_FILE=33;
const unsigned long NEOVI_ERROR_DLL_RS232_GET_COMM_STATE=34;
const unsigned long NEOVI_ERROR_DLL_RS232_SET_COMM_STATE=35;
const unsigned long NEOVI_ERROR_DLL_RS232_START_COMM_RX_THREAD=36;
const unsigned long NEOVI_ERROR_DLL_RS232_START_COMM_TX_THREAD=37;
const unsigned long NEOVI_ERROR_DLL_SYNC_COUNT_ERR=38;
const unsigned long NEOVI_ERROR_DLL_RX_MSG_FRAME_ERR=39;
const unsigned long NEOVI_ERROR_DLL_RX_MSG_FIFO_OVER=40;
const unsigned long NEOVI_ERROR_DLL_RX_MSG_CHK_SUM_ERR=41;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_BULKIN_THREAD=42;
const unsigned long NEOVI_ERROR_DLL_BULKIN_ERR_READ=43;
const unsigned long NEOVI_ERROR_DLL_MAIN51_RX_FIFO_OVERFLOW=44;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW=45;
const unsigned long NEOVI_ERROR_DLL_MAIN51_DEV_FIFO_OVERFLOW=46;
const unsigned long NEOVI_ERROR_DLL_RESET_STATUS_CHANGED=47;
const unsigned long NEOVI_ERROR_DLL_ISO_LONG_CACHE_OVERFLOW=48;
const unsigned long NEOVI_ERROR_DLL_ISORX_LONG_BUFFER_ALLOC=49;
const unsigned long NEOVI_ERROR_DLL_J1708_LONG_CACHE_OVERFLOW=50;
const unsigned long NEOVI_ERROR_DLL_J1708_LONG_BUFFER_ALLOC=51;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_DEVICE =52;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_HSCAN =53;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_MSCAN =54;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_SWCAN =55;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_LSFTCAN =56;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_FORDSCP =57;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_J1708 =58;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_AUX =59;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_JVPW =60;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_ISO =61;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_ISOPIC =62;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_MAIN51 =63;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_FIFO_OVERFLOW_HOST =64;
const unsigned long NEOVI_ERROR_DLL_READ_ENTIRE_DEEPROM_ERROR =65;
const unsigned long  NEOVI_ERROR_DLL_WRITE_ENTIRE_DEEPROM_ERROR=66;
const unsigned long  NEOVI_ERROR_DLL_USB_PORT_ALREADY_OPEN=67;
const unsigned long  NEOVI_ERROR_DLL_JVPW_TX_REPORT_FIFO_ERR_IN=68;
const unsigned long  NEOVI_ERROR_DLL_ISOJ_TX_REPORT_FIFO_ERR_IN=69;
const unsigned long  NEOVI_ERROR_DLL_JVPW_TX_REPORT_FIFO_ERR_OUT=70;
const unsigned long  NEOVI_ERROR_DLL_ISOJ_TX_REPORT_FIFO_ERR_OUT=71;
const unsigned long  NEOVI_ERROR_DLL_MAIN51_TX_IN_FROM_HOST_FIFO=72;
const unsigned long  NEOVI_ERROR_DLL_MAIN51_TX_HOST_CHKSUM=73;
const unsigned long NEOVI_ERROR_DLL_ISOJ_TX_HOST_MISSED_BYTE=74;
const unsigned long NEOVI_ERROR_DLL_NEOVI_NO_RESPONSE=75;
const unsigned long NEOVI_ERROR_DLL_RX_SOCKET_FIFO_OVER=76;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_TXSOCKET_THREAD=77;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_RXSOCKET_THREAD=78;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_TXSOCKET_CLIENT_THREAD=78;
const unsigned long NEOVI_ERROR_DLL_PROBLEM_STOPPING_RXSOCKET_CLIENT_THREAD=79;
const unsigned long NEOVI_ERROR_DLL_TCP_CLIENT_TX=80;
const unsigned long NEOVI_ERROR_DLL_TCP_CLIENT_RX=81;
const unsigned long NEOVI_ERROR_DLL_TCP_CLIENT_RX_SOCK=82;
const unsigned long NEOVI_ERROR_DLL_UNABLE_CONNECT_TO_SRVR=83;
const unsigned long NEOVI_ERROR_DLL_UNABLE_CREATE_CLIENT_SOCK=84;
const unsigned long NEOVI_ERROR_DLL_UNABLE_WSASTARTUP=85;
const unsigned long NEOVI_ERROR_DLL_SOCK_CL_RD_BUFFER_ALLOC=86;
const unsigned long NEOVI_ERROR_DLL_SOCK_CL_TX_BUFFER_ALLOC=87;
const unsigned long NEOVI_ERROR_DLL_SOCK_SRVR_RX_BUFFER_ALLOC=88;
const unsigned long NEOVI_ERROR_DLL_SOCK_SRVR_TX_BUFFER_ALLOC=89;
const unsigned long NEOVI_ERROR_DLL_ILLEGAL_TX_NETWORK=90;
const unsigned long NEOVI_ERROR_DLL_MAIN51_TX_HOST_OVERRUN=91;
const unsigned long NEOVI_ERROR_DLL_OPEN_GET_COMM_TIMEOUT=92;
const unsigned long NEOVI_ERROR_DLL_OPEN_SET_COMM_TIMEOUT=93;
const unsigned long NEOVI_ERROR_DLL_OPEN_READ_DEVICE_TYPE=94;
const unsigned long NEOVI_ERROR_DLL_OPEN_READ_DEVICE_TYPE_TOUT=95;
const unsigned long NEOVI_ERROR_DLL_CLOSE_PURGE_COMM=96;
const unsigned long NEOVI_ERROR_DLL_TX_COM_FIFO_OVERFLOW=97;
const unsigned long NEOVI_ERROR_DLL_GET_USBSERIAL_DEVICES=98;
const unsigned long  NEOVI_ERROR_DLL_USB_TX_RS232_BCOUNT=99;
const unsigned long  NEOVI_ERROR_DLL_OPEN_INBOOTLOADER=100;
const unsigned long  NEOVI_ERROR_DLL_TOO_MANY_PERIODICS=101;
const unsigned long  NEOVI_ERROR_DLL_PROBLEM_FIRMWARE_INFO=102;
const unsigned long  NEOVI_ERROR_DLL_NRED_ODDNUMBYTES=103;
const unsigned long  NEOVI_ERROR_DLL_NRED_UNKNOWN_RED_NETID=104;
const unsigned long  NEOVI_ERROR_DLL_RED_NOT_SUPPORTED=105;
/* 106 - 116 reserved for neovi red bootloader exceptions */
const unsigned long  NEOVI_ERROR_DLL_RED_BL_START_INDEX=106;
const unsigned long  NEOVI_ERROR_DLL_3G_BL_FAILURE=107;
const unsigned long  NEOVI_ERROR_DLL_RED_BL_END_INDEX=116;
const unsigned long  NEOVI_ERROR_DLL_RED_FAILED_TO_ENTER_BL=117;
const unsigned long  NEOVI_ERROR_DLL_RED_REQ_SERIAL_NUMBER=118;
const unsigned long  NEOVI_ERROR_DLL_RED_AUTHENTICATE=119;
const unsigned long  NEOVI_ERROR_DLL_RED_APP_VERSION=120;
const unsigned long  NEOVI_ERROR_DLL_RED_SET_BAUD_COMM_FAILURE=121;
const unsigned long  NEOVI_ERROR_DLL_RED_INVALID_BAUD_SPECIFIED=122;
const unsigned long  NEOVI_ERROR_DLL_RED_READ_BAUD_COMM_FAILURE=123;
const unsigned long  NEOVI_ERROR_DLL_RED_FAILED_TO_SAVE_EEPROM=124;
const unsigned long  NEOVI_ERROR_DLL_RED_FAILED_TO_UPDATE_WAVEFORM_CHANNEL=125;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_UNKNOWN_NETWORK=126;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_UNKNOWN_NETWORK=127;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_UNKNOWN_NETWORK=128;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_HSCAN1=129;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_HSCAN1=130;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_HSCAN1=131;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_HSCAN1 = 132;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_HSCAN2=133;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_HSCAN2=134;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_HSCAN2=135;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_HSCAN2 = 136;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_MSCAN1=137;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_MSCAN1=138;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_MSCAN1=139;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_MSCAN1 = 140;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_HSCAN3=141;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_HSCAN3=142;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_HSCAN3=143;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_HSCAN3 = 144;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_SWCAN=145;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_SWCAN=146;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_SWCAN=147;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_SWCAN = 148;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_LSFTCAN=149;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_LSFTCAN=150;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_LSFTCAN=151;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_LSFTCAN = 152;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_LIN1=153;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_LIN1=154;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_LIN1=155;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_LIN1 = 156;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_LIN2=157;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_LIN2=158;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_LIN2=159;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_LIN2 = 160;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_LIN3=161;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_LIN3=162;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_LIN3=163;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_LIN3 = 164;

const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_LIN4=165;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_LIN4=166;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_LIN4=167;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_LIN4 = 168;

const unsigned long  NEOVI_ERROR_DLL_USB_PURGE_FAILED=169;
const unsigned long  NEOVI_ERROR_FIRE_COMM_BAD_PACKET=170;
const unsigned long  NEOVI_ERROR_FIRE_CGI_COMM_BAD_PACKET=171;

                                                   
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_HSCAN1=172;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_HSCAN2=173;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_HSCAN3=174;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_MSCAN=175;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_SWCAN=176;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_LSFTCAN=177;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_LIN1=178;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_LIN2=179;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_LIN3=180;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_LIN4=181;
const unsigned long  NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_UNKNOWN_NETWORK=182;
const unsigned long  NEOVI_ERROR_DLL_RED_RX_MSG_FULL_JVPW=183;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_MSG_FULL_JVPW=184;
const unsigned long  NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_JVPW=185;
const unsigned long  NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_JVPW = 186;
const unsigned long  NEOVI_ERROR_DLL_INTERNAL_SERIAL_NO_DOES_NOT_MATCH_REGISTRY_SERIAL_NO = 187;
const unsigned long NEOVI_ERROR_DLL_JVPW_LONG_CACHE_OVERFLOW  = 188;
const unsigned long NEOVI_ERROR_DLL_FAILED_TO_SET_LICENSE = 189;
const unsigned long NEOVI_ERROR_DLL_3G_DEVICE_LICENSE_NEEDS_TO_BE_UPGRADED = 190;

const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_HSCAN = 191;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_MSCAN  = 192;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_HSCAN2  = 193;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_HSCAN3  = 194;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_LSFT  = 195;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_SW  = 196;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_LIN1  = 197;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_LIN2  = 198;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_LIN3  = 199;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_LIN4  = 200;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_JVPW  = 201;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_KYW  = 202;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_J1708  = 203;
const unsigned long NEOVI_ERROR_DLL_MAIN51_RTC_INVALID = 204;
const unsigned long NEOVI_ERROR_DLL_MAIN51_LOADED_DEFAULT_SETTINGS = 205;

const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_CGI = 206;
const unsigned long NEOVI_ERROR_DLL_RED_TX_MSG_FULL_CGI = 207;
const unsigned long NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_CGI = 208;
const unsigned long NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_CGI = 209;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_CGI = 210;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_CGI = 211;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_JVPW=212;

//DLL API ERRORS
const unsigned long NEOVI_ERROR_DLL_INVALID_SCRIPT_LOCATION = 213;
const unsigned long NEOVI_ERROR_DLL_SDCARD_NOT_INSERTED = 214;
const unsigned long NEOVI_ERROR_DLL_SDCARD_NOT_FORMATTED = 215;
const unsigned long NEOVI_ERROR_DLL_SDCARD_WRITE_ERROR = 216;
const unsigned long NEOVI_ERROR_DLL_SDCARD_READ_ERROR = 217;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_START_ERROR = 218;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_INVALID_FUNCBLOCK_INDEX = 219;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_ERROR_DOWNLOADING_SCRIPT = 220;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_ERROR_CLEARING_SCRIPT = 221;
                                                                       
const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_ISO = 222;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_ISO = 223;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_INVALID_MSG_INDEX = 224;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_INVALID_APPSIG_INDEX = 225;
const unsigned long NEOVI_ERROR_DLL_SCRIPT_NO_SCRIPT_RUNNING = 226;
const unsigned long NEOVI_ERROR_DLL_COULD_NOT_SET_SETTINGS_FIRMWARE_MISMATCH = 227;
const unsigned long NEOVI_ERROR_DLL_FIRE_CGI_TX_NOT_ENABLED = 228;
const unsigned long NEOVI_ERROR_DLL_SEND_DEVICE_CONFIG_ERROR = 229;
const unsigned long NEOVI_ERROR_DLL_GET_DEVICE_CONFIG_ERROR = 230;
const unsigned long NEOVI_ERROR_DLL_UNKNOWN_NEOVI_TYPE = 231;    
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_ISO2 = 232;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_ISO3 = 233;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_ISO4 = 234;

const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_ISO2 = 235;
const unsigned long NEOVI_ERROR_DLL_RED_TX_MSG_FULL_ISO2 = 236;
const unsigned long NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_ISO2 = 237;
const unsigned long NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_ISO2 = 238;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_ISO2 = 239;
const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_ISO3 = 240;
const unsigned long NEOVI_ERROR_DLL_RED_TX_MSG_FULL_ISO3 = 241;
const unsigned long NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_ISO3 = 242;
const unsigned long NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_ISO3 = 243;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_ISO3 = 244;
const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_ISO4 = 245;
const unsigned long NEOVI_ERROR_DLL_RED_TX_MSG_FULL_ISO4 = 246;
const unsigned long NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_ISO4 = 247;
const unsigned long NEOVI_ERROR_DLL_RED_DRIVER_OVERFLOW_ISO4 = 248;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_ISO4 = 249;
const unsigned long NEOVI_ERROR_DLL_RED_FAILED_TO_CLEAR_LIN_SLAVE_DATA = 250;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_ENABLED_ISO1 = 251;
const unsigned long NEOVI_ERROR_DLL_RED_RX_MSG_FULL_ISO1 = 252;
const unsigned long NEOVI_ERROR_DLL_RED_TX_MSG_FULL_ISO1 = 253;
const unsigned long NEOVI_ERROR_DLL_RED_TX_REPORT_MSG_FULL_ISO1 = 254;
const unsigned long NEOVI_ERROR_DLL_RED_SETTINGS_NOT_SET_ISO1 = 255;
const unsigned long NEOVI_ERROR_DLL_DROPPED_RTC_CMD = 256;
const unsigned long NEOVI_ERROR_DLL_J1850_TX_REQUESTS_FLUSHED = 257;
const unsigned long NEOVI_ERROR_J1708_COMM_BAD_PACKET = 258;
const unsigned long NEOVI_ERROR_DLL_NETWORK_NOT_SUPPORTED_BY_HARDWARE = 259;
const unsigned long NEOVI_ERROR_DLL_FEATURE_NOT_UNLOCKED = 260;    
const unsigned long NEOVI_ERROR_DLL_DEVICE_NOT_POWERED = 261;
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_OK 				= 262;  ////
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORBADINIT		= 263;  // See ENeoVI3GCANDownloaderReturnCode_t in neoVI3GCANDownloader.h
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORNOCANPIPE		= 264;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORISONEG7FRESPONSE	= 265;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORTOOLNOTSELECTED	= 266;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORINVALIDDEVICESELECTED	= 267;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORCOULDNOTOPENTOOL	= 268;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORNOFLOWCONTROL		= 269;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORUNSPECIFIC		= 270;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORCOREMININULLPTR		= 271;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORCOREMINIZEROLEN		= 272;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORRESERVED3		= 273;  //
const unsigned long NEOVI_ERROR_DLL_3GCANDOWNLOADER_ERRORRESERVED4		= 274;  //

// Constants for describing error severity
const unsigned long icsspyErrCritical=0x10;
const unsigned long icsspyErrExclamation=0x30;
const unsigned long icsspyErrInformation=0x40;
const unsigned long icsspyErrQuestion=0x20;

// Constants used to calculate the timestamp
const double NEOVI_TIMESTAMP_2 = 0.1048576;
const double NEOVI_TIMESTAMP_1 = 0.0000016;

const double NEOVIPRO_VCAN_TIMESTAMP_2 = 0.065536;
const double NEOVIPRO_VCAN_TIMESTAMP_1 = 0.000001;

const double NEOVI6_VCAN_TIMESTAMP_2 = 0.065536;
const double NEOVI6_VCAN_TIMESTAMP_1 = 0.000001;

const double NEOVI_RED_TIMESTAMP_2_25NS = 107.3741824;
const double NEOVI_RED_TIMESTAMP_1_25NS = 0.000000025;

typedef struct _SPerformanceStats
{
	unsigned long average_main_loop_us;
	unsigned long min_main_loop_us;
	unsigned long max_main_loop_us;
}SPerformanceStats;

#ifdef __C30
    #include "icsglb.h"
#else 
	// win32 types
        #define icscm_int16     short
	#define icscm_uint16    unsigned short
	#define icscm_uint32    unsigned int
	#define icscm_uint8    unsigned char
        #define icscm_float32    float
        
	#pragma pack(push)
	#pragma pack(2)

#endif


#ifdef USING_STUDIO_8
	#define VS_MODIFIER __declspec(align(2))
#else
	#define VS_MODIFIER
#endif
                             
#define NEOVI_RED_PROD_ID       0
#define NEOVI_FIRE_PROD_ID      1
#define NEOVI_VCAN3_PROD_ID     2
#define NEOVI_YELLOW_PROD_ID    3
#define NEOVI_ECU_PROD_ID       4
#define NEOVI_IEVB_PROD_ID      5
#define NEOVI_PENDANT_PROD_ID   6

#define NEOVI_FIRE_MCHIP_ID     0
#define NEOVI_FIRE_LCHIP_ID     1
#define NEOVI_FIRE_UCHIP_ID     2
#define NEOVI_FIRE_JCHIP_ID     3
                                  
#define NEOVI_VCAN3_MCHIP_ID 	4

#define NEOVI_YELLOW_MCHIP_ID 	5  
#define NEOVI_YELLOW_UCHIP_ID    NEOVI_FIRE_UCHIP_ID

#define NEOVI_ECU_MPIC_ID       6

#define NEOVI_IEVB_MPIC_ID       7

#define NEOVI_PENDANT_MPIC_ID    8

// --- CAN Settings
typedef VS_MODIFIER struct {
	icscm_uint8 Mode;
	icscm_uint8 SetBaudrate;
	icscm_uint8 Baudrate;
	icscm_uint8 transceiver_mode;
	icscm_uint8 TqSeg1;
	icscm_uint8 TqSeg2;
	icscm_uint8 TqProp;
	icscm_uint8 TqSync;
	icscm_uint16 BRP;
	icscm_uint8 auto_baud;
	icscm_uint8 RESERVED;
} CAN_SETTINGS;
                       
        enum { AUTO, USE_TQ };                                                                              //SetBaudrate
        enum { BPS20, BPS33, BPS50, BPS62, BPS83,  BPS100, BPS125, BPS250, BPS500, BPS800,  BPS1000 };        // CAN baudrates
        enum { NORMAL=0, DISABLE=1, LOOPBACK=2, LISTEN_ONLY=3, LISTEN_ALL=7 };        // CAN Modes
        enum { MSCAN2, LSFTCAN2, SWCAN2 }; 						// CAN2 Network Type

 

// --- SWCAN Settings
typedef VS_MODIFIER struct {
	icscm_uint8 Mode;
	icscm_uint8 SetBaudrate;
	icscm_uint8 Baudrate;
	icscm_uint8 transceiver_mode;
	icscm_uint8 TqSeg1;
	icscm_uint8 TqSeg2;
	icscm_uint8 TqProp;
	icscm_uint8 TqSync;
	icscm_uint16 BRP;
        icscm_uint16 high_speed_auto_switch; 
	icscm_uint8 auto_baud;
	icscm_uint8 RESERVED;
} SWCAN_SETTINGS;    

enum { SWCAN_AUTOSWITCH_DISABLED, SWCAN_AUTOSWITCH_NO_RESISTOR, SWCAN_AUTOSWITCH_WITH_RESISTOR, SWCAN_AUTOSWITCH_DISABLED_RESISTOR_ENABLED}; 

// --- LIN Settings
typedef VS_MODIFIER struct _LIN_SETTINGS{
	icscm_uint32 Baudrate;
	icscm_uint16 spbrg;
	icscm_uint16 brgh;
	icscm_uint8 MasterResistor;
	icscm_uint8 Mode;
} LIN_SETTINGS;

enum { BPS5000, BPS10400, BPS33333, BPS50000, BPS62500,  BPS71429, BPS83333, BPS100000, BPS117647 }; 	// baud rate
enum { RESISTOR_ON, RESISTOR_OFF };                             					//master resistor
enum { SLEEP_MODE, SLOW_MODE, NORMAL_MODE, FAST_MODE };    

typedef VS_MODIFIER struct {
	icscm_uint16 time_500us;
	icscm_uint16 k;
	icscm_uint16 l;
} ISO9141_KEYWORD2000__INIT_STEP;


// --- ISO (KEYWORD) Settings
typedef VS_MODIFIER struct {
	icscm_uint32 Baudrate;
	icscm_uint16 spbrg;
	icscm_uint16 brgh;
	
	ISO9141_KEYWORD2000__INIT_STEP init_steps[16];
	icscm_uint8 init_step_count;
	
	icscm_uint16 p2_500us;
	icscm_uint16 p3_500us;
	icscm_uint16 p4_500us;
	icscm_uint16 chksum_enabled;
} ISO9141_KEYWORD2000_SETTINGS;

// --- RS232 Settings
typedef VS_MODIFIER struct {
	icscm_uint16 Baudrate;
	icscm_uint16 spbrg;
	icscm_uint16 brgh;
} RS232_SETTINGS;

// --- J1708 Settings
typedef VS_MODIFIER struct {
	icscm_uint16 enable_convert_mode;
} J1708_SETTINGS;

typedef VS_MODIFIER struct _SRedSettings
{
	//CAN stuff
	CAN_SETTINGS can1;
	CAN_SETTINGS can2;
	// lin stuff
	LIN_SETTINGS lin1;
	LIN_SETTINGS lin2;
}SRedSettings;

enum
{
	REPORT_ON_PERIODIC,
	REPORT_ON_MISC1,
	REPORT_ON_MISC2,
	REPORT_ON_MISC3,
	REPORT_ON_MISC4,
	REPORT_ON_MISC5,
	REPORT_ON_MISC6,
	REPORT_ON_LED1,
	REPORT_ON_LED2,
	REPORT_ON_KLINE,
	REPORT_ON_MISC3_AIN,
	REPORT_ON_MISC4_AIN,
	REPORT_ON_MISC5_AIN,
	REPORT_ON_MISC6_AIN,
	REPORT_ON_PWM_IN1
};


typedef VS_MODIFIER struct _SFireSettings
{
        CAN_SETTINGS can1;
        CAN_SETTINGS can2;
        CAN_SETTINGS can3;
        CAN_SETTINGS can4;
 
        SWCAN_SETTINGS swcan;
        CAN_SETTINGS lsftcan;
 
        LIN_SETTINGS lin1;
        LIN_SETTINGS lin2;
        LIN_SETTINGS lin3;
        LIN_SETTINGS lin4; 

        icscm_uint16 cgi_enable_reserved;
        icscm_uint16 cgi_baud;
        icscm_uint16 cgi_tx_ifs_bit_times;
        icscm_uint16 cgi_rx_ifs_bit_times;  
        icscm_uint16 cgi_chksum_enable;
 
        icscm_uint16 network_enables;
        icscm_uint16 network_enabled_on_boot;
 
        icscm_uint32 pwm_man_timeout;
        icscm_uint16 pwr_man_enable;
 
        icscm_uint16 misc_io_initial_ddr;  
        icscm_uint16 misc_io_initial_latch;
        icscm_uint16 misc_io_analog_enable;
        icscm_uint16 misc_io_report_period;
        icscm_uint16 misc_io_on_report_events;
        icscm_uint16 ain_sample_period;
        icscm_uint16 ain_threshold;
 
        //ISO 15765-2 Transport Layer
        icscm_int16 iso15765_separation_time_offset;
 
        //ISO9141 - KEYWORD 2000
        icscm_int16 iso9141_kwp_enable_reserved;
        ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
 
        //Performance Test
        icscm_uint16 perf_en;

        //ISO9141 - Parity
	icscm_uint16 iso_parity; // 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination; // 0 - use inner frame time, 1 - GME CIM-SCL
	icscm_uint16 iso_tester_pullup_enable;

	//Additional network enables
    icscm_uint16 network_enables_2;     
	
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
	icscm_uint16 iso_parity_2; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_2; 				// 0 - use inner frame time, 1 - GME CIM-SCL
	
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_3;
	icscm_uint16 iso_parity_3; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_3; 				// 0 - use inner frame time, 1 - GME CIM-SCL
	
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_4;
	icscm_uint16 iso_parity_4; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_4; 				// 0 - use inner frame time, 1 - GME CIM-SCL    
	
	icscm_uint16 fast_init_network_enables_1;
	icscm_uint16 fast_init_network_enables_2;
}SFireSettings;

typedef VS_MODIFIER struct _SVCAN3Settings
{
        CAN_SETTINGS can1;
        CAN_SETTINGS can2;

        icscm_uint16 network_enables;
        icscm_uint16 network_enabled_on_boot;

        //ISO 15765-2 Transport Layer
        icscm_int16 iso15765_separation_time_offset;

        //Performance Test
        icscm_uint16 perf_en;

        //MISC IO
	icscm_uint16 misc_io_initial_ddr;
	icscm_uint16 misc_io_initial_latch;
	icscm_uint16 misc_io_report_period;
	icscm_uint16 misc_io_on_report_events;
}SVCAN3Settings;

typedef VS_MODIFIER struct _SYellowSettings
{
	CAN_SETTINGS can1;
	CAN_SETTINGS can2;

	RS232_SETTINGS rs232;
		
	icscm_uint16 hs2_j1708_enable;		// Use hs2 + J1708
	icscm_uint16 iso_j1850_enable;		// Select ISO + J1850
	icscm_uint16 j1708_j1850_enable;	// Use J1708 + J1850
	
	icscm_uint16 network_enables;
	icscm_uint16 network_enables_2;  
	icscm_uint16 network_enabled_on_boot;
	
	icscm_uint32 pwm_man_timeout;
	icscm_uint16 pwr_man_enable; // 0 - off, 1 - sleep enabled, 2- idle enabled (fast wakeup)
	
	icscm_uint16 misc_io_initial_ddr;  
	icscm_uint16 misc_io_initial_latch;
	icscm_uint16 misc_io_analog_enable;
	icscm_uint16 misc_io_report_period;
	icscm_uint16 misc_io_on_report_events;
	icscm_uint16 ain_sample_period;
	icscm_uint16 ain_threshold;

	//ISO 15765 Transport Layer
	icscm_int16 iso15765_separation_time_offset;
	
	//ISO9141 - KEYWORD 2000 1
	icscm_int16 iso9141_kwp_enable_reserved;
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
	LIN_SETTINGS lin1;
	
	//ISO9141 - KEYWORD 2000 2 // remove later
	icscm_int16 iso9141_kwp_enable_reserved_2; // remove later
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2; // remove later
	LIN_SETTINGS lin2;

	//J1708
	J1708_SETTINGS j1708;

	//Performance Test
	icscm_uint16 perf_en;
	
	//ISO9141 - Parity
	icscm_uint16 iso_parity; // 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination; // 0 - use inner frame time, 1 - GME CIM-SCL
	icscm_uint16 iso_tester_pullup_enable;
	
	//remove later
	icscm_uint16 iso_parity_2; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_2; 				// 0 - use inner frame time, 1 - GME CIM-SCL
	
	
	icscm_uint16 fast_init_network_enables_1;
	icscm_uint16 fast_init_network_enables_2;
	
}SYellowSettings;

typedef VS_MODIFIER struct _SECUSettings
{
	// ECU ID used in CAN communications.  
	// TX ID = ECU ID with bit28 cleared, 
	// RX ID = ECUID with bit28 set, 
	// ECU ID = 0 implies ECU ID = serial no with bit 27 set
	icscm_uint32 ecu_id;
	
	icscm_uint16 selected_network; // not supported yet - default to HSCAN
	
	CAN_SETTINGS can1;
	CAN_SETTINGS can2;

	LIN_SETTINGS lin1;
	LIN_SETTINGS lin2;
	
	//ISO 15765-2 Transport Layer
	icscm_int16 iso15765_separation_time_offset;

	//ISO9141 - KEYWORD 2000 1
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
	icscm_uint16 iso_parity; // 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination; // 0 - use inner frame time, 1 - GME CIM-SCL
	
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
	icscm_uint16 iso_parity_2; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_2; 				// 0 - use inner frame time, 1 - GME CIM-SCL
	
	icscm_uint16 network_enables;
	icscm_uint16 network_enables_2;
	icscm_uint16 network_enabled_on_boot;
		
	icscm_uint32 pwr_man_timeout;
	icscm_uint16 pwr_man_enable; // 0 - off, 1 - sleep enabled, 2- idle enabled (fast wakeup)
	
	icscm_uint16 misc_io_initial_ddr;  
	icscm_uint16 misc_io_initial_latch;
	icscm_uint16 misc_io_analog_enable;
	icscm_uint16 misc_io_report_period;
	icscm_uint16 misc_io_on_report_events;
	icscm_uint16 ain_sample_period;
	icscm_uint16 ain_threshold;
	
	SWCAN_SETTINGS swcan;
	SWCAN_SETTINGS swcan2;
	CAN_SETTINGS lsftcan;
	CAN_SETTINGS lsftcan2;
	
}SECUSettings;

typedef VS_MODIFIER struct _SPendantSettings
{
	// ECU ID used in CAN communications.  
	// TX ID = ECU ID with bit28 cleared, 
	// RX ID = ECUID with bit28 set, 
	// ECU ID = 0 implies ECU ID = serial no with bit 27 set
	icscm_uint32 ecu_id; 
	
	icscm_uint16 selected_network; // not supported yet - default to HSCAN
	
	CAN_SETTINGS can1;
	CAN_SETTINGS can2;

	LIN_SETTINGS lin1;
	LIN_SETTINGS lin2;

	//ISO 15765-2 Transport Layer
	icscm_int16 iso15765_separation_time_offset;

	//ISO9141 - KEYWORD 2000 1
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings;
	icscm_uint16 iso_parity; // 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination; // 0 - use inner frame time, 1 - GME CIM-SCL
	
	ISO9141_KEYWORD2000_SETTINGS iso9141_kwp_settings_2;
	icscm_uint16 iso_parity_2; 							// 0 - no parity, 1 - event, 2 - odd
	icscm_uint16 iso_msg_termination_2; 				// 0 - use inner frame time, 1 - GME CIM-SCL
	
	icscm_uint16 network_enables;
	icscm_uint16 network_enables_2;
	icscm_uint16 network_enabled_on_boot;
		
	icscm_uint32 pwr_man_timeout;
	icscm_uint16 pwr_man_enable; // 0 - off, 1 - sleep enabled, 2- idle enabled (fast wakeup)
	
	icscm_uint16 misc_io_initial_ddr;  
	icscm_uint16 misc_io_initial_latch;
	icscm_uint16 misc_io_analog_enable;
	icscm_uint16 misc_io_report_period;
	icscm_uint16 misc_io_on_report_events;
	icscm_uint16 ain_sample_period;
	icscm_uint16 ain_threshold;
	
	SWCAN_SETTINGS swcan;
	SWCAN_SETTINGS swcan2;
	CAN_SETTINGS lsftcan;
	CAN_SETTINGS lsftcan2;
	
//	icscm_uint16 idle_wakeup_network_enables_1;
//	icscm_uint16 idle_wakeup_network_enables_2;
	
}SPendantSettings;

typedef VS_MODIFIER struct _SIEVBSettings
{
	// ECU ID used in CAN communications.  
	// TX ID = ECU ID with bit28 cleared, 
	// RX ID = ECUID with bit28 set, 
	// ECU ID = 0 implies ECU ID = serial no with bit 27 set
	icscm_uint32 ecu_id; 
	
	icscm_uint16 selected_network; // not supported yet - default to HSCAN
	
	CAN_SETTINGS can1;

	LIN_SETTINGS lin1;
	
	icscm_uint16 network_enables;
	icscm_uint16 network_enables_2;
	icscm_uint16 network_enabled_on_boot;
	
	icscm_uint16 misc_io_initial_ddr;  
	icscm_uint16 misc_io_initial_latch;
	icscm_uint16 misc_io_analog_enable;
	icscm_uint16 misc_io_report_period;
	icscm_uint16 misc_io_on_report_events;
	icscm_uint16 ain_sample_period;
	icscm_uint16 ain_threshold;
	
	//ISO 15765-2 Transport Layer
	icscm_int16 iso15765_separation_time_offset;   
	
	CAN_SETTINGS can2;
	LIN_SETTINGS lin2;
			
}SIEVBSettings;

#define GS_VERSION 5
typedef VS_MODIFIER struct _GLOBAL_SETTINGS
{
	icscm_uint16 version;

	icscm_uint16 len;

	icscm_uint16 chksum;

	union
	{
		SRedSettings red;
	
		SFireSettings fire;  
	
		SVCAN3Settings vcan3;
		
		SYellowSettings yellow;

                SECUSettings ecu;
                	
		SIEVBSettings ievb;

                SPendantSettings pendant;
	};                   
} GLOBAL_SETTINGS;  

#define NEOVI_3G_MAX_SETTINGS_SIZE  sizeof(GLOBAL_SETTINGS)

enum
{
	LL_DEAD,
	LL_PRODUCTION,
	LL_FIRE_DEMO,        
	LL_FIRE,
	LL_RED_LIMITED,
	LL_RED,
	LL_YELLOW_LIMITED,
	LL_YELLOW,
	LL_VCAN3_LIMITED,
	LL_VCAN3,
	LL_VCAN3_PRODUCTION, // limited number of transmits and then hardware trap
	LL_FIRE_PRODUCTION, // limited number of transmits and then hardware trap, cgi enabled until power off or hardware trap
	LL_ECU_40,
	LL_IEVB,
	LL_ECU_20,	// limit USB communication
};

typedef struct _SReflashRequest
{
	char fire_mpic_ief[1024];
	unsigned long fire_mpic_enable;

	char fire_lpic_ief[1024];
	unsigned long fire_lpic_enable;

	char fire_yellow_upic_ief[1024];
	unsigned long fire_yellow_upic_enable;

	char fire_yellow_jpic_ief[1024];
	unsigned long fire_yellow_jpic_enable;

	char yellow_mpic_ief[1024];
	unsigned long yellow_mpic_enable;

	char vcan3_mpic_ief[1024];
	unsigned long vcan3_mpic_enable;

}SReflashRequest;

#define icscm_int16     short
#define icscm_uint16    unsigned short
#define icscm_uint32    unsigned int
#define icscm_uint8    unsigned char
#define icscm_float32    float

#define SCRIPT_LOCATION_FLASH_MEM  0
#define SCRIPT_LOCATION_SDCARD     1
#define SCRIPT_LOCATION_VCAN3_MEM  4

#define ICS_NEODEVICE_OLD_VERSION(x)  (x == NEODEVICE_DW_VCAN || x == NEODEVICE_BLUE)
#define ICS_NEODEVICE_NEW_VERSION(x)  (x == NEODEVICE_FIRE || x == NEODEVICE_VCAN3 || x == NEODEVICE_YELLOW)

typedef struct _stCM_ISO157652_RxMessage
{
	icscm_uint32 arbid;

	icscm_uint8 data[4*1024];

	icscm_uint32 num_bytes;
}stCM_ISO157652_RxMessage;


typedef struct _stCM_ISO157652_TxMessage
{
	//transmit message
	icscm_uint16 vs_netid;				/* not supported*/

	icscm_uint16 padding;				/* not supported*/

	icscm_uint32    id;

	//flow control filter
	icscm_uint32    fc_id;	
    icscm_uint32    fc_id_mask;

	icscm_uint16    fc_ext_address_enable; 	/* not supported*/
	icscm_uint16    fc_ext_address;			/* not supported*/


	//flow control timeouts
	icscm_uint16    fs_timeout;				/* not supported*/
	icscm_uint16    fs_wait;				/* not supported*/

	icscm_uint8 data[4*1024];

	icscm_uint32 num_bytes;

	//option bits
	union
	{
		struct
		{
			unsigned id_29_bit_enable:1;
			unsigned fc_id_29_bit_enable:1;
		};
		icscm_uint16 flags;
	};
        
}stCM_ISO157652_TxMessage;


#ifdef __C30
#else
	#pragma pack(pop)
#endif








#endif