danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
648 stars 226 forks source link

Fix Mat file Export #50

Closed bhagivinni closed 6 years ago

bhagivinni commented 6 years ago

Python version

Please run the following snippet and write the output here

python=2.7.14 (v2.7.14:84471935ed, Sep 16 2017, 20:19:30) [MSC v.1500 32 bit (Intel)]'
'os=Windows-7-6.1.7601-SP1'

Code

 for file_name in os.listdir(dir_mdf_file):
        mdf_parser = asammdf.mdf.MDF(name=file_name, memory='low', version='4.00')
        mdf_file = mdf_parser.export('mat',file_name)

Traceback

 (<type 'exceptions.TypeError'>, TypeError("'generator' object has no attribute '__getitem__'",), <traceback object at 0x000000000E247A88>)

Error 2: (<type 'exceptions.ValueError'>, ValueError('array-shape mismatch in array 7',), <traceback object at 0x0000000014D9B0C8>)

Description

While trying to convert MDF files to .mat files using MDF module, I am getting these two errors. I am assuming that Error 2 may be because of NUMPY, can anyone help why this error comes while exporting? Can i get help on this??

danielhrisca commented 6 years ago

I've switched from cantools to canmaxtrix (https://github.com/ebroecker/canmatrix). This should allow to parse the arxml attachment. Please retry.

bhagivinni commented 6 years ago

Hello @danielhrisca, I have tried running code using latest commit, but it is resulting in an warning saying that the filename, directory name, or volume label syntax is incorrect.

Please find the output,

ATTACHMENT block:
{'file_name_addr': 1174564, 'embedded_data': '', 'block_len': 98, 'md5_sum': '\xd2\x16@\xc3C\x16\x8c.\xe2Hc?\xdd\xfa\xe49', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11033828, 'mime_addr': 1127898, 'reserved1': 0, 'next_at_addr': 1124887, 'links_nr': 4, 'embedded_size': 0}
{'file_name_addr': {'text': 'c:\..\File_data\sample_mdf.arxml\x00\x00\x00\x00\x00\x00', 'block_len': 136, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}, 'mime_addr': {'text': 'app_data/x-arxml\x00\x00\x00\x00\x00', 'block_len': 48, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}}
False
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3569: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')
  warnings.warn(message)
Traceback (most recent call last)
  File "C:/data/main.py", line 134, in convert_mdf
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='minimum', version='4.00')
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 80, in __init__
    self._mdf = MDF4(name, memory)
  File "C\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 304, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 518, in _read
    neg_ch_cntr,
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 900, in _read_channels
    key='db',
  File "C:\Local\Continuum\anaconda2\lib\site-packages\canmatrix\formats.py", line 41, in loads
    fileObject = StringIO.StringIO[string]
NameError: global name 'StringIO' is not defined

Process finished with exit code 1
danielhrisca commented 6 years ago

You'll have to install the development branch of canmatrix

bhagivinni commented 6 years ago

Yes i have installed canmatrix package.

On 13 Mar 2018 10:27 am, "Daniel Hrisca" notifications@github.com wrote:

You'll have to install the development branch of canmatrix

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/danielhrisca/asammdf/issues/50#issuecomment-372547189, or mute the thread https://github.com/notifications/unsubscribe-auth/AQg-n2Jb3bHRXX0rrVNei3VAq2wkS1mcks5td1G9gaJpZM4SeK24 .

danielhrisca commented 6 years ago

pip install -I --no-deps https://github.com/ebroecker/canmatrix/archive/development.zip

bhagivinni commented 6 years ago

Please find the output after installing development branch.

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3569: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')
  warnings.warn(message)
ATTACHMENT block:
DEBUG - arxml - Read arxml ...
{'file_name_addr': 1174564, 'embedded_data': '', 'block_len': 98, 'md5_sum': '\xd2\x16@\xc3C\x16\x8c.\xe2Hc?\xdd\xfa\xe49', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11033828, 'mime_addr': 1127898, 'reserved1': 0, 'next_at_addr': 1124887, 'links_nr': 4, 'embedded_size': 0}
{'file_name_addr': {'text': 'c:\..\File_data\sample_mdf.arxml\x00\x00\x00\x00\x00\x00', 'block_len': 136, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}, 'mime_addr': {'text': 'app_data/x-arxml\x00\x00\x00\x00\x00', 'block_len': 48, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}}
False
Traceback (most recent call last):
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='minimum', version='4.00')
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 80, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 304, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 518, in _read
    neg_ch_cntr,
  File "C:\\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 900, in _read_channels
    key='db',
  File "C:\Local\Continuum\anaconda2\lib\site-packages\canmatrix\formats.py", line 51, in loads
    return load(fileObject, importType, key, flatImport, **options)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\canmatrix\formats.py", line 73, in load
    dbs = moduleInstance.load(fileObject, **options)
  File "C:\\Local\Continuum\anaconda2\lib\site-packages\canmatrix\arxml.py", line 1464, in load
    tree = etree.parse(file)
  File "src/lxml/etree.pyx", line 3444, in lxml.etree.parse (src\lxml\etree.c:83185)
  File "src/lxml/parser.pxi", line 1851, in lxml.etree._parseDocument (src\lxml\etree.c:120981)
  File "src/lxml/parser.pxi", line 1871, in lxml.etree._parseMemoryDocument (src\lxml\etree.c:121250)
  File "src/lxml/parser.pxi", line 1752, in lxml.etree._parseDoc (src\lxml\etree.c:119804)
  File "src/lxml/parser.pxi", line 1066, in lxml.etree._BaseParser._parseUnicodeDoc (src\lxml\etree.c:113546)
  File "src/lxml/parser.pxi", line 598, in lxml.etree._ParserContext._handleParseResultDoc (src\lxml\etree.c:107738)
  File "src/lxml/parser.pxi", line 709, in lxml.etree._handleParseResult (src\lxml\etree.c:109447)
  File "src/lxml/parser.pxi", line 638, in lxml.etree._raiseParseError (src\lxml\etree.c:108301)
  File "<string>", line 1
lxml.etree.XMLSyntaxError: Document is empty, line 1, column 1
danielhrisca commented 6 years ago

DEBUG - arxml - Read arxml ... {'file_name_addr': 1174564, 'embedded_data': '', 'block_len': 98, 'md5_sum': '\xd2\x16@\xc3C\x16\x8c.\xe2Hc?\xdd\xfa\xe49', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11033828, 'mime_addr': 1127898, 'reserved1': 0, 'next_at_addr': 1124887, 'links_nr': 4, 'embedded_size': 0} {'file_name_addr': {'text': 'c:..\File_data\sample_mdf.arxml\x00\x00\x00\x00\x00\x00', 'block_len': 136, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}, 'mime_addr': {'text': 'app_data/x-arxml\x00\x00\x00\x00\x00', 'block_len': 48, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}} False

The False here means that the file c:..\File_data\sample_mdf.arxml does not exist. Update asammdf to see exactly the file name, not just if it exists, and double check your paths/files.

bhagivinni commented 6 years ago

Hi @danielhrisca, Yes they have given some other path which is not accesseble, we need only the signals and values (as we are working on signals) inside MDF file, can we get only those into mat file and can we ignore remaining info inside the file.

danielhrisca commented 6 years ago

Please try the new code: bus logging is ignored if the database attachment is unavailable.

bhagivinni commented 6 years ago

Hi @danielhrisca, Conversion from MDF to Mat was done, thank you for the support.

But the file is returned in the form of generator so if we want to read this file using scipy.loadmat, it is resulting in error, please let me know, if you have any suggestions regarding this

type of file is: <type 'generator'>

Traceback (most recent call last):
  File "C:/Desktop/data/main.py", line 412, in mat_file_data
    full_data = sio.loadmat(mat_file_path, squeeze_me=True)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\scipy\io\matlab\mio.py", line 141, in loadmat
    MR, file_opened = mat_reader_factory(file_name, appendmat, **kwargs)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\scipy\io\matlab\mio.py", line 64, in mat_reader_factory
    byte_stream, file_opened = _open_file(file_name, appendmat)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\scipy\io\matlab\mio.py", line 33, in _open_file
    return open(file_like, 'rb'), True
TypeError: coercing to Unicode: need string or buffer, generator found
danielhrisca commented 6 years ago

Can you share the full script?

bhagivinni commented 6 years ago

Hi @danielhrisca , i can share you the conversion part and reading mat file as we have huge number of lines of code.

    def convert_mdf(self, dir_mdf_file):
        current_dir = os.getcwd()
        mat_file_path = []
        os.chdir(dir_mdf_file)
        for file_name in os.listdir(dir_mdf_file):
            if file_name.endswith('.MF4'):
                mdf_parser = asammdf.mdf.MDF(name=file_name, memory='minimum', version='4.00')
                mdf_file = mdf_parser.export('mat', file_name)
            mat_file_path.append(glob.iglob(os.path.join(dir_mdf_file,"*.mat")))
            #if mdf_file.endswith('.mat'):
            #     print "mdf_file", mdf_file
            #      mat_file_path.append(os.path.join(dir_mdf_file, mdf_file))
        os.chdir(current_dir)
        return mat_file_path

    @staticmethod
    def mat_file_data(mat_file_path):
        # reads the .mat file as dictionary
        full_data = sio.loadmat(mat_file_path, squeeze_me=True)
        return full_data
danielhrisca commented 6 years ago

export does not return (actually Python automatically returns None in this case). Do you use the variable _mdffile later?

bhagivinni commented 6 years ago

The converted file we need to store in the same directory so i am using that variable.

bhagivinni commented 6 years ago

I got the point, i think the culprit here is "iglob" which am using to store file in the same directory, it returns generator, will try modifying it.

bhagivinni commented 6 years ago

Hi @danielhrisca, Mat file conversion was done, so i need some info regarding the signal formatting. While converting export follows:
In the mat file the channels will be renamed to 'DataGroup'. The channel group master will be renamed to 'DataGroup_master' ( is the data group index starting from 0) As i am not that involved in MDF format files before, may i know what is datagroup (i am assuming the data collected from the same channel) and what is data group index and what basis channel group master is recognized.??

danielhrisca commented 6 years ago

In MDF each data group has the same sampling rate (common master channel, usually a time master). This is why it is important to know in the mat file the master for each channel.

Indexing starts at 0.

bhagivinni commented 6 years ago

Ok @danielhrisca, now am clear about the format, Thanks for the response.

danielhrisca commented 6 years ago

@bhagivinni I think this issue can be closed now.

danielhrisca commented 6 years ago

@bhagivinni I've made some improvements to the mat export (see documentation of export method http://asammdf.readthedocs.io/en/development/api.html#mdf).

It would be great if you could test them with your files.

bhagivinni commented 6 years ago

Yes @danielhrisca, I will test and post the output ASAP.

On 20 Mar 2018 5:01 pm, "Daniel Hrisca" notifications@github.com wrote:

@bhagivinni https://github.com/bhagivinni I've made some improvements to the mat export (see documentation of export method http://asammdf.readthedocs.io/en/development/api.html#mdf ).

It would be great if you could test them with your files.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/danielhrisca/asammdf/issues/50#issuecomment-374564995, or mute the thread https://github.com/notifications/unsubscribe-auth/AQg-n37AB_9BqKhio9erKZhqA8_yLCvaks5tgOisgaJpZM4SeK24 .

bhagivinni commented 6 years ago

Hello @danielhrisca, I got this output when i run code with latest development.

Traceback (most recent call last):
  File "C:/Desktop/Demo/main.py", line 140, in convert_mdf
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='low', version='4.00')
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 91, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 306, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 521, in _read
    neg_ch_cntr,
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 771, in _read_channels
    channel = Channel(address=ch_addr, stream=stream)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\v4_blocks.py", line 246, in __init__
    display_name = ET.fromstring(comment).find('.//names/display')
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1311, in XML
    parser.feed(text)
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1657, in feed
    self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 47: ordinal not in range(128)
danielhrisca commented 6 years ago

Thanks for trying this out. I suppose you are still using Python 2. Could you also try on Python 3?

danielhrisca commented 6 years ago

It would also help to put a print in _v4blocks.py :

            # line 244
            if comment.startswith('<CNcomment'):
                print(comment, type(comment))
                display_name = ET.fromstring(comment).find('.//names/display')
bhagivinni commented 6 years ago

No @danielhrisca we are suppose to use python 2, its not possible to shift to python 3.

bhagivinni commented 6 years ago

This development will not work in python 2??

danielhrisca commented 6 years ago

It should. I just want to see if this issue is related to the botched Unicode/are handling in python 2

danielhrisca commented 6 years ago

What does that print look like?

danielhrisca commented 6 years ago

The last commit from development will skip the display name identification (https://github.com/danielhrisca/asammdf/commit/6b5c4fe136545dcf1ae1d194f5df6239a3c0f666) but it would be nice to see why it failed in the first place.

bhagivinni commented 6 years ago

After adding print in v4_blocks.py i got this output:

 File "C:Desktop/demo/main.py", line 112, in read_input
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x30050FA</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x600086D3</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60008060</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60008064</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60007FA8</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60007FAC</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60007FB0</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x60006AD0</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x600068EC</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="2">0x600065F0</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x60007138</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>T1</TX><raster>0.002</raster>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x80007240</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x5000755A</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x50007845</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x6000731E</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1">0x8000704C</address>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX><raster>0.01</raster>
</CNcomment> <type 'unicode'>
<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1" bit_mask="0x0080">0x000B</address>
</CNcomment> <type 'unicode'>
  File "C:/Desktop/Demo/main.py", line 140, in convert_mdf
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='low', version='4.00')
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 91, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 306, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 521, in _read
    neg_ch_cntr,
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 771, in _read_channels
    channel = Channel(address=ch_addr, stream=stream)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\v4_blocks.py", line 246, in __init__
    display_name = ET.fromstring(comment).find('.//names/display')
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1311, in XML
    parser.feed(text)
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1657, in feed
    self._parser.Parse(data, 0)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in position 47: ordinal not in range(128)
danielhrisca commented 6 years ago

Did you place the print at line 245 (just before display_name = ET.fromstring(comment).find('.//names/display'))?

I ask this because the last printed channel comment:

<CNcomment>
<TX>some comment text mesage</TX>
<address byte_count="1" bit_mask="0x0080">0x000B</address>
</CNcomment>

is ASCII only so I can't see how it could have triggered the exception

bhagivinni commented 6 years ago

Yes, i had added comment in 244 line.

bhagivinni commented 6 years ago

I had updated 3.3.0.dev0 development code and tested now its working fine.

bhagivinni commented 6 years ago

I got the converted mat file.

danielhrisca commented 6 years ago

Did you use the new **kargs options for the mat export (single_time_base, raster, time_from_zero)?

bhagivinni commented 6 years ago

No i couldn't see **kwargs options for mat export ,mentioned above.

danielhrisca commented 6 years ago

Check out the documentation http://asammdf.readthedocs.io/en/development/api.html#mdf

This is a short example code:

from asammdf import MDF

mdf = MDF('test.mf4')
mdf.export(
    'mat',
    'test.mat',
    single_time_base=True,
    raster=0.1,
    time_from_zero=True,
)
bhagivinni commented 6 years ago

Hi @danielhrisca, Tried out with **kwargs but i am getting error:

TypeError: export() got an unexpected keyword argument 'single_time_base'

bhagivinni commented 6 years ago

I think additional **kwargs are not included in 3.3.0.dev0, i couldn't see related code in mdf.py.

danielhrisca commented 6 years ago

https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf.py#L583

bhagivinni commented 6 years ago

@danielhrisca , i am getting this error with latest development code.

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3705: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')
ATTACHMENT block:
  warnings.warn(message)
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='low', version='4.00')
  File "C:Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 89, in __init__
    self._mdf = MDF4(name, memory)
  File "C:Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 305, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 455, in _read
    common_properties = ET.fromstring(comment).find(".//common_properties")
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1312, in XML
    return parser.close()
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1671, in close
    self._raiseerror(v)
  File "C:\Local\Continuum\anaconda2\lib\xml\etree\ElementTree.py", line 1523, in _raiseerror
    raise err
xml.etree.ElementTree.ParseError: syntax error: line 1, column 0
{'file_name_addr': 1151016, 'embedded_data': '', 'block_len': 96, 'md5_sum': 'W\x8e\xf8\xd6\x1a\rb\x07\\\xa5\x1e1 \xdc\xf6\x06', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 31335, 'mime_addr': 1151136, 'reserved1': 0, 'next_at_addr': 1137744, 'links_nr': 4, 'embedded_size': 0}
{'file_name_addr': {'text': 'c:\desktop\local\test.dbc', 'block_len': 120, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}, 'mime_addr': {'text': 'application/x-dbc\x00\x00\x00\x00\x00\x00\x00', 'block_len': 48, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}}
C:\desktop\local\test.dbc False

Process finished with exit code 1
danielhrisca commented 6 years ago

If your using the same file as before, then I suspect that there is something fishy on your setup.

The new code (https://github.com/danielhrisca/asammdf/commit/68665d5097dbf6abb5d97ff0a704e8149d715267) will handle this error and print a message. Please share the printed message

bhagivinni commented 6 years ago

@danielhrisca I got the same message with .dbc files, but process was not stoped, conversion to mat was done.

danielhrisca commented 6 years ago

Line 458 should give a new print (https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf_v4.py#L458) that is important to help understand why the error is triggered (the comment appears not to be a valid XML tag, but for bus logging it is mandatory).

bhagivinni commented 6 years ago

The given file names in MDF file are not valid paths as we will be only working on signals.

bhagivinni commented 6 years ago

I got this with latest development code:

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3655: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')
  warnings.warn(message)
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:851: UserWarning: Expected .dbc or .arxml file as CAN channel attachment but got "C:\Desktop\Test\234890.arxml"
  warnings.warn('Expected .dbc or .arxml file as CAN channel attachment but got "{}"'.format(at_name))
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\\Desktop\Test\234890.arxml False
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:851: UserWarning: Expected .dbc or .arxml file as CAN channel attachment but got "C:\Desktop\Test\234890.dbc"
ATTACHMENT block:
  warnings.warn('Expected .dbc or .arxml file as CAN channel attachment but got "{}"'.format(at_name))
{'file_name_addr': 1151016, 'embedded_data': '', 'block_len': 96, 'md5_sum': 'W\x8e\xf8\xd6\x1a\rb\x07\\\xa5\x1e1 \xdc\xf6\x06', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 31335, 'mime_addr': 1151136, 'reserved1': 0, 'next_at_addr': 1137744, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.dbc False
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:447: UserWarning: Invalid bus logging channel group metadata: CAN_ErrorFrame
--------------------------------------------------------------------------------
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
INVALID Bus logging channel group comment:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:447: UserWarning: Invalid bus logging channel group metadata: CAN_RemoteFrame
CAN_ErrorFrame
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:851: UserWarning: Expected .dbc or .arxml file as CAN channel attachment but got "C:\Desktop\Test\234890.dbc"
--------------------------------------------------------------------------------
  warnings.warn('Expected .dbc or .arxml file as CAN channel attachment but got "{}"'.format(at_name))
--------------------------------------------------------------------------------
INVALID Bus logging channel group comment:
CAN_RemoteFrame
--------------------------------------------------------------------------------
ATTACHMENT block:
{'file_name_addr': 1137560, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\xd3\x17@\xc4C\x15\x9c.\xe3Hc?\xdd\xfa\xe48', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 11032738, 'mime_addr': 1137696, 'reserved1': 0, 'next_at_addr': 1124776, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.arxml False
--------------------------------------------------------------------------------
INVALID Bus logging channel group comment:
CAN_ErrorFrame
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
INVALID Bus logging channel group comment:
CAN_RemoteFrame
--------------------------------------------------------------------------------
ATTACHMENT block:
{'file_name_addr': 1124616, 'embedded_data': '', 'block_len': 96, 'md5_sum': '\x8d ,\xe1\xf8\x1f/,\xaf\xde<\xa6\x07\xcd\x17:', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 5904, 'mime_addr': 1124728, 'reserved1': 0, 'next_at_addr': 0, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.dbc False
--------------------------------------------------------------------------------
INVALID Bus logging channel group comment:
CAN_ErrorFrame
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
INVALID Bus logging channel group comment:
CAN_RemoteFrame
--------------------------------------------------------------------------------
ATTACHMENT block:
{'file_name_addr': 1151016, 'embedded_data': '', 'block_len': 96, 'md5_sum': 'W\x8e\xf8\xd6\x1a\rb\x07\\\xa5\x1e1 \xdc\xf6\x06', 'reserved0': 0, 'creator_index': 0, 'id': '##AT', 'comment_addr': 0, 'flags': 4, 'original_size': 31335, 'mime_addr': 1151136, 'reserved1': 0, 'next_at_addr': 1137744, 'links_nr': 4, 'embedded_size': 0}
C:\Desktop\Test\234890.dbc False
danielhrisca commented 6 years ago

I'll have to have a deeper look at error frames and remote frames; there's a good chance I haven't implemented all by the standard.

bhagivinni commented 6 years ago

Hi @danielhrisca, Can i get development without the print statements on the console.

danielhrisca commented 6 years ago

Hello,

you can use the latest code.

If you also want to remove warnings:

import warnings
warnings.simplefilter("ignore")
import asammdf

...
bhagivinni commented 6 years ago

Got it. Thank you @danielhrisca.