This project is read-only.

Need some help with DotSpatial.Positioning

Oct 23, 2012 at 8:14 AM

I've created a little windows service using DotSpatial that acts as a location data provider for another application. What I do not fully comprehend is the logic behind the (serial) device cache.

When my service is running without devices I attempt device detection every 2 minutes. If this goes on for too long the failed detection count for unused ports skyrockets, after which DotSpatial never attempts to open those ports again, even though a GPS device may be connected.

Is there a flush method for this (registry)cache? I have tried calling undetect on shutdown of my application, but it oftentimes throws exceptions if the key it is trying to delete is not found. That this exception isn't caught by the dotspatial code surprises me, since it is not a critical error.

Furthermore, can anyone explain to me why my serial port cache always has 2 entries per port? 1 with and 1 without ':' postfix. One of those 2 causes exceptions when dotspatial tries to open the ports.

Oct 23, 2012 at 3:24 PM

After diving into the source code I downloaded maybe 2 months ago I can see the following things happening:

-DotSpatial always loads the entire device cache from registry at startup. It first uses a command called clearcache, which only wipes the internal storage, but the registry cache is left untouched. Bit of a confusing use of the term cache there.

-If I have serial port 65 in my cache (for example), it will try to open it during device detection, even if I specify my maxserialportnr as 30. Seems it just uses the entire registry cache regardless of explicit settings. Bit sloppy this.

-I Found out why I get port entries with and without ':' postfix. You might consider removing the wrong ones from the internal cache after trying them and noticing the nasty exceptions they throw. Saves all the mess during device detection (it just repeatedly tries out rubbish port entries).

-I cant find any method that resets the fail count in the registry, so that leaves me with unusable ports after N passes of device detection.

-A possible remedy to above problem would be to run undetect before starting device detection, but considering I want my code to stay stable for extended periods of time it is only a stopgap measure as I would only be inclined to call this on startup.

-The undetect method is not robust enough and fails if I throw away some registry keys manually. Proper software should be prepared for these types of situations. An exception occurs because it cant throw away a key that it is assuming is there. Exactly why I would want this method to stop when it cant throw away an item that is already removed is beyond me, isn't that what it is trying to accomplish in the first place?

 

I might sound overly critical, but I like the dotspatial framework and think any good thing can benefit from honest criticism. I will just patch up the problem areas for myself unless someone here tells me I'm a pompous idiot and points out mistakes in my conclusions (please feel free to do so!).