Results 1 to 8 of 8

Thread: OBDSim help?

  1. #1
    Newbie preet's Avatar
    Join Date
    Sep 2009
    Location
    Canada eh
    Posts
    43

    OBDSim help?

    Hey,

    First of all, wanna say thanks to chunkyks for such a useful piece of software. I'm tired of freezing my butt off in the car to test every little code change I do. I'm trying to simulate generic obd over can through the ELM. On my local device, the init sequence goes something like...

    AT Z
    AT SP 6 // set protocol to iso 15765
    AT AT2 // set aggressive timing
    AT D1 // set can dlc display
    AT H1 // set show headers
    AT CAF1 // set can auto formatting

    then comm is typically

    AT SH // set header
    // data reqs

    I can't get set protocol to work... how do I use it? Using this link: http://icculus.org/obdgpslogger/manp...der/obdsim.txt as reference.

    Preet

    ---------- Post added at 02:46 PM ---------- Previous post was at 02:28 PM ----------

    To make this post more useful, I've thrown up the input/output.

    http://www.pastebin.com/miNEi27G

    Corresponding terminal output:
    Code:
    Successfully initialised obdsim, entering main loop
    Reset
    Adaptive Timing: 2
    Defaults
    Headers Enabled
    Last edited by preet; 03-23-2011 at 02:42 PM.

  2. #2
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    HeyHey,

    The protocol should be being set, but there wasn't a message about it on the console before [although the software sending the ATSP command would have received an "OK"].

    I've added the relevant printf in the current svn.

    Thanks,
    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

  3. #3
    Newbie preet's Avatar
    Join Date
    Sep 2009
    Location
    Canada eh
    Posts
    43
    Hey,

    Thanks for the update

    I have another question for you -- It seems like the max update rate I can get from the sim'd ECU is 5Hz. Can I increase this somehow? I'm using the Cycle generator btw.

    Regards,

    -Preet

  4. #4
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    Sure. It's easy to increase samplerate, and several ways to do it [ranging from "this is the Correct Thing To Do (TM)" to "sure, just tell obdsim to make the delays lower"]

    1) OBDSim recognises the elm327 v1.3+ optimisation of specifying the number of bytes you expect to be returned.

    If you specify this, it'll return you results without waiting for a virtual ECU timeout.

    This is the correct way to fix the problem in general; you need to check to see if the device is ELM327 1.3+ compliant, and use that parameter. It's detailed in the elm327 datasheet, but the short version is pass an extra byte dictating how many values you're expecting to be returned. Typical usage will look like:
    Code:
    01 0C 2
    [to indicate you're expecting two bytes to measure RPM, instead of the normal "01 0C"]

    2) OBDSim honors adaptive timing

    ... well, vaguely. It's hard/impossible to do correctly in software, the manpage describes valid values for ATAT{0,1,2} as meaning "off/on/vigorous". Call it thus to reduce timeouts:
    Code:
    ATAT2
    It's worth noting [doesn't *everything* have a caveat?] that this may or may not be wise to rely on in real cars.

    3) OBDSim honors the concrete "timeout" AT parameter

    From the manpage: "ST{n} Set timeout. Hex value is multiplied by 4, and measured in ms"
    This lowers the timeout on results being returned. Again, just setting this value may have negative effects in real vehicles. [eg, if the ECU doesn't respond by the timeout]. This is kinda superceded by the actual ECU timeout:

    4) Each ECU in the sim has its own virtual timeout.

    That's set on the command-line using the -d parameter. For example:
    Code:
    obdsim -g Cycle -d 1000
    That will create one ECU in the sim, "Cycle", with a 1 second timeout. IIRC, setting a timeout using the ATST parameter less than the ECU's timeout actually does the right thing and fails to return valid values.

    And because this is a long email of caveats, be warned that the older spec [pre-APR2002, IIRC] dictates that you shouldn't expect more than ten useful samples a second, ever, in cars that adhere to it. IME, you can attempt to sample faster, you just don't get results back in time.

    Gary (-;

    PS I also suggest not using Cycle. It's the default, and returns values, but I might not necessarily accuse them of being sensible. I would highly recommend using the "Logger" generator, with a valid logfile. If you'd like a workable logfile, albeit one with fairly few parameters available, I usually use this: ces2010.db. It's a log of me driving my mini to Vegas.

    ---------- Post added at 10:34 PM ---------- Previous post was at 10:24 PM ----------

    Oh, and I just re-read your original post:
    Code:
    Successfully initialised obdsim, entering main loop
    Reset
    Adaptive Timing: 2
    Defaults
    Headers Enabled
    Sounds like you're already calling ATAT2, but by calling ATD after you're resetting that back to the default 1.

    Gary (-;
    Last edited by chunkyks; 05-15-2011 at 01:27 AM.
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

  5. #5
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    Oh, oops. It's not defaults, it's ATD1. I've written what I think is valid code to support that, but I gotta check it on some hardware before committing it.

    Either way, that should go in later today sometime

    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

  6. #6
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    OK, ATD1 is in SVN. I've tried to match the output I see with my hardware I have sitting here. I've started a discussion here about it:
    http://www.mp3car.com/engine-managem...1-non-can.html

    If ATD1 is really meant to work with other protocols than CAN, the code is easy to do [I had it in earlier, but that didn't align with what my hardware's doing]

    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

  7. #7
    Newbie preet's Avatar
    Join Date
    Sep 2009
    Location
    Canada eh
    Posts
    43
    Hey,

    Thanks for all the updates!

    I have a couple more questions/notes...

    I seem to be doing something that makes obdsim stop responding. It doesn't freeze, I just don't get the ready response '>' back. A few responses get through, but then it locks. This happens when:

    1) I explicitly specify the number of bytes expected for each response
    2) I send more than one type of pid request (in the attached example, I'm sending vehicle speed & engine speed requests).

    Sent:
    Code:
    14:30:24.269:	AT Z
    14:30:25.275:	AT E0
    14:30:25.278:	AT S0
    14:30:25.282:	AT SP 6
    14:30:25.286:	AT ST 6
    14:30:25.291:	AT AT1
    14:30:25.295:	AT D0
    14:30:25.298:	AT H1
    14:30:26.872:	01 0C2
    14:30:26.873:	01 0D1
    14:30:26.920:	01 0C2
    14:30:26.922:	01 0D1
    14:30:26.960:	01 0C2
    14:30:26.961:	01 0D1
    14:30:27.006:	01 0C2
    14:30:27.007:	01 0D1
    14:30:27.166:	01 0C2
    14:30:27.167:	01 0D1
    14:30:27.399:	01 0C2
    14:30:27.403:	01 0D1
    14:30:27.471:	01 0C2
    14:30:27.474:	01 0D1
    14:30:27.500:	01 0C2
    14:30:27.503:	01 0D1
    14:30:27.557:	01 0C2
    14:30:27.559:	01 0D1
    14:30:27.629:	01 0C2
    14:30:27.634:	01 0D1
    14:30:27.655:	01 0C2
    14:30:27.659:	01 0D1
    14:30:27.714:	01 0C2
    14:30:27.718:	01 0D1
    14:30:27.763:	01 0C2
    Received:
    Code:
    14:30:24.271:	AT Z
    14:30:25.275:	ELM327 v1.3a OBDGPSLogger >
    14:30:25.278:	AT E0 OK >
    14:30:25.282:	OK >
    14:30:25.286:	OK >
    14:30:25.290:	OK >
    14:30:25.295:	OK >
    14:30:25.298:	OK >
    14:30:25.302:	AT H1 OK >
    14:30:26.873:	01 0C2 7E8 04 41 0C 07 D1 D8 >
    14:30:26.878:	01 0D1 7E8 03 41 0D 2A 2A >
    14:30:26.922:	01 0C2 7E8 04 41 0C 08 B6 BE >
    14:30:26.926:	01 0D1 7E8 03 41 0D 2A 2A >
    14:30:26.961:	01 0C2 7E8 04 41 0C 09 76 7F >
    14:30:26.966:	01 0D1 7E8 03 41 0D 2B 2B >
    14:30:27.007:	01 0C2 7E8 04 41 0C 0A 53 5D >
    14:30:27.011:	01 0D1 7E8 03 41 0D 2B 2B >
    14:30:27.167:	01 0C2 7E8 04 41 0C 0D 51 5E >
    14:30:27.170:	01 0D1 7E8 03 41 0D 2D 2D >
    14:30:27.403:	01 0C2 7E8 04 41 0C 11 B0 C1 >
    14:30:27.406:	01 0D1 7E8 03 41 0D 2F 2F >
    14:30:27.474:	01 0C2 7E8 04 41 0C 13 0B 1E >
    14:30:27.478:	01 0D1 7E8 03 41 0D 2F 2F >
    14:30:27.503:	01 0C2 7E8 04 41 0C 13 93 A6 >
    14:30:27.507:	01 0D1 7E8 03 41 0D 2F 2F >
    14:30:27.559:	01 0C2 7E8 04 41 0C 14 A6 BA >
    14:30:27.563:	01 0D1 7E8 03 41 0D 30 30 >
    14:30:27.634:	01 0C2 7E8 04 41 0C 16 01 17 >
    14:30:27.638:	01 0D1 7E8 03 41 0D 30 30 >
    14:30:27.659:	01 0C2 7E8 04 41 0C 16 7D 93 >
    14:30:27.662:	01 0D1 7E8 03 41 0D 31 31 >
    14:30:27.718:	01 0C2 7E8 04 41 0C 17 98 AF >
    14:30:27.722:	01 0D1 7E8 03 41 0D 31 31 >
    14:30:27.763:	01 0C2 // stops here! No response or '>' prompt
    Notes:
    * I tried setting a default timeout (AT ST) to see if it changed anything, but it didn't; this occurs whether or not AT ST is explicitly set to anything (it shouldn't change anything since I'm specifying number of expected bytes).

    * I turned off echo... this seems to work for elm commands but I still see my obd requests echoed back. This isn't an issue but just thought I'd mention it.

    * This doesn't happen if I only send requests for one PID (ie. only engine speed or only vehicle speed, etc). This also doesn't happen if I don't specify the number of bytes in advance.

    -Preet

  8. #8
    SuperMod - OBDII GPS Logger forum
    Auto Apps:loading...

    Join Date
    Mar 2009
    Location
    Los Angeles
    Posts
    924
    I turned off echo... this seems to work for elm commands but I still see my obd requests echoed back. This isn't an issue but just thought I'd mention it.
    This doesn't seem to be happening here [# is my comments, added after]:
    Code:
    >ATRV
    12.1
    >0100
    41 00 FF FF FF FF
    >ATE0
    OK
    >   # I typed "ATRV" and hit enter, here
    11.7
    >   # I typed "0100" and hit enter, here
    41 00 FF FF FF FF
    >
    I think what's happening is that obdsim is recognising the "ATD0" you send as "ATD", and resetting to defaults. That's why it goes back to echoing, and puts spaces back in. ATH1 works because it's after the ATD0 you send.

    I've updated the code in SVN to recognise ATD0/1; could you try doing an SVN update and see if that problem goes away after a clean rebuild? [what platform are you on, by the way?]


    As for the other problem:

    Running obdgpslogger at maximum sampling rate, I'm seeing a sample rate of ~500 PIDs per second, without the problem you see there.

    Assuming you're on linux, OSX, Cygwin [something that obdgpslogger builds on!], please could you try something like this:
    Code:
    obdgpslogger -t -s /dev/pts/4  -i 0C,0D -o -a0
    And see if the problem manifests there? ["-t" spams stdout with results, "-s /dev/pts/4" will be whatever obdsim is creating for you, "-i 0C,0D" logs the two PIDs you do above, "-o" enabled optimisations [digit on the end], and -a0 tells it to sample as fast as it can]


    Now that I look at it, I'm wondering if you're actually sending the last carriage return; I only see the command you're sending, and absolute silence from obdsim other than the echo. You'd see that if the carriage return doesn't get sent.

    Gary (-;
    OBDGPSLogger, for logging OBDII and/or GPS data
    OBDSim, an OBDII/ELM327 software simulator
    mp3car forums: obdgpslogger, obdsim

Similar Threads

  1. OBDsim with FB
    By nemo1 in forum OBDSim
    Replies: 2
    Last Post: 10-25-2010, 10:33 PM
  2. What is OBDSim?
    By chunkyks in forum OBDSim
    Replies: 0
    Last Post: 09-20-2010, 03:26 PM
  3. OBDSim on Windows
    By chunkyks in forum OBDSim
    Replies: 0
    Last Post: 09-20-2010, 03:24 PM
  4. CF with my OBDSim
    By chunkyks in forum Centrafuse
    Replies: 0
    Last Post: 09-15-2010, 03:02 PM
  5. New Toy: obdsim
    By chunkyks in forum OBDII GPS Logger
    Replies: 7
    Last Post: 07-02-2009, 12:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •