10 from __future__
import division, absolute_import, print_function, unicode_literals
13 from pyuavcan_v0
import UAVCANException
18 This exception is raised in case of a parser failure.
20 file Source file path where the error has occurred. Optional, will be None if unknown.
21 line Source file line number where the error has occurred. Optional, will be None if unknown.
24 def __init__(self, text, file=None, line=None):
25 Exception.__init__(self, text)
30 '''Returns nicely formatted error string in GCC-like format (can be parsed by e.g. Eclipse error parser)'''
35 return Exception.__str__(self)
39 '''Returns a nice human readable path to 'filename'.'''
41 a = os.path.abspath(filename)
42 r = os.path.relpath(filename)
47 return a
if '..' in r
else r
60 if isinstance(bytes, basestring):
61 bytes = map(ord, bytes)
63 if isinstance(bytes, str):
64 bytes = map(ord, bytes)
71 crc = ((crc << 1) ^ 0x1021) & 0xFFFF
73 crc = (crc << 1) & 0xFFFF
80 return bytes(struct.pack(
str(
"<Q"), crc64))