|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
patch: delbin, detect when waypoint count exceeds device limitI've noticed some geocachers complaining that waypoints are silently
dropped if the device limit (currently 1000) is reached. While it is in general not possible to detect this perfectly without consuming an inordinate amount of time (re-reading all the waypoints and comparing against what was sent), we can detect when it has _probably_ happened and at least print out a warning. Index: delbin.c =================================================================== --- delbin.c (revision 27) +++ delbin.c (working copy) @@ -127,6 +127,9 @@ // Whether device understands message 0xb016 static int use_extended_notes; +// Device capabilities +static unsigned device_max_waypoint; + static const char* waypoint_symbol(unsigned index); static unsigned waypoint_symbol_index(const char* name); static int track_color(unsigned index); @@ -143,6 +146,7 @@ #define MSG_ACK 0xaa00 #define MSG_BREAK 0xaa02 #define MSG_BREAK_SIZE 33 +#define MSG_CAPABILITIES 0xb001 #define MSG_DELETE 0xb005 #define MSG_DELETE_SIZE 67 #define MSG_NAVIGATION 0xa010 @@ -182,7 +186,6 @@ //----------------------------------------------------------------------------- // Message structures - // Input Delete Message // Message ID: 0xB005 typedef enum { @@ -418,6 +421,24 @@ char extra[16]; } msg_version_t; +// Output Device Capabilities Message +// Message ID: 0xB001 +typedef struct { + gbuint8 max_waypoints[4]; // U32 + gbuint8 max_tracks[2]; // U16 + gbuint8 max_track_points[4]; // U32 + gbuint8 max_routes[2]; // U16 + gbuint8 max_route_points[4]; // U32 + gbuint8 max_route_shape_points[4]; // U32 + gbuint8 max_maps[2]; // U16 + gbuint8 min_map_version[2]; // U16 + gbuint8 max_map_version[2]; // U16 + gbuint8 total_internal_file_memory[4]; // U32 + gbuint8 avail_internal_file_memory[4]; // U32 + gbuint8 total_external_file_memory[4]; // U32 + gbuint8 avail_external_file_memory[4]; // U32 +} msg_capabilities_t; + //----------------------------------------------------------------------------- #if __APPLE__ || __linux @@ -1359,10 +1380,37 @@ static void write_waypoints(void) { + message_t m; + unsigned device_n = 0; + waypoint_i = 0; waypoint_n = waypt_count(); + if (waypoint_n > device_max_waypoint) { + fatal(MYNAME ": waypoint count (%u) exceeds device limit (%u)\n", + waypoint_n, device_max_waypoint); + } + + message_init_size(&m, 0); + message_write(MSG_WAYPOINT_COUNT, &m); + if (message_read(MSG_WAYPOINT_COUNT, &m)) { + device_n = le_readu32(m.data); + } + waypt_disp_all(write_waypoint); send_batch(TRUE); + + if (device_n + waypoint_n > device_max_waypoint) { + m.size = 0; + message_write(MSG_WAYPOINT_COUNT, &m); + if (message_read(MSG_WAYPOINT_COUNT, &m) && + le_readu32(m.data) == device_max_waypoint) + { + warning(MYNAME ": waypoint count (%u already on device + %u added = %u)" + " exceeds device limit (%u), some may have been discarded\n", + device_n, waypoint_n, device_n + waypoint_n, device_max_waypoint); + } + } + message_free(&m); } //----------------------------------------------------------------------------- @@ -2132,8 +2180,7 @@ // confuse the first message read if we don't get rid of it packet_read(buf); // Send a break to clear any state from a previous failure - message_init(&m); - m.size = MSG_BREAK_SIZE; + message_init_size(&m, MSG_BREAK_SIZE); memset(m.data, 0, m.size); message_write(MSG_BREAK, &m); // get version info @@ -2198,6 +2245,16 @@ delbin_write(void) { if (doing_wpts) { + message_t m; + device_max_waypoint = 1000; + message_init_size(&m, 0); + message_write(MSG_CAPABILITIES, &m); + if (message_read(MSG_CAPABILITIES, &m)) { + const msg_capabilities_t* p = m.data; + device_max_waypoint = le_read32(p->max_waypoints); + } + message_free(&m); + if (opt_nuke_wpt) add_nuke(nuke_type_wpt); write_waypoints(); } ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
|
|
Re: patch: delbin, detect when waypoint count exceeds device limitOn Thu, Sep 3, 2009 at 12:15 PM, Paul Cornett <pc-gpsb@...> wrote: I've noticed some geocachers complaining that waypoints are silently We'll get false negatives on this (I can send 999 waypoints 10 times and not trigger it) but I was thinking that we can indeed catch the case that we *know* will fail and head that off. I actually had something very much like this in a debugger last night. I did the capabilities groping during conversation startup instead of waypoint transfer so I could use it for tracks and routes, too. We also can't catch gpsbabel -i gpx -f 900.gpx -o delbin -F usb: -i gpx -f 900more.gpx -o delbin -F usb: with this approach, either. I kept dwelling on 'perfect' and maybe 'good enough' on this is exactly that. I've applied this. Thanx. I deduce you're a GSAK user watching that conversation... RJL ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
|
|
Re: patch: delbin, detect when waypoint count exceeds device limitRobert Lipe wrote:
> I deduce you're a GSAK user watching that conversation... I'm not a geocacher myself, I just happened to stumble upon the GSAK threads. I see they have noticed a discrepancy in the icon names versus Topo 8. I got the original list from the doc (including the typo...), and the new ones from Topo 8. I knew DeLorme renamed "Geocache" (#123) to "Cache" in Topo 8, but I intentionally did not change it. I think "Cache" is too generic, and "Geocache" is much more common. But others may disagree. Anyway, here is a small patch for the typo and tombstone->cemetery. Index: delbin.c =================================================================== --- delbin.c (revision 29) +++ delbin.c (working copy) @@ -2251,7 +2251,7 @@ message_write(MSG_CAPABILITIES, &m); if (message_read(MSG_CAPABILITIES, &m)) { const msg_capabilities_t* p = m.data; - device_max_waypoint = le_read32(p->max_waypoints); + device_max_waypoint = le_readu32(p->max_waypoints); } message_free(&m); @@ -2988,7 +2988,7 @@ "Arrow Up Left", "Arrow Up Right", "Arrow Down Left", - "Arrow Dow Right", + "Arrow Down Right", "Green Star", "Yellow Square", "Red X", @@ -3052,7 +3052,7 @@ "Telephone", "Traffic Light", "Fire Hydrant", - "Tombstone", + "Cemetery", "Picnic Table", "Tent", "Shelter", ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
|
|
Re: patch: delbin, detect when waypoint count exceeds device limitThanx. Applied.
On Sat, Sep 5, 2009 at 1:30 AM, Paul Cornett <pc-gpsb@...> wrote:
------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Gpsbabel-code mailing list http://www.gpsbabel.org Gpsbabel-code@... https://lists.sourceforge.net/lists/listinfo/gpsbabel-code |
| Free embeddable forum powered by Nabble | Forum Help |