Updated Devicelink Wrapper class.

Forum for the discussion of Device Link

Updated Devicelink Wrapper class.

Postby WWSensei on Thu Jan 19, 2006 4:53 pm

From the Readme:
Devicelink Wrapper Version 2.1.

In this zip file I included the devicelink.cpp and devicelink.h wrapper class files. You can link these in directly to your project. There is also a sample config.ini file as well. You will need to include the Winsock library in your project file.

Changes:
Most of the functions are commented. I didn't include all the possible devicelink commands in the headers as I tend to create them as I need but there is enough there to use as an example if you add more. I did include functions to retrieve engine data and cleaned up the code some more. Mainly added a lot more error trapping and debugging messages as well as eliminating several potential buffer overflow vulnerabilities. The natural question is why didn't I use STL for strings if I wanted to stay away from buffer overflows? Performance was the main reason and that Microsoft's STL (based on Dinkumware) is out of date and I didn't want to hassle with updating it and/or relying on other programmers to update their copies.

Most of the issues could be addressed by simply checking buffers and limiting writes to them.

Other big change was I added a CritSec class and a thread lock class to make the library thread-safe. I launch no threads of my own (and hope to keep it that way) but this should make the primitives and private vars thread safe. I made the Lock destructor take care of executing the thread unlock. Should keep any exceptions you throw from blocking and causing
a race condition. I find that even if you are careful to match Enter and Leave on thread locking you can still get hung on the odd exception. If that bubbles out to the OS you might even get a hard lock. A Bad Thing--"Be sure". ;-)

I cleaned up the Debug Output as well. By default it provides no output to either the stderr or a debug file. However, if you define DEBUG_OUTPUT then it will default to writing debug messages to std_err. If you call Init() with a filename instead of nothing then it will output the debug to the specified file.

As time goes on I will be updating this from time to time. Mostly adding new functions and will strive to make it backwards compatible.

This new version should be compatible with previous versions. I added to the API but did not eliminate any old methods (except ones that weren't used.)

Finally, yes, in retrospect there are at least 10 things I would have done differently (like better object/class definitions of various parts), but I wasn't out to make Xerox Parc proud of work. I considered this to be one low level "channel" class of communication rather than a pure "airplane object" class.

Now, for the legal stuff.

Use at your own risk. You break something don't blame me. I've provided the raw code so you can examine it yourself. You are allowed to re-use this code in any product private or commercial I only ask that I receive credit if you do. I would also appreciate any feedback on bugs you find. If you add more functions send them back to me and I will include
them in the next release.

WWSensei

http://www.wingwalkers.org


Click Here
WWSensei
Flight Sergeant
 
Posts: 88
Joined: Sun Dec 12, 2004 2:53 pm

Return to Device Link

Who is online

Users browsing this forum: No registered users and 3 guests

cron