Welcome to the MP3Car.com forums.
You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. Registering will also remove advertisements. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!
If you have any problems with the registration process or your account login, please contact contact us.
|
04-13-2005, 06:38 PM
|
#16
|
|
9 Fingered Administrator Lesbian
Join Date: Jan 2003
Location: Ruston, LA
Vehicle: 1998 Ranger/1991 Sunbird
Posts: 9,852
|
Quote: Originally Posted by Erorus
Glad to hear it's truly multithreaded.. that's how one should write stuff like this that writes asynchronously to a port. (My VB6 class isn't multithreaded b/c VB6 can't really do threads.)
Instead of waiting 300ms to send the next command, may I suggest just waiting until you get the ELM's prompt ">" back and then send the next command then? I think the ELM won't send a prompt if it can't accept the command; correct me if I'm wrong.
Any luck using the ELM in binary mode? Supposedly it's a little faster but I didn't have the patience to code for it.
Finally, there's gotta be some .NET class for serial I/O where you don't have to rely on an ancient ActiveX component. I have little .NET experience so I can't really help find it, but there's got to be something out there.
The 2.0 betas have native .NET serial libraries I believe.
__________________
FrodoPlayer.com
TeaBaggins.com
[H]4 Life
My next generation Front End is right on schedule.
It will be done sometime in the next generation.
I'm a lesbian too.
I am for hire!
|
|
|
04-13-2005, 09:01 PM
|
#17
|
|
Newbie
Join Date: Feb 2005
Posts: 13
|
Hey guys,
Here are the sceen shots from the app i made. I used C# and driect3D for the gauges. For the serial interface I used a winapi wrapper. I'd be glad to help out with the development and share my code if anyone would like.
Let me know what you think about the gauges. It took me a while to construct the meshes. This was my first direct3d project.
-joe
|
|
|
04-13-2005, 09:31 PM
|
#18
|
|
FLAC
Join Date: Jan 2004
Posts: 1,348
|
You're a stupid DUMBASS for using OBD-II (which is worthless) to measure RPM! I RULE YOU! Suck it. Suck it dry!
heh, the thread felt empty without JTP, thought I'd fill in for him since he's missing. Looks nice! Which interface? ELM?
|
|
|
04-13-2005, 10:13 PM
|
#19
|
|
Newbie
Join Date: Feb 2005
Posts: 13
|
yeah ELM. I've only tested with elm 323, I only have japanese cars for testing.
Why would i even need RPMs its right there on the dash  .
This systems does work on a threaded model that waits for the > signal from the chip to trigger the next data request.
|
|
|
06-19-2006, 09:36 PM
|
#20
|
|
Newbie
Join Date: May 2006
Location: Florida
Vehicle: 2001 VW PASSAT
Posts: 1
|
OBD2 Speed RPM
Hello I have a quick question regarding OBD2 I have wrote a little interface to return rpm and speed problem is how do you return BOTH
I have tried everything 2 different timers and a million different things.
Please send some samples of how to poll RPM and SPEED at the same time in .net
|
|
|
06-19-2006, 10:13 PM
|
#21
|
|
Constant Bitrate
Join Date: Oct 2005
Location: Livonia, MI
Vehicle: 2003 Mustang GT
Posts: 147
|
With OBD-II you're allowed only one outstanding request. Try using a mutex to prevent your timers or threads from accessing the vehicle simultaneously. Also if there's more than one ECU on the vehicle, you should wait for all responses before submitting a second request.
Typically it's easier to keep your code single threaded. I've created several .NET examples for Mongoose. Here's a snippet of how I make an OBD-II request on J1850VPW:
Code:
uint ProtocolID = J1850VPW;
// Clear any messages received before this request
PassThruIoctl(ChannelID, CLEAR_RX_BUFFER, NULL, NULL);
// Mode 01: Request vehicle data
numMsgs = 1;
Msg[0].ProtocolID = ProtocolID;
Msg[0].TxFlags = 0;
Msg[0].Data[0] = 0x68; // Header
Msg[0].Data[1] = 0x6A;
Msg[0].Data[2] = 0xF1;
Msg[0].Data[3] = 0x01; // Mode 01: Request vehicle data
Msg[0].Data[4] = PID; // PID: 8-bit
Msg[0].DataSize = 5;
PassThruWriteMsgs(ChannelID, Msg, ref numMsgs, 100);
// Wait P2_J1850_MAX (100ms) for a response from the ECU
timestamp = (uint) Environment.TickCount;
while (((uint) Environment.TickCount - timestamp) < 100)
{
numMsgs = 3;
PassThruReadMsgs(ChannelID, InMsg, ref numMsgs, 100);
for (i=0; i < numMsgs; i++)
{
if ((InMsg[i].RxStatus & (ISO15765_PADDING_ERROR | TX_DONE | RX_BREAK | START_OF_MESSAGE | TX_MSG_TYPE)) == 0)
{
if ((InMsg[i].Data[3] == (mode + 0x40)) && (InMsg[i].Data[4] == PID))
{
// Valid response. Restart the P2_MAX timeout.
timestamp = (uint) Environment.TickCount;
// Should improve this code to wait for other ECUs instead of returning immediately.
switch (size)
{
case 1:
value = (UInt32) InMsg[i].Data[5];
return PASS;
case 2:
value = (UInt32) (InMsg[i].Data[5] << 8) | InMsg[i].Data[6];
return PASS;
case 4:
value = ((UInt32) InMsg[i].Data[5] << 24) | ((UInt32) InMsg[i].Data[6] << 16) | ((UInt32) InMsg[i].Data[7] << 8) | (UInt32) InMsg[i].Data[8];
return PASS;
default:
// This code handles only 1, 2, and 4 byte responses.
value = 0;
return FAIL;
}
}
}
}
}
// We exited the loop for a timeout. Indicate failure.
value = 0;
return FAIL;
|
|
|
07-15-2007, 11:08 PM
|
#22
|
|
Newbie
Join Date: Jun 2007
Posts: 16
|
Anyway of changing this code for VB^?
I have not used .net and this is the issue I am running into, I need a way to hold second mscomm command until receiving reply from first (and holding third command until receiving reply from second etc etc)
Quote: Originally Posted by joeyoravec 
With OBD-II you're allowed only one outstanding request. Try using a mutex to prevent your timers or threads from accessing the vehicle simultaneously. Also if there's more than one ECU on the vehicle, you should wait for all responses before submitting a second request.
Typically it's easier to keep your code single threaded. I've created several .NET examples for Mongoose. Here's a snippet of how I make an OBD-II request on J1850VPW:
Code:
uint ProtocolID = J1850VPW;
// Clear any messages received before this request
PassThruIoctl(ChannelID, CLEAR_RX_BUFFER, NULL, NULL);
// Mode 01: Request vehicle data
numMsgs = 1;
Msg[0].ProtocolID = ProtocolID;
Msg[0].TxFlags = 0;
Msg[0].Data[0] = 0x68; // Header
Msg[0].Data[1] = 0x6A;
Msg[0].Data[2] = 0xF1;
Msg[0].Data[3] = 0x01; // Mode 01: Request vehicle data
Msg[0].Data[4] = PID; // PID: 8-bit
Msg[0].DataSize = 5;
PassThruWriteMsgs(ChannelID, Msg, ref numMsgs, 100);
// Wait P2_J1850_MAX (100ms) for a response from the ECU
timestamp = (uint) Environment.TickCount;
while (((uint) Environment.TickCount - timestamp) < 100)
{
numMsgs = 3;
PassThruReadMsgs(ChannelID, InMsg, ref numMsgs, 100);
for (i=0; i < numMsgs; i++)
{
if ((InMsg[i].RxStatus & (ISO15765_PADDING_ERROR | TX_DONE | RX_BREAK | START_OF_MESSAGE | TX_MSG_TYPE)) == 0)
{
if ((InMsg[i].Data[3] == (mode + 0x40)) && (InMsg[i].Data[4] == PID))
{
// Valid response. Restart the P2_MAX timeout.
timestamp = (uint) Environment.TickCount;
// Should improve this code to wait for other ECUs instead of returning immediately.
switch (size)
{
case 1:
value = (UInt32) InMsg[i].Data[5];
return PASS;
case 2:
value = (UInt32) (InMsg[i].Data[5] << 8) | InMsg[i].Data[6];
return PASS;
case 4:
value = ((UInt32) InMsg[i].Data[5] << 24) | ((UInt32) InMsg[i].Data[6] << 16) | ((UInt32) InMsg[i].Data[7] << 8) | (UInt32) InMsg[i].Data[8];
return PASS;
default:
// This code handles only 1, 2, and 4 byte responses.
value = 0;
return FAIL;
}
}
}
}
}
// We exited the loop for a timeout. Indicate failure.
value = 0;
return FAIL;
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Confused about OBD II |
tom2112 |
Engine Management, OBD-II, Engine Diagnostics, etc. |
30 |
10-19-2007 01:06 AM |
| Skinnable OBD II Software |
antimatter |
Engine Management, OBD-II, Engine Diagnostics, etc. |
374 |
08-11-2006 08:55 PM |
| Looking for Non ELM software for OBD II |
Refael Azi |
Engine Management, OBD-II, Engine Diagnostics, etc. |
13 |
07-19-2006 10:32 AM |
| my OBD II Software |
kocke |
Engine Management, OBD-II, Engine Diagnostics, etc. |
8 |
04-06-2005 02:53 PM |
| obd II datalogger building and software |
backpack09 |
Off Topic |
2 |
08-22-2002 08:03 PM |
All times are GMT -5. The time now is 04:36 PM.
|
|