Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > Engine Management, OBD-II, Engine Diagnostics, etc. > OBDII GPS Logger


Reply
 
Share Thread Tools Display Modes
Old 06-17-2009, 02:41 AM   #1
Mod - OBDII GPS Logger forum
 
Join Date: Mar 2009
Location: Los Angeles
Posts: 523
chunkyks has a spectacular aura aboutchunkyks has a spectacular aura aboutchunkyks has a spectacular aura about
New Toy: obdsim

So, I tried a bunch of simulators out there, and found none of them were meeting my wishlist. Specifically, high on my wishlist is "must work from obdgpslogger logs and pretend that it's a real ELM device while doing it". That, and "command-line".

So, I decided to write a sim. The code borrows heavily from malcolm2073's ObdSim in this thread, a very friendly base to work from for which I am eternally grateful.

Here are some major features:

It works by consuming logfiles from obdgpslogger. If you don't have any, here's one.

It also has a pluggable [although only compile-time, and currently only done by editing build files] mechanism for pulling from other data streams. The first, proof-of-concept one I wrote was a random generator - it pulls numbers from random() every time. The default is now to use logs, but the random one is still there.

It honors ATE{1,0}, ATS{0,1}, ATZ, with more on the way. It's also case-insensitive.

It reads the database created by obdgpslogger, and when asked what it supports [via 0100/0120/0140/0160], it responds accurately with a list of what it found based on columns in the database. Short version, it really pretends to be the car the log was originally created in.

It interpolates values from the database, so if your original database was created with a samplerate of once-per-second, but you are connecting to it and sampling 20 times a second, you'll get a graph that looks exactly the same and has pretty good guesses at values. The opposite works too, obviously.

It's free (as in beer), and Free (as in speech). Thanks to Malcolm2073 again for doing the hard bits.

It's in the same repo as obdgpslogger (1). It's obviously first-and-foremost a tool for messing with obdgpslogger, but it doesn't depend on the logger itself [although it does depend on some other libraries in the same source tree]. This means that it works with OBDII software other than obdgpslogger. It does, though, provide a cheesy command-line option to let it take a stab at automatically launching obdgpslogger and connecting the logger to it.

It's in the same repo as obdgpslogger (2). I intend to keep it feature-compatible with obdgpslogger; as I add features to obdgpslogger, I will be adding features to the sim for testing it. As mentioned, the current set of AT commands is pretty limited, but it neatly matches the commands that obdgpslogger uses.

I think that's a good enough start.

Gary (-;
chunkyks is online now   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 06-17-2009, 09:06 AM   #2
Constant Bitrate
 
Join Date: Aug 2007
Location: Northern VA
Posts: 132
cgalpin is on a distinguished road
Excellent. I'll try check it out later this week!
cgalpin is offline   Reply With Quote
Old 06-19-2009, 01:01 PM   #3
Mod - OBDII GPS Logger forum
 
Join Date: Mar 2009
Location: Los Angeles
Posts: 523
chunkyks has a spectacular aura aboutchunkyks has a spectacular aura aboutchunkyks has a spectacular aura about
All,

As promised, I worked on the generator API a bit last night. Now obdsim is capable of having multiple generators linked in at the same time. Instructions on writing plugins are provided in src/sim/generators/README.generator [repeated below]. The short version is "copy generators/random/ to generators/{whatever}/, and edit to taste".

Code:
How to write a generator for obdsim Note: By convention, I will refer to the name of your generator-to-be as {generator}, or {GENERATOR} if you should uppercase it. 1) Start by looking at datasource.h It contains a struct, "obdsim_generator", containing functions you must implement. 2) The easiest generator to understand is in /generators/random/ Copy /generators/random/ to generators/{generator}/ 2a) Look at the C files It #includes "datasource.h", then creates the functions required by datasource.h. By convention, all the functions are named {generator}_simgen_{function}. At the end of the file, we create the obdsim_generator struct. 2b) Look at the CMakeInclude.cmake files Edit this and replace all instances of RANDOM with {GENERATOR}, and random with {generator} If you need extra libraries for your generator, add them similarly at the end of GENERATOR_LIBS 3) Open sim/obdsim.c Your plugin should be added in two places, both near the top of the file: first, an extern to declare it without #including anything. second, added to the list of available_generators. Note that each instance is wrapped with #ifdef OBDSIMGEN_{GENERATOR} Project-wide conventions: If your generator will add external dependencies, it should default to Off. Gary "Chunky Ks" Briggs <chunky@icculus.org>

Step 3 is obviously the slightly cheesy C workaround. If anyone has a better way of doing it, I'm open to suggestion. The rest of it is pretty easy, a big case of monkey-see-monkey-do. I'm likely to make the CMakeInclude files easier to edit by some simple substitutions, but that won't change anything important.


The output of --help now appears thus:
Code:
Usage: ../bin/obdsim [params] [-s|--seed=<generator-specific-string>] [-g|--generator=<name of generator>] [-o|--launch-logger] [-v|--version] [-h|--help] The generators built into this sim: "Random" "Logger" (default)

It's also not too late to get in requests for changes to the API. The current version is here: http://svn.icculus.org/obdgpslogger/....h?view=markup. As I see it, there's two things that might be worth changing:
1) The build system, specifically a better way of working around step 3 in the instructions. In C++, I would use a linked list and some macros so that generators get added during static initialisation. I don't know of a pattern like that that works in C, though.
2) The API itself. It's not too late to get in requests for API changes. I'm currently considering two more functions:
a) one to get a human-friendly description of the seed for end-user help [eg, the one for logger would be "Filename of obdgpslogger logfile"].
b) An idle-type callback. Currently the sim blocks on reading lines from the pty. This was easier to code [a lot!] than a nonblocking version. The problem is that when you want to write a GUI data generator.

There are two ways to write a GUI data generator for this;
1) Spawn a thread in the generator_create function and run the UI from that [generally running UIs out of your non-main thread is a Bad Idea(TM), although it will work fine for some of them, or in most cases...].
2) Add an idle callback in obdsim. Use nonblocking reads from the pty, and whenever obdsim has nothing better to do, it calls that idle callback. This is great for GUIs, since you can just shove a call to wxYield(), FL::check(), QApplication:rocessEvents(), etc.

Feedback is welcome. In fact, more than welcome, I really need help and advice of developers here :-)

It also occurs to me that an idle callback would be more useful in the case of, say, a dbus plugin which can continue consuming signals while it has nothing better to do.

Gary (-;

Last edited by chunkyks; 06-19-2009 at 01:04 PM.
chunkyks is online now   Reply With Quote
Old 06-20-2009, 09:50 AM   #4
Constant Bitrate
 
Join Date: Aug 2007
Location: Northern VA
Posts: 132
cgalpin is on a distinguished road
Works just like it says on the tin!

#2++
cgalpin is offline   Reply With Quote
Old 06-29-2009, 10:20 PM   #5
Mod - OBDII GPS Logger forum
 
Join Date: Mar 2009
Location: Los Angeles
Posts: 523
chunkyks has a spectacular aura aboutchunkyks has a spectacular aura aboutchunkyks has a spectacular aura about
So it's super cheesy and ugly right now, but...



It's a gui plugin for obdsim. The sim is on the right [you can see obdsim announcing the pty it created in the terminal], and on the left is obdgpslogger [where you can see I gave it the pty created by the sim]

Woooo

Gary (-;
chunkyks is online now   Reply With Quote
Old 06-30-2009, 12:47 AM   #6
Mod - OBDII GPS Logger forum
 
Join Date: Mar 2009
Location: Los Angeles
Posts: 523
chunkyks has a spectacular aura aboutchunkyks has a spectacular aura aboutchunkyks has a spectacular aura about
Up to five plugins now:
Code:
kibbles-2:build chunky$ ../bin/obdsim --help Usage: ../bin/obdsim [params] [-s|--seed=<generator-specific-string>] [-g|--generator=<name of generator>] [-o|--launch-logger] [-v|--version] [-h|--help] The generators built into this sim: "Random" (default) "Logger" "DBus" "dlopen" "gui_fltk" kibbles-2:build chunky$

Gary (-;
chunkyks is online now   Reply With Quote
Old 07-01-2009, 09:40 PM   #7
Constant Bitrate
 
Join Date: Aug 2007
Location: Northern VA
Posts: 132
cgalpin is on a distinguished road
Nice work. I've gotten busy but will test it out later this week.

charles
cgalpin is offline   Reply With Quote
Old 07-02-2009, 12:04 PM   #8
Mod - OBDII GPS Logger forum
 
Join Date: Mar 2009
Location: Los Angeles
Posts: 523
chunkyks has a spectacular aura aboutchunkyks has a spectacular aura aboutchunkyks has a spectacular aura about
Coo, have fun :-)

Gary (-;
chunkyks is online now   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
IGNav (New toy for the new year) Champak General MP3Car Discussion 11 03-10-2008 06:38 PM
new toy - wifi card w/ external antenna warnockm Wireless Communications 3 08-13-2006 01:30 AM
my new toy scott_fx Off Topic 2 07-14-2006 10:01 PM
Another toy by MindTool: MindCalm mindtool MediaCar 34 12-10-2003 02:12 PM
Built a box today for my new toy! outragis General MP3Car Discussion 2 09-15-2003 08:25 AM



All times are GMT -5. The time now is 11:36 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.2
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics