Google
  Web www.gpspassion.com


GpsPasSion LIVE!
www.flickr.com
This is a Flickr badge showing public photos from GpsPasSion Live !. Make your own badge here.

www.NaviBlog.com



Versions

Links/Liens




Portal/Portail
Rechercher

- -

Polls/Sondages
Sondage
Pour vous guider sur la Route :
GPS Mobile (SEM)
GPS Intégré
Smartphone
Autre
Voter  -  Résultat des votes
Votes : 1345




Club GpsPasSion
Soutenez le site!

USA: (US$)
EUROPE: (€)
Guide Paypal


GpsPasSion Forums
Home | Profile | Register/Enregist. | Active Topics | Search/Recherche | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 GPS Programming
 "Beta" GPS software
 MTK Loggers - Configuration software - BT747
 New Topic  Reply/Répondre
 Printer Friendly
Previous Page | Next Page
Author Previous Topic Topic Next Topic
Page: of 50

elijahparker

USA
23 Posts

Posted - 06 mai 2007 :  20:56:36  Show Profile  Visit elijahparker's Homepage  Reply with Quote
Here's a sample of some kml output:



I can see a lot of potential here...This is a plot of the height. I also can plot speed, which can be very interesting when analyzing training bike rides or runs and compare speed over time and incline...I'm having fun now that I'm beyond the hardest parts!

This was done completely with a Mac... I'm downloading xcode right now so maybe I can make it into a "real" application instead of just php script.
Go to Top of Page

ext2

France
38 Posts

Posted - 07 mai 2007 :  02:16:00  Show Profile  Reply with Quote
elijahparker:
i have translate a part of your program i C language.
I have already donne the 'send' and the 'chksum' part.
I'm not a good programer but it seem to work (with no compiling error).
I can put it there if you are agree and if someone is interrested.

Go to Top of Page

elijahparker

USA
23 Posts

Posted - 07 mai 2007 :  02:22:32  Show Profile  Visit elijahparker's Homepage  Reply with Quote
You are free to do anything you want with it. Here is some more code, too, for parsing the raw data. I still don't have any interface for my program...that is what I am working on right now. I might translate it to C++ and do it in Xcode or else make a Javascript Widgit interface for it...I don't know yet -- I'm playing with both.

Sorry this code is still very messy. But it does work! It can read in different formats, too (everything but satellite info and stuff like that), and it also has error correction if it gets out of sync.



function decode($datafile)
{
	global $db;
	global $LOG_END;
	global $fh;
	global $pos;
	global $length;

	$fh = fopen($datafile, "r");
	$time = time();
	$csvfile = "log/" . $time . ".csv";
	$pkmlfile = "log/" . $time . "p.kml";
	$skmlfile = "log/" . $time . "s.kml";
	log_line_to_db("#LOG_START", $db);
	
	$RETRY_BLOCK_SIZE = 16;
	$LOG_END = "0706010000BBBBBBBB";
	$ENDING = "BBBBBBBB";
	$HEADER_LENGTH = 1056;
	$NEW_SET_BEGIN = "AAAAAAAAAAAAAA";
	$ZERO = "00000000";
	$FFFF = "FFFFFFFF";

	$results = array();

	$size = hexdec(fread($fh, 16));
	echo "format=" . $format = (fread($fh, 16));
	echo "\n";

	if(is_int($format)) $format = dechex($format);
	$length = get_bytes_per_line($format) * 2;
	$datasize = filesize($datafile);
	$pos = 0;

	$line = resync("");
	
	$line_number = 0;
	$continue = true;

	for(;;)
	{
		//if($line_number == 0) echo "line = " . $line . "\n\n\n"; //break;
		if(strlen($line) < $length) break;
		if(substr($line, 0, strlen($NEW_SET_BEGIN)) == $NEW_SET_BEGIN || preg_match("/^[A-F0-9]{18}43000000002A/", substr($line, 0, 32)))
		{
			$line = resync($line);
			//echo "line = " . $line . "\n\n\n"; //break;
//			$results[] = "#LOG_START";
//			$pos += 32;
//			$waypoint = fread($fh, 32);
//			echo $line . " " . $waypoint . "\n\n\n";
			log_line_to_csv("#LOG_START", $csvfile);
			log_line_to_kml("#LOG_START", $pkmlfile, $skmlfile);
			log_line_to_db("#LOG_START", $db);
			continue;
		}
		else if(substr($line, 0, strlen($FFFF)) == $FFFF)
		{
			$tries = ($HEADER_LENGTH + $length) / ($RETRY_BLOCK_SIZE / 2);
			while((($found = strpos($line, $ENDING)) === false) && $tries-- > 0)
			{
				//echo $tries . " + " . $line . "\n";
				$pos += $RETRY_BLOCK_SIZE;
				$line = substr($line, $RETRY_BLOCK_SIZE) . fread($fh, $RETRY_BLOCK_SIZE);
				if(strlen($line) < $length) break;
			}
			if($found !== false)
			{
				$extra = $length - ($found + strlen($ENDING));
				if($extra > 0) $line = substr($line, $extra) . fread($fh, $extra);
				if(strlen($line) < $length) break;
			}
			else
			{
				break;
			}
		}
		else
		{
			$tries = $HEADER_LENGTH + length;
			while((($result = decode_line($line, $format)) == false) && $tries-- > 0)
			{
				$pos += 2;
				$line = substr($line, 2) . fread($fh, 2);
				if(strlen($line) < $length) break;

				if($error) echo "."; else echo "Error!  Attempting to resync... ";
				$error = true;

				//$results[] = "#ERROR";
				//echo "error at line $line_number (0x" . dechex($pos) . ")\n";
				//echo "   " . $line . "\n";
				break;
			}
			if($error && $result !== false)
			{
				echo "Recovered!";
				$error = false;
			}
			if($result != false)
			{
//				$results[] = $result;
				log_line_to_csv($result, $csvfile);
				log_line_to_db($result, $db);
				log_line_to_kml($result, $pkmlfile, $skmlfile);
			}
			$pos += $length;
			if($pos + $length > $datasize) break;
		}
		$line_number++;
		$line = fread($fh, $length);
	}
	echo "\n";
	fclose($fh);
	log_line_to_kml("#END", $pkmlfile, $skmlfile);
	return $results;
}

function resync($block)
{
	global $LOG_END;
	global $fh;
	global $pos;
	global $length;

	$block_size = strlen($LOG_END);
	$pos += $block_size; //strpos($data, $LOG_END) + strlen($LOG_END);
	$tries = 2048;
	$return = "";
	if(strlen($block) < $block_size) $block .= $return = fread($fh, $block_size - strlen($block));
	while((($found = strpos($block, $LOG_END)) === false) && $tries-- > 0)
	{
		//echo $tries . " " . $block . "\n";
		$pos += 2;
		$return .= $block = substr($block, 1) . fread($fh, 1);
	}
	if($found > strlen($block) - $block_size) $amount = $length - $found; else $amount = $length;
	$line = fread($fh, $amount);
	return $line;
}

function decode_line($line, $format)
{
	global $LOG, $LOGC;

	// Convert the hex-encoded string to a byte array //
	$bytes = array();
	for($i = 0; $i < strlen($line); $i += 2)
	{
		$bytes[] = hexdec($line{$i} . $line{$i + 1});
	}
	
	// Validate checksum //
	$csum = $bytes[count($bytes) - 1];
	$bytes = array_slice($bytes, 0, count($bytes) - 2);
	$chk = 0;
	foreach($bytes as $byte) $chk ^= $byte;
	if($chk != $csum) return false;
	
	// Get the list of fields in the correct order //
	$log_mask = $LOG;
	asort($LOG);
	$logformat = hexdec($format);
	$fields = array();
	foreach($log_mask as $name => $mask)
	{
		if($logformat & $mask) $fields[] = $name;
	}

	// Parse the data //
	$result = array();
	$addr = 0;
	foreach($fields as $field)
	{
		$str = "";
		$part = array_slice($bytes, $addr, $LOGC[$field]['size']);
		foreach($part as $byte) $str .= chr($byte);
		$val = unpack($LOGC[$field]['type'], $str);
		$result[$field] = $val[1];
		$addr += $LOGC[$field]['size'];
	}

	return $result;
}

function get_bytes_per_line($format)
{
	global $LOG, $LOGC;
	
	$log_mask = $LOG;
	asort($LOG);
	$logformat = hexdec($format);
	$fields = array();
	foreach($log_mask as $name => $mask)
	{
		if($logformat & $mask) $fields[] = $name;
	}
	$length = 2;
	foreach($fields as $field) $length += $LOGC[$field]['size'];

	return $length;
}

Go to Top of Page

elijahparker

USA
23 Posts

Posted - 08 mai 2007 :  00:06:18  Show Profile  Visit elijahparker's Homepage  Reply with Quote
I think I have something that is satisfactory at least for the time being for me. I kept the driver in PHP but made an interface with a Dashboard widget in JavaScript. This is for Mac OS X 10.4 and newer only.

http://www.elijahtech.com/temp/iBlue747.zip

Try it out and let me know what you think! It's still a bit rough and certainly not foolproof, but it seems to work for me anyway. Make sure to change the path to the driver on the back of the widget before trying to connect!
Go to Top of Page

ext2

France
38 Posts

Posted - 08 mai 2007 :  17:53:02  Show Profile  Reply with Quote
The widjet work for me.
But the data extract from the device seems not to be good: perhaps my data is corrupted (by all the try i've donne on the GPS).

Edited by - ext2 on 08 mai 2007 17:53:26
Go to Top of Page

elijahparker

USA
23 Posts

Posted - 08 mai 2007 :  18:08:38  Show Profile  Visit elijahparker's Homepage  Reply with Quote
ext2, can you post a bit of the data from the .cvs file found in the log folder? I just made a few small improvements so I'll be updating the program soon.

And are you able to connect to the device and change the settings via the widget? If all this works and you have bad data, try erasing the log (using the widget) and doing it again.

Oh, one thing to note: it will not work correctly if it is connect via USB. Only use Bluetooth with the device disconnected from USB and set to "NAV" mode.

Edited by - elijahparker on 08 mai 2007 18:35:54
Go to Top of Page

ext2

France
38 Posts

Posted - 08 mai 2007 :  19:19:59  Show Profile  Reply with Quote
Here is the cvs file :

UTC,VALID,LATITUDE,LONGITUDE,HEIGHT,SPEED,RCR
1388701004,18496,2.395063048063E-45,-7.38662176979E+288,2.6578585548928E-32,1.5164363092058E-13,15174
-1336919226,512,2.0933418977616E-251,3.6090293421548E+85,2.2295550555538E-35,1.3619917560574E-17,2825
7604546,34362,3.0446610215962E+59,1.0078253128013E+294,4.1681177755516E-24,3.8819718296097E-34,41901
-46194602,21827,1.9903497955779E+90,4.5197652628234E-105,-7796505444352,3.716916237566E+15,52606
1388701004,18496,2.395063048063E-45,-7.38662176979E+288,2.6578585548928E-32,1.5164363092058E-13,15174
-1336919226,512,2.0933418977616E-251,3.6090293421548E+85,2.2295550555538E-35,1.3619917560574E-17,2825
7604546,34362,3.0446610215962E+59,1.0078253128013E+294,4.1681177755516E-24,3.8819718296097E-34,41901
-46194602,21827,1.9903497955779E+90,4.5197652628234E-105,-7796505444352,3.716916237566E+15,52606








Yes i'm able to connect the device (via BT).
But i don't want to change the setting because i'm affraid of errasing data in the GPS (I want to keep this data).
it seem to me that the soft using in windows errase all the data in the GPs when he change any setting.
Your soft do the same?

ps: a a sympathetic guy at my work have donne a great job on the device. He've soldering a 1kom 402 chip
at the right place on the iblue. it looks as if the chip as be place by a machine:)

psII: if you want i can put online the log file (321k0) or send to you by mail but i don't know where.


psIII: i thought that a php program could only work online with an apache server. I was wrong.

Edited by - ext2 on 08 mai 2007 19:24:00
Go to Top of Page

elijahparker

USA
23 Posts

Posted - 08 mai 2007 :  19:42:08  Show Profile  Visit elijahparker's Homepage  Reply with Quote
It's true -- to change the log settings the device must be erased. I had some problems once like that and it was fixed by erasing the device. You see, my software doesn't support all of the log settings (it doesn't support any satellite data), so if the unit was configured with the windows software, it may not work with my software.

The best thing to try would be to download the log with the windows software so that you have it backed up, then "reset" the device using the windows software (the button on the right of the erase confirmation prompt after pressing the erase button).

After that, use my software to choose which fields you want to log and set the intervals (time is in seconds and distance in meters with a minimum of 10m). Then use the device and capture come data in the "log" mode. Then it should all work.
Go to Top of Page

ext2

France
38 Posts

Posted - 08 mai 2007 :  20:23:16  Show Profile  Reply with Quote
Ok,
I will get access to an XP/PC tomorow. So i'll try your soft after.
Go to Top of Page

bastpless

Germany
3 Posts

Posted - 08 mai 2007 :  21:42:03  Show Profile  Reply with Quote
I bought the iBlue several days ago and I'm delighted to see a Mac compatible version being developed. Thank you all very much!

The first (Java) version by vtec did not work for me, because I wasn't able to install a Java 1.5 version without registering as an Apple developer.

The version by elijahparker runs and is able to connect to my iBlue 747 but I'm not able to download a log. The message >Error writing "< is displayed (without >< of course). 3 files are generated (one .log and two .kml files). The log file contains about 30 zeros and nothing else. I tried the "Delete / Change format" button several times before writing a new log.

Hope this will help in your development. I will keep looking for updates. Thank you again.

Go to Top of Page

elijahparker

USA
23 Posts

Posted - 08 mai 2007 :  21:52:37  Show Profile  Visit elijahparker's Homepage  Reply with Quote
Thanks for your feedback, bastpless! That's helpful...and interesting. I don't know why exactly that would be, because normally it would imply a permissions error for the ./log folder. This doesn't seem to be the case because the files are present, but just to make sure, check the the permissions for the folder allow writing by both "group" and "others".

Also, would you be willing to try running "php download_log.php" (with the GPS in NAV mode) from the Terminal in the driver folder and posting the output? That would be very helpful since I don't know what is causing your problem right now. Thanks!

And make sure the unit is not connected via USB. Have you made the bluetooth modification with the resistor to be able to accept commands? I would assume so since it connected, but just to make sure. It could be that this is the problem.
Go to Top of Page

sungame

Norway
2 Posts

Posted - 09 mai 2007 :  11:45:11  Show Profile  Reply with Quote
quote:
Originally posted by elijahparker

Here's my code that is currently working. I would do a bit differently now that I know more about the protocol, but this works and I've built a lot on top of it. One thing is doesn't allow which I have since learned is possible is sending multiple command at once and then receiving and confirming the multiple replies. This isn't important with my software so much, but still would have been nice.




sorry for my stupid reply, but how do I run this? I tried "php codefile.php", but got only a bunch of error messages, including

"Call to undefined function log_line_to_kml()" and the other log functions...
Go to Top of Page

bastpless

Germany
3 Posts

Posted - 09 mai 2007 :  15:43:19  Show Profile  Reply with Quote
Hello elijahparker,

thanks for your reply. I tried changing the permissions before, without any change in the behaviour of the software. Now I tried to run the script from the terminal and received the following messages:

Error retrieving used memory size
Error reading log format
status=Done!
status=Download complete, parsing...
status=Success!
csv=/Applications/Geo/iBlue747/iBlue747_Driver/log/1178717933.csv
status=Error writing ''
error=true

Hope this helps!
Go to Top of Page

elijahparker

USA
23 Posts

Posted - 09 mai 2007 :  15:50:44  Show Profile  Visit elijahparker's Homepage  Reply with Quote
bastpless, the problem appears to be that you haven't soldered in the resister as described here: http://www.gpspassion.com/forumsen/topic.asp?TOPIC_ID=81990#508553

That tweak is necessary to be able to use my software. A little scary, but it works great!
Go to Top of Page

bastpless

Germany
3 Posts

Posted - 09 mai 2007 :  16:12:58  Show Profile  Reply with Quote
Yes, this seems to be the cause for the problem. But 'scary' is the right word...

I remember I downloaded a Mac driver for the usb to serial adaptor inside the device, so shouldn't it be possible to use the usb connection for sending commands?

I will wait for any development in this direction before soldering inside my device, but thank you much for your advice!

Edited by - bastpless on 09 mai 2007 16:13:47
Go to Top of Page
Page: of 50 Previous Topic Topic Next Topic  
Previous Page | Next Page
 New Topic  Reply/Répondre
 Printer Friendly
Jump To:
GpsPasSion Forums © 2002-2013_GpsPasSion/Manzanite Go To Top Of Page
This page was generated in 1,95 seconds. Powered By: Snitz Forums 2000 Version 3.4.05