Palmer Performance

OBDNet SDK

Copyright © 2010 Palmer Performance Engineering, Inc.








1. Overview

OBDNet overview here.






2. Getting Started

2.1 Initializing

You must initialize OBDNet before using it. You initialize OBDNet by calling OBDNetInitialize. OBDNetInitialize takes into account what programming language you are using, in order to correctly return data.

After initializing, you need to create an OBDNET_HANDLE to identify the connection. This enables you to connect to more than one OBDNet server at once. Call OBDNetCreate to create a handle. You also need to call OBDNetWorker often, using the newly created handle.


2.2 Getting Connected

Now you have completely initialized OBDNet, you need to connect. OBDNetOpenConnection will connect you to an OBDNet server. It requires an active OBDNET_HANDLE.


2.3 Datalogging

Now that you are connected, it's time to get some data! To get the list of availble PIDs, use OBDNetGetPidList. This will call the OBDNET_CALLBACK_PID_LIST_ITEM callback for each PID.







3. Data Types

 

3.1 OBDNET_PID_VALUE

Usage:
Parameter values are returned using this structure. When you call OBDNetParameterGetCurrentValue it returns the PID data through this structure. Parameter data is also returned using this structure through the #define OBDNET_CALLBACK_STREAMING_PID_VALUE callback.

Syntax:
typedef struct
{
	unsigned long	PidValueType;
	unsigned long	TimeStamp;
	double		EnglishValue;
	double		MetricValue;
	const char *	EnglishValueString;
	const char *	MetricValueString;
	const char *	UniqueId;
} OBDNET_PID_VALUE;

Members:
PidValueType
The type of data that the structure contains. It will be either OBDNET_PID_VALUETYPE_NUMBER or POBDII_PID_VALUETYPE_STRING. This indicates whether EnglishValue, MetricValue is valid, or if EnglishValueString, MetricValueString is valid.
TimeStamp
The parameter's time stamp. The time stamp is the number of milliseconds since logging started.
EnglishValue
The English value if the PidValueType is POBDII_PID_VALUETYPE_NUMBER.
MetricValue
The Metric value if the PidValueType is POBDII_PID_VALUETYPE_NUMBER.
EnglishValueString
The English value if the PidValueType is POBDII_PID_VALUETYPE_STRING.
MetricValueString
The Metric value if the PidValueType is POBD_II_PID_VALUETYPE_STRING.
UniqueId
The unique ID that idenifies this PID. (i.e. "SAE.RPM")


 

3.2 OBDNET_PID_INFO

Usage:
Parameter information is returned using this structure when you call OBDNetParameterGetInfo.

Syntax:
typedef struct
{
	unsigned long Supported;
	unsigned long Priority;
	const char * UniqueId;
	const char * Name;
	const char * Category;
	const char * EnglishUnits;
	const char * MetricUnits;
} OBDNET_PID_INFO;

Members:
Supported
Indicates whether the PID is supported. Zero for not supported, non-zero for supported.
Priority
The priority of the PID. This determines how often the PID will be updated during normal data logging. This can be 1, 2, or 3. By default, priority 1 parameters are logged every frame, priority 2 parameters are logged every 10 priority 1 frames, and priority 3 parameters are logged every 5 priority 2 frames.
UniqueId
The unique ID that idenifies this PID. (i.e. "SAE.RPM")
Name
The name of the PID. (i.e. "Engine RPM")
Category
The category of the PID. (i.e. "Misfire")
EnglishUnits
The English units of the PID. (i.e. "MPH" or "RPM")
MetricUnits
The Metric units of the PID. (i.e. "KMH" or "RPM")


4. Callbacks

#define OBDNET_CALLBACK_PID_LIST_ITEM		0
#define OBDNET_CALLBACK_SELECTED_PID_ITEM	1
#define OBDNET_CALLBACK_STREAMING_PID_VALUE	2
 

4.1 OBDNET_CALLBACK_PID_LIST_ITEM

Usage:
This callback will be called once for every PID in the PID list when OBDNetParameterGetPidList is called.

Syntax:
typedef void (OBDNET_CALLBACK * OBDNET_CALLBACK_PID_LIST_ITEM_PROTOTYPE) (OBDNET_HANDLE OBDNetHandle, const char * lpszPidUniqueId);

Parameters:
OBDNetHandle
A handle to the OBDNet connection that the PID list is being retrieved for.
lpszPidUniqueId
The unique ID of a PID in the list.

Return Value:
This function does not return a value.


 

4.2 OBDNET_CALLBACK_SELECTED_PID_ITEM

Usage:
This callback will be called once for every PID in the PID list when OBDNetLoggingGetSelectedPidList is called.

Syntax:
typedef void (OBDNET_CALLBACK * OBDNET_CALLBACK_SELECTED_PID_ITEM_PROTOTYPE) (OBDNET_HANDLE OBDNetHandle, const char * lpszPidUniqueId);

Parameters:
OBDNetHandle
A handle to the OBDNet connection that the selected PID list is being retrieved for.
lpszPidUniqueId
The unique ID of a PID in the list.

Return Value:
This function does not return a value.


 

4.3 OBDNET_CALLBACK_STRAMING_PID_VALUE

Usage:
This callback will be called every time a streamed PID value is updated.

Syntax:
typedef void (OBDNET_CALLBACK * OBDNET_CALLBACK_STREAMING_PID_VALUE_PROTOTYPE) (OBDNET_HANDLE OBDNetHandle, const OBDNET_PID_VALUE * pPidValue);

Parameters:
OBDNetHandle
A handle to the OBDNet connection that the PID value is being retrieved for.
pPidValue
A pointer to the OBDNET_PID_VALUE structure containing the PID data.

Return Value:
This function does not return a value.


5. Functions

5.1 Initialization functions

 

5.1.1 OBDNetInitialize

Usage:
This function initializes OBDNet. It must be the first function you call. You pass this function an API type for the language you are coding in.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetInitialize(
	unsigned long ApiType,
	void * lpReserved
);

Parameters:
ApiType
The API type that you want to initialize. This parameter can be one of the following:

OBDNET_APITYPE_C_CPLUSPLUSC/C++ - This flag indicates you are coding in C or C++. OBDNet has no special handling for this lagnuage type.
OBDNET_APITYPE_VISUALBASICVisual Basic - This flag indicates you are coding in Visual Basic. OBDNet has special handling for string parameters and return values, so that they are properly constructed to interface with Visual Basic.

lpReserved
Reserved, pass NULL for this parameter.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.1.2 OBDNetUninitialize

Usage:
Call this function when you are done with OBDNet to uninitialize it. This must be the last function you call.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetUninitialize(
	void
);

Parameters:
--
This function takes no parameters.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


5.2 Creation functions

 

5.2.1 OBDNetCreate

Usage:
This function creates an OBDNET_HANDLE. This handle must be used for almost all other OBDNet functions.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetCreate(
	void
);

Parameters:
--
This function takes no parameters.

Return Value:
This function returns an OBDNET_HANDLE. This handle is required for most other OBDNet functions.


 

5.2.2 OBDNetDestroy

Usage:
Call this function when you are done with an OBDNET_HANDLE to destroy it.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetDestroy(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The handle to destroy.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


5.3 Status functions

 

5.3.1 OBDNetStatusGetErrorCodeString

Usage:
Call this function to get a text description for an error code returned by another OBDNet function.

Syntax:
const char * OBDNET_API OBDNetStatusGetErrorCodeString(
	OBDNET_STATUS ErrorCode
);

Parameters:
ErrorCode
The error code to retrieve the description for.

Return Value:
This function returns a string holding the description for the error code specified in theErrorCode parameter.


5.4 Debugging functions

 

5.4.1 OBDNetEnableDebugMode

Usage:
Often it is useful to record debugging information to send back to Palmer Performance Engineering for analysis. Use this function to enable debug logging. You should never enable debug logging unless you absolutely need it, as it negatively effects the performance of OBDNet.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetEnableDebugMode(
	const char * lpszTechlogFileName,
	unsigned long DebugLevel,
	BOOL EnableDebugTracing
);

Parameters:
lpszTechlogFileName
A string indicating the name of the file to save debug information in.
DebugLevel
The debug level, between 1 and 9.
EnableDebugTracing
Set this to true to enable debug tracing.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.4.2 OBDNetEnableSequentialWriting

Usage:
Please consult Palmer Performance Engineering before using this function.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetEnableSequentialWriting(
	BOOL EnableSequentialWriting
);

Parameters:
EnableSequentialWriting
Set this to true to enable sequential writing, false to disable.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.4.3 OBDNetDisableDebugMode

Usage:
This function is used to disable debug logging. Once debugging is disabled, you may email the techlog to Palmer Performance Engineering for analysis.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetDisableDebugMode(
	void
);


Parameters:
--
This function takes no parameters.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


5.5 Connection functions

 

5.5.1 OBDNetOpenConnection

Usage:
Use this function to open a connection to an OBDNet Server. The default port is 1301. The suggested timeout is 30-60 seconds.

Syntax:
POBDII_STATUS POBDII_API OBDNetOpenConnection(
			OBDNET_HANDLE OBDNetHandle,
			const char * lpszServer,
			unsigned long Port,
			unsigned long TimeoutInMilliseconds
);

Parameters:
OBDNetHandle
An OBDNET_HANDLE that was created by OBDNetCreate.
lpszServer
A string containing the IP address of the OBDNet server to connect to.
Port
The port number that the OBDNet server is listening on.
TimeoutInMilliseconds
The lenght of time, in milliseconds, that OBDNet will wait before declaring the connection failed.

Return Value:
This function returns POBDII_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.5.2 OBDNetCloseConnection

Usage:
Use this function to close a connection to an OBDNet server.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetCloseConnection(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The handle to the connection to close.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.5.3 OBDNetIsConnected

Usage:
Use this function to determine if the specified OBDNET_HANDLE is connected to an OBDNet server. It is possible for the connection to be lost without an explicit call to OBDNetCloseConnection.

Syntax:
BOOL OBDNET_API OBDNetIsConnected(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The handle in question.

Return Value:
This function returns true if the handle is connected, false otherwise.


5.6 Misc. functions

 

5.6.1 OBDNetWorker

Usage:
After you have established an OBDNet connection to a server, you must call this function regularly to perform processing work such as keeping the connection alive, and datalogging, etc. It is recommended to call this function from your main application loop. You may call this function even when you are not connected.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetWorker(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The hande to the connection to process.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.6.2 OBDNetSetCallback

Usage:
Use this function to set a callback. See Callbacks for more information.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetSetCallback(
	unsigned long CallbackNumber,
	void * pCallback
);

Parameters:
CallbackNumber
The ID for the callback you want to set. Can be any of the values defined in the callbacks section.
pCallBack
A pointer to the callback function.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.6.3 OBDNetSetWorkerTimeout

Usage:
Use this function to set the OBDNetWorker timeout.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetSetWorkerTimeout(
	OBDNET_HANDLE OBDNetHandle,
	unsigned long TimeoutInMilliseconds
);

Parameters:
OBDNetHandle
The OBDNET_HANDLE to modify.
TimeoutInMilliseconds
The desired timeout.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.6.4 OBDNetSetFunctionCallTimeout

Usage:
Use this function to set the function timeout.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetSetWorkerTimeout(
	OBDNET_HANDLE OBDNetHandle,
	unsigned long TimeoutInMilliseconds
);

Parameters:
OBDNetHandle
The OBDNET_HANDLE to modify.
TimeoutInMilliseconds
The desired timeout.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


5.7 Parameter functions

 

5.7.1 OBDNetParameterGetCount

Usage:
This function retrieves the total number PIDs available.

Syntax:
unsigned long OBDNET_API OBDNetParameterGetCount(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The OBDNET_HANDLE to retrieve the PID count for.

Return Value:
This function returns the total PID count for the specified OBDNET_HANDLE.


 

5.7.2 OBDNetParameterGetUniqueId

Usage:
Retrieves the unique ID for any PID currently available. For retrieving the entire list, it is more economical to use OBDNetParameterGetPidList.

Syntax:
const char * OBDNET_API OBDNetParameterGetUniqueId(
	OBDNET_HANDLE OBDNetHandle,
	unsigned long PidIndex
);

Parameters:
OBDNetHandle
The OBDNET_HANDLE to retrieve the PID unique ID from.
PidIndex
The index of the PID to retrieve the unique ID for. This must be between 0 and the value returned by OBDNetParameterGetCount.

Return Value:
This function returns the unique ID for the specified PID.


 

5.7.3 OBDNetParameterGetPidList

Usage:
This function will enumerate all available PIDs by calling the OBDNET_CALLBACK_PID_LIST_ITEM callback for each.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetParameterGetPidList(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The OBDNET_HANDLE to retrieve the PID list for.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.7.4 OBDNetParameterGetInfo

Usage:
Use this function to retrieve information about a PID (such as the units).

Syntax:
OBDNET_STATUS OBDNET_API OBDNetParameterGetInfo(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszUniqueId,
	OBDNET_PID_INFO * lpPidInfo
);

Parameters:
OBDNetHandle
The handle to the connection that contains the desired PID.
lpszUniqueId
The unique ID of the desired PID.
lpPidInfo
A pointer to an OBDNET_PID_INFO structure that will recieve the PID info.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.7.5 OBDNetParameterGetCurrentValue

Usage:
After connecting to an OBDNet server that is datalogging (or after starting datalogging), you can use this function to get PID data.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetParameterGetCurrentValue(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszUniqueId,
	OBDNET_PID_VALUE * lpPidValue
);

Parameters:
OBDNetHandle
A connected OBDNET_HANDLE.
lpszUniqueId
The unique ID of the desired PID data.
lpPidValue
A pointer to an OBDNET_PID_VALUE structure that will receive the PID data.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


5.8 Logging functions

 

5.8.1 OBDNetLoggingGetSelectedPidList

Usage:
This function is used to get the selected PID list. The list is returned using the OBDNET_CALLBACK_SELECTED_PID_ITEM callback.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingGetSelectedPidList(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The handle whose selected PID list is to be retrieved.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.2 OBDNetLoggingClearSelectedPidList

Usage:
This function is used to clear the selected PID list.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingClearSelectedPidList(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The handle that will get it's selected list cleared.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.3 OBDNetLoggingAddSelectedPid

Usage:
Use this function to add a PID to the selected PID list. Call this once for every PID you want to datalog.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingAddSelectedPid(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszPid
);

Parameters:
OBDNetHandle
This function adds a PID to the selected list of this handle..
lpszPid
The unique ID of the PID to start logging. Can be retrieved using OBDNetParameterGetUniqueId.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.4 OBDNetLoggingRemoveSelectedPid

Usage:
Use this function to remove a PID from the selected PID list. Call this once for every PID you want to stop datalogging.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingRemoveSelectedPid(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszPid
);

Parameters:
OBDNetHandle
This function adds a PID to the selected list of this handle..
lpszPid
The unique ID of the PID to stop logging. Can be retrieved using OBDNetParameterGetUniqueId.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.5 OBDNetLoggingGetMode

Usage:
Use this function to determine the host's datalogging status.

Syntax:
unsigned long OBDNET_API OBDNetLoggingGetMode(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
A connected OBDNET_HANDLE.

Return Value:
This function will return the current datalogging status on the OBDNet host. This can be OBDNET_LOGGINGMODE_UNKNOWN, OBDNET_LOGGINGMODE_STOPPED, OBDNET_LOGGINGMODE_MONITORING, or OBDNET_LOGGINGMODE_RECORDING.


 

5.8.6 OBDNetLoggingSetMode

Usage:
Use this function to set the datalogging mode.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingSetMode(
	OBDNET_HANDLE OBDNetHandle,
	unsigned long LoggingMode
);

Parameters:
OBDNetHandle
A connected OBDNET_HANDLE.
LoggingMode
The desired logging mode. This can be OBDNET_LOGGINGMODE_STOPPED, OBDNET_LOGGINGMODE_MONITORING, or OBDNET_LOGGINGMODE_RECORDING.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.7 OBDNetLoggingStartStreamingPid

Usage:
Use this function to start streaming a PID. The PID data will be recieved through the OBDNET_CALLBACK_STREAMING_PID_VALUE callback.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingStartStreamingPid(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszPid
);

Parameters:
OBDNetHandle
The OBDNet connection to stream from.
lpszPid
The unique ID of the PID to start streaming. Can be retrieved using OBDNetParameterGetUniqueId.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.8 OBDNetLoggingStopStreamingPid

Usage:
Use this function to stop streaming a PID.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingStopStreamingPid(
	OBDNET_HANDLE OBDNetHandle,
	const char * lpszPid
);

Parameters:
OBDNetHandle
The OBDNet connection to stop streaming from.
lpszPid
The unique ID of the PID to stop streaming. Can be retrieved using OBDNetParameterGetUniqueId.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.


 

5.8.9 OBDNetLoggingStopStreamingAllPids

Usage:
Use this function to stop streaming all PIDs.

Syntax:
OBDNET_STATUS OBDNET_API OBDNetLoggingStopStreamingAllPids(
	OBDNET_HANDLE OBDNetHandle
);

Parameters:
OBDNetHandle
The OBDNet connection to stop streaming from.

Return Value:
This function returns OBDNET_STATUS_SUCCESS if it succeeds, any other value on failure. Pass this value to OBDNetStatusGetErrorCodeString to get a text description of the error.