Example #1
0
	def __init__(self, port):
		try:
			self.ser = serial.Serial(
				port=port,
				baudrate=115200,
				parity=serial.PARITY_NONE,
				stopbits=serial.STOPBITS_ONE,
				bytesize=serial.EIGHTBITS)
		except serial.serialutil.SerialException, e:
			die('error: %s' % e)
Example #2
0
	def purge_log_on_device(self):
		'''Delete all tracklogs from the device.'''
		self.check_if_device_is_empty()
		fprint('purge log on device.. ', newline=False)
		buf = self._communicate(PURGE_LOG)
		if OK not in buf:
			die('error while trying to purge the log')
		else:
			while FINISH not in buf:
				time.sleep(1)
				buf += self.ser.read(self.ser.inWaiting())
			fprint('ok')
Example #3
0
def _write(datas, path):
	'''Write the tracklogs in their specific GPX-files.
	
	@param datas: The list of tracklogs.
	@param path: The target directory.'''
	try:
		os.chdir(path)
	except OSError, e:
		if path == '%s/mainnav-tracklogs/' % os.environ.get('HOME', tempfile.gettempdir()):
			try:
				os.mkdir(path)
				os.chdir(path)
			except OSError, e:
				die(e)
Example #4
0
	def check_if_device_is_empty(self):
		if self.logsize == 8192:
			die('there aren\'t stored any tracklogs on the device')
Example #5
0
def _write(datas, path):
	'''Write the tracklogs in their specific GPX-files.
	
	@param datas: The list of tracklogs.
	@param path: The target directory.'''
	try:
		os.chdir(path)
	except OSError, e:
		if path == '%s/mainnav-tracklogs/' % os.environ.get('HOME', tempfile.gettempdir()):
			try:
				os.mkdir(path)
				os.chdir(path)
			except OSError, e:
				die(e)
		else:
			die(e)
	folder = datetime.datetime.now().strftime('%y-%m-%d_%H:%M')
	try:
		os.chdir(folder)
	except OSError:
		try:
			os.mkdir(folder)
			os.chdir(folder)
		except OSError, e:
			die('error while creating folder: \'%s\'' % folder)
	i = 1
	for data in datas:
		filename = data[1]
		fullpath = '%s/%s' % (os.getcwd(),  filename)
		if data[1] == 'trackdata.bin':
			verbose('writing binary data to: \'%s\'.. ' % fullpath, newline=False)