View Single Post
Old 09-10-2004, 09:25 AM   #8
god_of_cpu
Raw Wave
 
god_of_cpu's Avatar
 
Join Date: Jan 2004
Location: SilverSpring Maryland
Posts: 2,957
This is the exposed interface of the dll, most of these should be semi-self explainatory, but they are explained completely in the code files I'll post later.

This code is in C++, you will have to covert the prototypes to VB.



Code:
INIT_DLL_FUNCTION(LPVOID, WINAPI, API_OBDII_Create,(HWND hWnd, IUnknown* lpUknown)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Release,(LPVOID lpUser)); INIT_DLL_FUNCTION_NAMED(VOID, WINAPI, GetModuleName,(CHAR* szName, INT iMaxLen), API_OBDII_GetModuleName) INIT_DLL_FUNCTION_NAMED(VOID, WINAPI, GetVersion,(CHAR* szVersion, INT iMaxLen), API_OBDII_GetVersion) INIT_DLL_FUNCTION_NAMED(VOID, WINAPI, GetGUID,(GUID* pguid), API_OBDII_GetGUID); INIT_DLL_FUNCTION_NAMED(INT, WINAPI, RequestedAPI,(INT iMaxAPI), API_OBDII_RequestedAPI); INIT_DLL_FUNCTION_NAMED(VOID, WINAPI, GetModuleComment,(CHAR* szComment, INT iMaxLen), API_OBDII_GetModuleComment); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_SetMode, (LPVOID lpUser, enumOBDModes eOBDMode)); INIT_DLL_FUNCTION(FLOAT, WINAPI, API_OBDII_Mode1_GetRefreshRate, (LPVOID lpUser)); INIT_DLL_FUNCTION(VOID, WINAPI, API_OBDII_Mode1_ResetData, (LPVOID lpUser)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode1_IsPIDSupported, (LPVOID lpUser, enumOBDMode1PIDs eOBDPID)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode1_AddOBDPID, (LPVOID lpUser, enumOBDMode1PIDs eOBDPID)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode1_RemoveAllOBDPIDs, (LPVOID lpUser)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode1_Start, (LPVOID lpUser)); INIT_DLL_FUNCTION(VOID, WINAPI, API_OBDII_Mode1_GetPacket, (LPVOID lpUser, enumOBDMode1PIDs eOBDPID, API_OBDII_MSGPACKET* lpMsgPacket)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode1_Stop, (LPVOID lpUser)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode3_IsMILLightOn, (LPVOID lpUser)); INIT_DLL_FUNCTION(INT, WINAPI, API_OBDII_Mode3_GetNumTroubleCodes, (LPVOID lpUser)); INIT_DLL_FUNCTION(VOID, WINAPI, API_OBDII_Mode3_GetTroubleCodes, (LPVOID lpUser, DWORD* lpTroubleCodes, INT iMaxNumTrobleCodes)); INIT_DLL_FUNCTION(BOOL, WINAPI, API_OBDII_Mode3_ClearTroubleCodes, (LPVOID lpUser)); //*** OPTIONAL FUNCTIONS *** INIT_DLL_FUNCTION(INT, WINAPI, API_OBDII_ConfigurationDialog, (LPVOID lpUser));

To read real time data after calling create, you would set the mode to read current data, then reset the PIDs to read and add only the PIDs you now want, then just start the plugin and it begins polling the COM port in a seperate thread, returning from the call immediatly.

i.e.
Code:
if (!m_lpAD->m_vdb.GetOBDIIPlugin()->SetMode(eOBDModeCurrentData)) TV_THROWMSGBOX("Could not set the OBD II mode to read current data!"); if (!m_lpAD->m_vdb.GetOBDIIPlugin()->Mode1_RemoveAllOBDPIDs()) TV_THROWMSGBOX("Could not remove PIDs from the OBD II module"); //Just monitor speed for now if (!m_lpAD->m_vdb.GetOBDIIPlugin()->Mode1_AddOBDPID(eOBDPIDVehicleSpeed)) TV_THROWMSGBOX("Could not add a PID to monitor the OBD II plug-in for!"); if (!m_lpAD->m_vdb.GetOBDIIPlugin()->Mode1_Start()) { TV_THROWMSGBOX("Could not start the OBD II plug-in!"); }

In a timer in your program you would call Mode1_GetPacket with the PID you want and it would return the data in the following structure:

Code:
//OBD message packet recieved from the vehicle typedef struct API_OBDII_MSGPACKET { DWORD m_dwTimeRecieved; BYTE m_iNumDataBytes; BYTE m_Header[API_OBDII_NUMHEADERBYTES]; BYTE m_Data[API_OBDII_NUMDATABYTES]; };

__________________
StreetDeck.com Developer (I am Chuck)
Get StreetDeck at http://www.streetdeck.com
The Official StreetDeck Forums have moved, please visit us at http://www.streetdeck.com/forum for official support for Streetdeck.
god_of_cpu is offline   Reply With Quote