Hello,

please find attached a patch against qlandkarte-svn rev. 509
to make map upload to serial units possible again.
Connection to the unit was lost because of message box.

And little cleanup to debug-output for serial units.

Compile tested, and tested with etrexLegend and little map.

best regards,
Andreas
Index: qlandkarte/trunk/src/device/Emap/CDevice.cpp
===================================================================
--- qlandkarte/trunk/src/device/Emap/CDevice.cpp	(Revision 509)
+++ qlandkarte/trunk/src/device/Emap/CDevice.cpp	(Arbeitskopie)
@@ -609,3 +609,44 @@
     delete serial;
     serial = 0;
 }
+
+// just copied from GPSMAP60CSX driver, 20081006
+void CDevice::_getDevProperties(Garmin::DevProperties_t& dev_properties)
+{
+    if(serial == 0) return;
+    Packet_t command;
+    Packet_t response;
+
+    // ask for SD Ram capacity
+    command.id   = Pid_Command_Data;
+    command.size = 2;
+    *(uint16_t*)command.payload = Cmnd_Transfer_Mem;
+    serial->write(command);
+
+    // try to read SD Ram capacity
+    uint32_t memory = 0;
+    uint16_t tile_limit = 0;
+    while(serial->read(response)) {
+        if(response.id == Pid_Capacity_Data) {
+            tile_limit = ((uint16_t*)response.payload)[1];
+            memory = ((uint32_t*)response.payload)[1];
+        }
+    }
+    if(tile_limit == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the tile limit of the GPS");
+    }
+    if(memory == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the available memory of the GPS");
+    }
+
+    // add to the properties list
+    properties.memory_limit = memory;
+    properties.set.item.memory_limit = 1;
+    properties.maps_limit = tile_limit;
+    properties.set.item.maps_limit = 1;
+
+    // return the properties
+    dev_properties = properties;
+}
+
+
Index: qlandkarte/trunk/src/device/Emap/CDevice.h
===================================================================
--- qlandkarte/trunk/src/device/Emap/CDevice.h	(Revision 509)
+++ qlandkarte/trunk/src/device/Emap/CDevice.h	(Arbeitskopie)
@@ -43,6 +43,9 @@
             void _downloadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _downloadTracks(std::list<Garmin::Track_t>& tracks);
+
+            void _getDevProperties(Garmin::DevProperties_t& dev_properties);
+
             void _release();
 
             Garmin::CSerial * serial;
Index: qlandkarte/trunk/src/device/CSerial.cpp
===================================================================
--- qlandkarte/trunk/src/device/CSerial.cpp	(Revision 509)
+++ qlandkarte/trunk/src/device/CSerial.cpp	(Arbeitskopie)
@@ -525,12 +525,19 @@
 int CSerial::serial_check_ack(uint8_t cmd)
 {
     Packet_t response;
-    if (serial_read(response) > 0)
-        if (response.id == Pid_Ack_Byte && response.payload[0] == cmd)
+    int count;
+
+    count= serial_read( response);
+    if (count > 0) {
+        if (response.id == Pid_Ack_Byte && response.payload[0] == cmd) {
             return 0;
-
-    cout << endl << "serial_check_ack failed: pid sent = $" << hex << cmd;
-    cout << " response id = " << response.id << " pid acked: " << response.payload[0] << endl;
+        } else {
+            cout << endl << "serial_check_ack failed: pid sent = $" << hex << (unsigned)cmd;
+            cout << " response id = $" << (unsigned)response.id << " pid acked: $" << (unsigned)response.payload[0] << endl;
+            return  -1;
+        }
+    }
+    cout << endl << "serial_check_ack failed: no bytes received" << endl;
     return  -1;
 }
 
Index: qlandkarte/trunk/src/device/GPSMap76/CDevice.cpp
===================================================================
--- qlandkarte/trunk/src/device/GPSMap76/CDevice.cpp	(Revision 509)
+++ qlandkarte/trunk/src/device/GPSMap76/CDevice.cpp	(Arbeitskopie)
@@ -614,3 +614,44 @@
     delete serial;
     serial = 0;
 }
+
+// just copied from GPSMAP60CSX driver, 20081006
+void CDevice::_getDevProperties(Garmin::DevProperties_t& dev_properties)
+{
+    if(serial == 0) return;
+    Packet_t command;
+    Packet_t response;
+
+    // ask for SD Ram capacity
+    command.id   = Pid_Command_Data;
+    command.size = 2;
+    *(uint16_t*)command.payload = Cmnd_Transfer_Mem;
+    serial->write(command);
+
+    // try to read SD Ram capacity
+    uint32_t memory = 0;
+    uint16_t tile_limit = 0;
+    while(serial->read(response)) {
+        if(response.id == Pid_Capacity_Data) {
+            tile_limit = ((uint16_t*)response.payload)[1];
+            memory = ((uint32_t*)response.payload)[1];
+        }
+    }
+    if(tile_limit == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the tile limit of the GPS");
+    }
+    if(memory == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the available memory of the GPS");
+    }
+
+    // add to the properties list
+    properties.memory_limit = memory;
+    properties.set.item.memory_limit = 1;
+    properties.maps_limit = tile_limit;
+    properties.set.item.maps_limit = 1;
+
+    // return the properties
+    dev_properties = properties;
+}
+
+
Index: qlandkarte/trunk/src/device/GPSMap76/CDevice.h
===================================================================
--- qlandkarte/trunk/src/device/GPSMap76/CDevice.h	(Revision 509)
+++ qlandkarte/trunk/src/device/GPSMap76/CDevice.h	(Arbeitskopie)
@@ -46,6 +46,9 @@
             void _downloadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _downloadTracks(std::list<Garmin::Track_t>& tracks);
+
+            void _getDevProperties(Garmin::DevProperties_t& dev_properties);
+
             void _release();
 
             Garmin::CSerial * serial;
Index: qlandkarte/trunk/src/device/EtrexLegend/CDevice.cpp
===================================================================
--- qlandkarte/trunk/src/device/EtrexLegend/CDevice.cpp	(Revision 509)
+++ qlandkarte/trunk/src/device/EtrexLegend/CDevice.cpp	(Arbeitskopie)
@@ -621,3 +621,43 @@
     delete serial;
     serial = 0;
 }
+
+// just copied from GPSMAP60CSX driver, 20081006
+void CDevice::_getDevProperties(Garmin::DevProperties_t& dev_properties)
+{
+    if(serial == 0) return;
+    Packet_t command;
+    Packet_t response;
+
+    // ask for SD Ram capacity
+    command.id   = Pid_Command_Data;
+    command.size = 2;
+    *(uint16_t*)command.payload = Cmnd_Transfer_Mem;
+    serial->write(command);
+
+    // try to read SD Ram capacity
+    uint32_t memory = 0;
+    uint16_t tile_limit = 0;
+    while(serial->read(response)) {
+        if(response.id == Pid_Capacity_Data) {
+            tile_limit = ((uint16_t*)response.payload)[1];
+            memory = ((uint32_t*)response.payload)[1];
+        }
+    }
+    if(tile_limit == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the tile limit of the GPS");
+    }
+    if(memory == 0) {
+        throw exce_t(errRuntime,"Failed to send map: Unable to find the available memory of the GPS");
+    }
+
+    // add to the properties list
+    properties.memory_limit = memory;
+    properties.set.item.memory_limit = 1;
+    properties.maps_limit = tile_limit;
+    properties.set.item.maps_limit = 1;
+
+    // return the properties
+    dev_properties = properties;
+}
+
Index: qlandkarte/trunk/src/device/EtrexLegend/CDevice.h
===================================================================
--- qlandkarte/trunk/src/device/EtrexLegend/CDevice.h	(Revision 509)
+++ qlandkarte/trunk/src/device/EtrexLegend/CDevice.h	(Arbeitskopie)
@@ -46,6 +46,9 @@
             void _downloadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _uploadWaypoints(std::list<Garmin::Wpt_t>& waypoints);
             void _downloadTracks(std::list<Garmin::Track_t>& tracks);
+
+            void _getDevProperties(Garmin::DevProperties_t& dev_properties);
+
             void _release();
 
             Garmin::CSerial * serial;
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
QLandkarte-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qlandkarte-users

Reply via email to