danielhrisca / asammdf

Fast Python reader and editor for ASAM MDF / MF4 (Measurement Data Format) files
GNU Lesser General Public License v3.0
631 stars 223 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

Hello,

It would be better to post the full traceback so we can see exactly the line that triggers the exception.

What numpy version do you have installed?

bhagivinni commented 6 years ago

Hello, I am using 1.13.3 version of Numpy which is included in Anaconda package. And coming to traceback i am getting generator error while using export in MDF module with parameter "filename = 'mat'", here is the code where error occurs.

Code

  elif fmt == 'mat':
            try:
                from scipy.io import savemat
            except ImportError:
                warn('scipy not found; export to mat is unavailable')
                return

            name = os.path.splitext(name)[0] + '.mat'
            mdict = {}

            master = 'DataGroup_{}_{}_master'
            channel = 'DataGroup_{}_{}'

            for i, grp in enumerate(self.groups):
                master_index = self.masters_db.get(i, -1)
                data = self._load_group_data(grp)
                for j, _ in enumerate(grp['channels']):
                    sig = self.get(
                        group=i,
                        index=j,
                        data=data,
                    )

Here in the code data variable assigned is a generator so while trying to access data in "sig" it returns just a generator object but not the next item or channel, hence it is not processed further.

Why array mismatch error raises and can i get the solution??

danielhrisca commented 6 years ago

Hey, I think I found the problem.

Please install the latest development branch (__version__ = 3.2.2dev):

pip install -I --no-deps https://GitHub.com/danielhrisca/asammdf/archive/development.zip
bhagivinni commented 6 years ago

Hi, Thanks for the response, will get the version mentioned and will try again.

bhagivinni commented 6 years ago

Hi, I am getting this error do you have any idea regarding this?? <class 'asammdf.utils.MdfException'>, MdfException('samples and timestamps length mismatch (24 vs 31)',),

We cannot export file if we have uneven samples and timestamps??

danielhrisca commented 6 years ago

Hello,

you still don't print the full traceback. I know where this error appears but I don't know where it originates. It's very difficult to debug this way.

Is it possible to send me the file over e-mail cu investigate? If you are not allowed, then at least print the full treaceback

Here is an example of what I mean:

Traceback (most recent call last):
  File "C:/.PyCharmCE2017.2/config/scratches/scratch_8.py", line 6, in <module>
    x.export('mat', r'file.mat')
  File "E:\02__PythonWorkspace\asammdf\asammdf\mdf.py", line 733, in export
    data=data,
  File "E:\02__PythonWorkspace\asammdf\asammdf\mdf_v4.py", line 4468, in get
    master_metadata=master_metadata,
  File "E:\02__PythonWorkspace\asammdf\asammdf\signal.py", line 78, in __init__
    raise Exception('demo traceback')
Exception: demo traceback

instead of

Exception: demo traceback
bhagivinni commented 6 years ago

Hi, Sorry for the inconvenience, Please find detailed traceback here.

Traceback (most recent call last):
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 733, in export
    data=data,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 4468, in get
    master_metadata=master_metadata,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\signal.py", line 85, in __init__
    raise MdfException(message)
asammdf.utils.MdfException: samples and timestamps length mismatch (24 vs 31)

Process finished with exit code 1

danielhrisca commented 6 years ago

Using the new code from development you will also see the channel name that triggers the error.

Please post a screenshot of this channel using MDFValidator from Vector https://vector.com/vi_news_detail_en,422738,,181791,detail.html with the channel's sub-tree expanded and the channel fields visible:

image

bhagivinni commented 6 years ago

Hi, Is New code in the previous comment refers to new version of ASAMMDF (now i am using 3.2.2) ??

danielhrisca commented 6 years ago

Same version, just run the pip command again to fetch he latest code

danielhrisca commented 6 years ago

I've created a new utility function to print extra information in case of errors.

Please use the same pip command to fetch the latest development code, and post here the printed output. It should be something similar to this:

SIGNAL =========================================================================
samples: 10000 [ 0  1  2 ..., 17 18 19]
timestamps: 10000 [  0.00000000e+00   1.00000000e+00   2.00000000e+00 ...,   9.99700000e+03
   9.99800000e+03   9.99900000e+03]
master meta: ('Unsigend_UInt64_LE_Master_Offset_0', 1)

MDF ============================================================================
name: test.mf4
version: 4.10
memory: minimum
read fragment size: 0
write fragment size: 8388608

GROUP ==========================================================================
sorted: True
data location: 0
record_size: {0: 24}
parets: {0: ('Unsigend_UInt64_LE_Master_Offset_0', 0), 1: ('Unsigend_UInt64_LE_Offset_64', 0), 2: ('Unsigend_UInt32_LE_Offset_128', 0), 3: ('Unsigend_UInt16_LE_Offset_160', 0), 4: ('Unsigend_UInt8_LE_Offset_176', 0), 5: ('Unsigend_UInt1_LE_Offset_184', 0)}
dtypes: [('Unsigend_UInt64_LE_Master_Offset_0', '<u8'), ('Unsigend_UInt64_LE_Offset_64', '<u8'), ('Unsigend_UInt32_LE_Offset_128', '<u4'), ('Unsigend_UInt16_LE_Offset_160', '<u2'), ('Unsigend_UInt8_LE_Offset_176', 'u1'), ('Unsigend_UInt1_LE_Offset_184', 'u1'), ('invalidation_bytes', 'u1', (0,))]

CHANNEL GROUP ==================================================================
record id: 0
record size: 24
invalidation bytes: 0
cycles: 10000

CHANNEL ========================================================================
channel: {'id': b'##CN', 'reserved0': 0, 'block_len': 160, 'links_nr': 8, 'next_ch_addr': 66760, 'component_addr': 0, 'name_addr': 16392, 'source_addr': 0, 'conversion_addr': 0, 'data_block_addr': 0, 'unit_addr': 0, 'comment_addr': 0, 'channel_type': 0, 'sync_type': 0, 'data_type': 0, 'bit_offset': 0, 'byte_offset': 8, 'bit_count': 64, 'flags': 0, 'pos_invalidation_bit': 0, 'precision': 0, 'reserved1': 0, 'attachment_nr': 0, 'min_raw_value': 0.0, 'max_raw_value': 0.0, 'lower_limit': 0.0, 'upper_limit': 0.0, 'lower_ext_limit': 0.0, 'upper_ext_limit': 0.0}
name: Unsigend_UInt64_LE_Offset_64
conversion: None
conversion ref blocks: None

CHANNEL ARRAY ==================================================================
array: False
bhagivinni commented 6 years ago

Hi @danielhrisca , Thanks for the support. Please find the output with the recent updated code.

SIGNAL =========================================================================
samples: 24 [4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4]
timestamps: 31 [  9.79462276e-001  -3.53714500e+062   0.00000000e+000   5.56269005e-318
   1.99995891e-316  -5.87613263e-040   3.78576700e-279   2.17290071e-320
   3.58706481e-319   2.45132255e-260   2.68994924e-293   8.39911598e-323
   2.05239771e-298   2.09784351e+001   1.30009982e+262   0.00000000e+000
   5.56269005e-318   2.01348559e-316  -5.76791028e+284   4.27197407e+087
   2.17290071e-320   3.59185725e-319   3.83152087e-162  -3.70534686e+070
   8.39911598e-323   2.05239784e-298   4.09775347e+001   2.83402959e+063
   0.00000000e+000   5.56269005e-318   2.01902658e-316]
master meta: (u't', 1)

('MDF', '============================================================================')
('name:', 'Sample_mdf.MF4')
('version:', u'4.10')
('memory:', 'low')
('read fragment size:', 0)
('write fragment size:', 8388608)
()
('GROUP', '==========================================================================')
('sorted:', True)
('data location:', 0)
('record_size:', {1: 13})
('parets:', {0: (u't', 0), 2: (u'Sum_Con', 0)})
('dtypes:', dtype([('t', '<f8'), ('Sum_Con', '<u2'), ('invalidation_bytes', 'u1', (0,))]))
()
('CHANNEL GROUP', '==================================================================')
('record id:', 1)
('record size:', 13)
('invalidation bytes:', 0)
('cycles:', 24)
()
('CHANNEL', '========================================================================')
('channel:', {'upper_ext_limit': 0.0, 'bit_offset': 0, 'id': '##CN', 'reserved1': 0, 'reserved0': 0, 'component_addr': 0, 'name_addr': 2386784, 'sync_type': 0, 'bit_count': 20, 'data_block_addr': 0, 'comment_addr': 2387104, 'source_addr': 2387288, 'data_type': 0, 'byte_offset': 10, 'unit_addr': 0, 'precision': 255, 'max_raw_value': 4.0, 'upper_limit': 104857.5, 'lower_limit': 0.0, 'min_raw_value': 4.0, 'block_len': 160, 'pos_invalidation_bit': 0, 'attachment_nr': 0, 'channel_type': 0, 'flags': 28, 'next_ch_addr': 2386624, 'lower_ext_limit': 0.0, 'conversion_addr': 2387000, 'links_nr': 8})
('name:', u'Sum_Con_Stat')
('conversion:', {'block_len': 104, 'val_0': 1048575.0, 'name_addr': 2386936, 'inv_conv_addr': 0, 'default_addr': 2386840, 'unit_addr': 0, 'reserved0': 0, 'conversion_type': 7, 'val_param_nr': 1, 'comment_addr': 1251176, 'flags': 7, 'text_0': 1245048, 'precision': 1, 'min_phy_value': 0.4, 'ref_param_nr': 2, 'id': '##CC', 'links_nr': 6, 'max_phy_value': 0.4})
('conversion ref blocks:', {'default_addr': {'a': 0.1, 'block_len': 96, 'b': 0.0, 'name_addr': 0, 'inv_conv_addr': 0, 'unit_addr': 32024, 'reserved0': 0, 'conversion_type': 1, 'val_param_nr': 2, 'comment_addr': 0, 'flags': 1, 'precision': 1, 'min_phy_value': 0.0, 'ref_param_nr': 0, 'id': '##CC', 'links_nr': 4, 'max_phy_value': 0.0}, 'text_0': {'text': 'SNA\x00\x00\x00\x00\x00', 'block_len': 32, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}})
()
('CHANNEL ARRAY', '==================================================================')
('array:', False)
()
Traceback (most recent call last):
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 733, in export
    data=data,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 4470, in get
    master_metadata=master_metadata,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\signal.py", line 89, in __init__
    raise MdfException(message)
asammdf.utils.MdfException: Sum_Con_Stat samples and timestamps length mismatch (24 vs 31)
danielhrisca commented 6 years ago

Hello @bhagivinni ,

it was a good idea to prepare the debug function. I think the issue is fixed in the latest development commit (https://github.com/danielhrisca/asammdf/commit/37f1b6bf4e446443af60e4f997aa1ba5c12c4120). Please give it a try.

bhagivinni commented 6 years ago

Thank you @danielhrisca, Will try latest development.

bhagivinni commented 6 years ago

Hi @danielhrisca,

After testing the new commit development code, i got this error.

 File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 733, in export
    data=data,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 3741, in get
    vals = fromarrays(arrays, dtype=types)
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\numpy\core\records.py", line 619, in fromarrays
    raise ValueError("array-shape mismatch in array %d" % k)
ValueError: array-shape mismatch in array 1
danielhrisca commented 6 years ago

I think the first issue is now fixed and this is a separate issue.

I've created a new branch to isolate this investigation from the other code : (https://github.com/danielhrisca/asammdf/tree/fix_issue_50)

pip install -I --no-deps https://GitHub.com/danielhrisca/asammdf/archive/fix_issue_50.zip

Let's see what the debug prints with this code

bhagivinni commented 6 years ago

This is the latest debug prints.

  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 733, in export
    data=data,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 3742, in get
    vals = fromarrays(arrays, dtype=types)
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\numpy\core\records.py", line 619, in fromarrays
SIGNALS ========================================================================
SKS_Data 0 float64
SKS_Data 0 uint8
SKS_Data  0 uint8
SKS_Data  0 uint8
SKS_Data  0 uint32
SKS_Data  0 uint32
SKS_Data  0 uint8
SKS_Data  0 uint8
SKS_Data  0 uint8
('MDF', '============================================================================')
('name:', 'sample_mdf.MF4')
('version:', u'4.10')
('memory:', 'low')
('read fragment size:', 0)
('write fragment size:', 8388608)
()
('GROUP', '==========================================================================')
('sorted:', True)
('data location:', 0)
('record_size:', {1: 0})
('parets:', {0: (u't', 0), 1: (u'SKS_Data.DataBytes', 27), 2: (u'SKS_Data .DataBytes', 26), 3: (u'SKS_Data.DataBytes', 24), 4: (u'SKS_Data .DataBytes', 25), 5: (u'SKS_Data .DataBytes', 31), 6: (u'SKS_Data .DataBytes', 4), 7: (u'SKS_Data .DataBytes', 1), 8: (u'SKS_Data.DataBytes', 3), 9: (u'SKS_Data.DataBytes', 6), 10: (u'SKS_Data.DataBytes', 0), 11: (u'SKS_Data.DataBytes', 8), 12: (u'SKS_Data.DataBytes', 16), 13: (None, None), 14: (u'SKS_Data.ID', 0), 15: (u'SKS_Data.DataBytes', 0), 16: (u'SKS_Data.DLC', 0), 17: (u'SKS_Data.Flags', 0), 18: (u'SKS_Data.ID', 0), 19: (u'SKS_Data.ID', 31), 20: (u'SKS_Data.Flags', 5), 21: (u'SKS_Data.Flags', 6), 22: (u'SKS_Data.DataLength', 0)})
('dtypes:', dtype([('t', '<f8'), ('SKS_Data.ID', '<u4'), ('SKS_Data.Flags', 'u1'), ('SKS_Data.DLC', 'u1'), ('SKS_Data.DataLength', 'u1'), ('SKS_Data.DataBytes', 'u1', (8,)), ('invalidation_bytes', 'u1', (0,))]))
()
('CHANNEL GROUP', '==================================================================')
('record id:', 1)
('record size:', 23)
('invalidation bytes:', 0)
('cycles:', 0)
()
('CHANNEL', '========================================================================')
('channel:', {'upper_ext_limit': 0.0, 'bit_offset': 0, 'id': '##CN', 'reserved1': 0, 'reserved0': 0, 'component_addr': 1504600, 'name_addr': 1504760, 'sync_type': 0, 'bit_count': 120, 'data_block_addr': 0, 'comment_addr': 1504800, 'attachment_0_addr': 1137744, 'source_addr': 1505152, 'data_type': 10, 'byte_offset': 8, 'unit_addr': 0, 'precision': 255, 'max_raw_value': 0.0, 'upper_limit': 1.0, 'lower_limit': 0.0, 'min_raw_value': 0.0, 'block_len': 168, 'pos_invalidation_bit': 0, 'attachment_nr': 1, 'channel_type': 0, 'flags': 1028, 'next_ch_addr': 0, 'lower_ext_limit': 0.0, 'conversion_addr': 0, 'links_nr': 9})
('name:', u'SKS_Data')
('conversion:', {})
('conversion ref blocks:', None)
()
('CHANNEL ARRAY', '==================================================================')
('array:', True)
()
    raise ValueError("array-shape mismatch in array %d" % k)
ValueError: array-shape mismatch in array 1

Process finished with exit code 1
danielhrisca commented 6 years ago

Please try again with the new commit from fix_issue_50 https://github.com/danielhrisca/asammdf/commit/3b20b452e52bafa80ae6b5bad1b14a95be78207a

bhagivinni commented 6 years ago

Hi @danielhrisca , Got this after running latest commit.

SIGNALS ========================================================================
SKS_Data .BusChannel 0 float64
SKS_Data .DataBytes 0 uint8
SKS_Data .DLC 0 uint8
SKS_Data .Flags 0 uint8
SKS_Data .ID 0 uint3
SKS_Data .IDE 0 uint32
SKS_Data .SingleWire 0 uint8
SKS_Data .WakeUp 0 uint8
SKS_Data .DataLength 0 uint8
('MDF', '============================================================================')
('name:', 'sample_mdf.MF4')
('version:', u'4.10')
('memory:', 'low')
('read fragment size:', 0)
('write fragment size:', 8388608)
()
('GROUP', '==========================================================================')
('sorted:', True)
('data location:', 0)
('record_size:', {1: 23})
('parets:', {0: (u't', 0), 1: (u'SKS_Data .DataBytes', 27), 2: (u'SKS_Data.DataBytes', 26), 3: (u'SKS_Data.DataBytes', 24), 4: (u'SKS_Data .DataBytes', 25), 5: (u'SKS_Data.DataBytes', 31), 6: (u'SKS_Data.DataBytes', 4), 7: (u'SKS_Data.DataBytes', 1), 8: (u'SKS_Data.DataBytes', 3), 9: (u'SKS_Data.DataBytes', 6), 10: (u'SKS_Data.DataBytes', 0), 11: (u'SKS_Data.DataBytes', 8), 12: (u'SKS_Data.DataBytes', 16), 13: (None, None), 14: (u'SKS_Data.ID', 0), 15: (u'SKS_Data.DataBytes', 0), 16: (u'SKS_Data.DLC', 0), 17: (u'SKS_Data.Flags', 0), 18: (u'SKS_Data.ID', 0), 19: (u'SKS_Data.ID', 31), 20: (u'SKS_Data.Flags', 5), 21: (u'SKS_Data.Flags', 6), 22: (u'SKS_Data.DataLength', 0)})
('dtypes:', dtype([('t', '<f8'), ('SKS_Data.ID', '<u4'), ('SKS_Data.Flags', 'u1'), ('SKS_Data.DLC', 'u1'), ('SKS_Data .DataLength', 'u1'), ('SKS_Data .DataBytes', 'u1', (8,)), ('invalidation_bytes', 'u1', (0,))]))
()
('CHANNEL GROUP', '==================================================================')
('record id:', 1)
('record size:', 23)
('invalidation bytes:', 0)
('cycles:', 0)
()
('CHANNEL', '========================================================================')
('channel:', {'upper_ext_limit': 0.0, 'bit_offset': 0, 'id': '##CN', 'reserved1': 0, 'reserved0': 0, 'component_addr': 1504600, 'name_addr': 1504760, 'sync_type': 0, 'bit_count': 120, 'data_block_addr': 0, 'comment_addr': 1504800, 'attachment_0_addr': 1137744, 'source_addr': 1505152, 'data_type': 10, 'byte_offset': 8, 'unit_addr': 0, 'precision': 255, 'max_raw_value': 0.0, 'upper_limit': 1.0, 'lower_limit': 0.0, 'min_raw_value': 0.0, 'block_len': 168, 'pos_invalidation_bit': 0, 'attachment_nr': 1, 'channel_type': 0, 'flags': 1028, 'next_ch_addr': 0, 'lower_ext_limit': 0.0, 'conversion_addr': 0, 'links_nr': 9})
('name:', u'SKS_Data')
('conversion:', {})
('conversion ref blocks:', None)
()
('CHANNEL ARRAY', '==================================================================')
('array:', True)
()

Traceback (most recent call last):
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 733, in export
    data=data,
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 3742, in get
    vals = fromarrays(arrays, dtype=types)
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\numpy\core\records.py", line 619, in fromarrays
    raise ValueError("array-shape mismatch in array %d" % k)
ValueError: array-shape mismatch in array 1
danielhrisca commented 6 years ago

I'm 99% sure the new commit is the final one https://github.com/danielhrisca/asammdf/commit/255953aeee8ecf93f4a17e326b0d878e101b832f

bhagivinni commented 6 years ago

Hi @danielhrisca,

I got this when i tried with latest commit, but i think this is from other library. Can you help me on this?

Traceback (most recent call last):
  File "C:\AppData\Local\Continuum\anaconda2\lib\ntpath.py", line 67, in join
    p_drive, p_path = splitdrive(p)
  File "C:\AppData\Local\Continuum\anaconda2\lib\ntpath.py", line 115, in splitdrive
    if len(p) > 1:
TypeError: object of type 'NoneType' has no len()
danielhrisca commented 6 years ago

Do you provide a file name when you call the export method?

bhagivinni commented 6 years ago

@danielhrisca, Yes i have given the file name.

danielhrisca commented 6 years ago

The traceback looks strange. Did you remove some lines? I can't see how it relates to the export method.

bhagivinni commented 6 years ago

No @danielhrisca i didn't remove lines from code, but i agree that traceback looks strange.

danielhrisca commented 6 years ago

I think this means that there is another problem on your setup, and you don't even reach the line that imports asammdf. Can you place some print statements in your script to confirm this?

bhagivinni commented 6 years ago

Anyway it might be due to the path and not related to export method, so let me check and then will come back to you. Thank you.

bhagivinni commented 6 years ago

Hi @danielhrisca, i had some problem in setup, so i had reinstalled the package. so when i tried running ,i got this error.

File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf.py", line 79, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 302, in __init__
    self._read()
  File "C:\AppData\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 446, in _read
    grp['can_id'] = can_id
UnboundLocalError: local variable 'can_id' referenced before assignment
danielhrisca commented 6 years ago

Hello,

I've merged the branch fix_issue_50 into development so please use the latest code from here https://github.com/danielhrisca/asammdf/commit/267298322b8b712a064c45bcf0f137192b5b555d

Your file contains bus logging. For now there is initial support for CAN bus logging http://asammdf.readthedocs.io/en/development/buslogging.html

Let me know if it works correctly now.

bhagivinni commented 6 years ago

Hello @danielhrisca,

When i tried to execute recent development code i got this error,

C:\anaconda2\lib\site-packages\asammdf\mdf_v4.py:460: UserWarning: Invalid bus logging channel group metadata
  warnings.warn('Invalid bus logging channel group metadata')
Traceback (most recent call last):
  File "C:\Desktop/Data.py/main.py", line 134, 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 80, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 303, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 461, in _read
    grp['can_id'] = can_id
UnboundLocalError: local variable 'can_id' referenced before assignment
danielhrisca commented 6 years ago

You did not update correctly. This is how line 461 looks like https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf_v4.py#L461

bhagivinni commented 6 years ago

Hi @danielhrisca, https://github.com/danielhrisca/asammdf/commit/267298322b8b712a064c45bcf0f137192b5b555d commit shared on Friday code is different to the above link, i had made changes as per this commit, is this latest or above link which mentioned is the latest one??

bhagivinni commented 6 years ago

Hi @danielhrisca, I am getting same error..

C:\anaconda2\lib\site-packages\asammdf\mdf_v4.py:460: UserWarning: Invalid bus logging channel group metadata
  warnings.warn('Invalid bus logging channel group metadata')
Traceback (most recent call last):
  File "C:\Desktop/Data.py/main.py", line 134, 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 80, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 303, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 461, in _read
    grp['can_id'] = can_id
UnboundLocalError: **local variable 'can_id' referenced before assignment**
bhagivinni commented 6 years ago

With https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf_v4.py#L461 development code, i am getting same error,

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:457: UserWarning: Invalid bus logging channel group metadata
  warnings.warn('Invalid bus logging channel group metadata')
Traceback (most recent call last):
  File "C:/Desktop/data.py/main.py", line 134, 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 80, in __init__
    self._mdf = MDF4(name, memory)
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 303, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 458, in _read
    grp['can_id'] = can_id
UnboundLocalError: local variable 'can_id' referenced before assignment

Process finished with exit code 1
danielhrisca commented 6 years ago

Ok it looks like the channel group comment does not match what was expected in case of bug logging.

You should get a warning from line 461 (https://github.com/danielhrisca/asammdf/blob/development/asammdf/mdf_v4.py#L461), please post it here.

bhagivinni commented 6 years ago

Yes @danielhrisca, Channel group does not match what was expected, here is the output for above development code.

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1377</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1369</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1378</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1379</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1291</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:461: UserWarning: Invalid bus logging channel group metadata: <CGcomment>
<TX>Network Management</TX>
<common_properties>
<e name="MessageID" ro="true">1328</e>
<e name="MessageDLC" ro="true">8</e>
</common_properties>
</CGcomment>
  warnings.warn('Invalid bus logging channel group metadata: {}'.format(comment))
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3555: 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:Desktop/data.py/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 303, in __init__
    self._read()
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 508, in _read
    neg_ch_cntr,
  File "C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py", line 883, in _read_channels
    database_format='dbc'
  File "C:\Local\Continuum\anaconda2\lib\site-packages\cantools\db\__init__.py", line 129, in load_string
    raise UnsupportedDatabaseFormatError(e_dbc, e_kcd, e_sym)
cantools.db.UnsupportedDatabaseFormatError: DBC: "Invalid DBC syntax at line 1, column 1: '>!<': Expected {VERSION | NS_ | BS_ | BU_ | BO_ | CM_ | BA_DEF_ | BA_DEF_DEF_ | BA_ | VAL_ | VAL_TABLE_ | SIG_VALTYPE_ | SG_MUL_VAL_ | BO_TX_BU_ | BA_DEF_REL_ | BA_DEF_DEF_REL_ | BA_REL_ | SIG_GROUP_ | EV_}."

Process finished with exit code 1
danielhrisca commented 6 years ago

This is moving along with baby steps. Is it possible to send the file via e-mail?

bhagivinni commented 6 years ago

Do You mean mdf file??

danielhrisca commented 6 years ago

Yes the mdf file. I will treat it with maximum discretion and will not distribute it further.

bhagivinni commented 6 years ago

Sorry @danielhrisca, That was quite confidential we cannot access it, it was restricted.

danielhrisca commented 6 years ago

I understand.

I've changed the channel group comment parsing and it should now work correctly with your file.

Please try again and post the prints.

bhagivinni commented 6 years ago

These are the recent prints i got from execution

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:455: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  if common_properties:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3571: 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 953, in <module>
ATTACHED database "" (first 10 lines):
[]
  File "C:/Desktop/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 894, in _read_channels
    database_format='dbc',
  File "C:\\Local\Continuum\anaconda2\lib\site-packages\cantools\db\__init__.py", line 129, in load_string
    raise UnsupportedDatabaseFormatError(e_dbc, e_kcd, e_sym)
cantools.db.UnsupportedDatabaseFormatError: DBC: "Invalid DBC syntax at line 1, column 1: '>!<': Expected {VERSION | NS_ | BS_ | BU_ | BO_ | CM_ | BA_DEF_ | BA_DEF_DEF_ | BA_ | VAL_ | VAL_TABLE_ | SIG_VALTYPE_ | SG_MUL_VAL_ | BO_TX_BU_ | BA_DEF_REL_ | BA_DEF_DEF_REL_ | BA_REL_ | SIG_GROUP_ | EV_}."

Process finished with exit code 1
danielhrisca commented 6 years ago

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3571: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')

this means there should be an external dbc file, but the file name specified in the attachment block is not correct.

This is how a correct external attachment looks like: image image

We should see the attachment block structure with the new commit. Please retry.

bhagivinni commented 6 years ago

Output for new commit:

ATTACHMENT block:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:455: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
{'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}
  if common_properties:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3571: 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:/Desktop/data/main.py", line 953, in <module>
    mdf_parser = asammdf.mdf.MDF(name=file_name, memory='minimum', version='4.00')
  File "C:\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 894, in _read_channels
ATTACHMENT block:
{'file_name_addr': 1174564, 'embedded_data': '', 'block_len': 98, 'md5_sum': '\xd2\x16@\xc3C\x16\x8c.\xe3Hc?\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}
ATTACHED database "" (first 10 lines):
[]
    database_format='dbc',
  File "C:\Local\Continuum\anaconda2\lib\site-packages\cantools\db\__init__.py", line 129, in load_string
    raise UnsupportedDatabaseFormatError(e_dbc, e_kcd, e_sym)
cantools.db.UnsupportedDatabaseFormatError: DBC: "Invalid DBC syntax at line 1, column 1: '>!<': Expected {VERSION | NS_ | BS_ | BU_ | BO_ | CM_ | BA_DEF_ | BA_DEF_DEF_ | BA_ | VAL_ | VAL_TABLE_ | SIG_VALTYPE_ | SG_MUL_VAL_ | BO_TX_BU_ | BA_DEF_REL_ | BA_DEF_DEF_REL_ | BA_REL_ | SIG_GROUP_ | EV_}."

Process finished with exit code 1
danielhrisca commented 6 years ago

I forgot to print the text blocks associated with the attachment. Look at the new prints and make sure you have the external file at the proper path.

bhagivinni commented 6 years ago

Output for latest commit:

C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:455: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  if common_properties:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3571: UserWarning: Exception during attachment extraction: WindowsError(123, 'The filename, directory name, or volume label syntax is incorrect')
  warnings.warn(message)
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}}
Traceback (most recent call last):
  File "C:/Desktop/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 894, in _read_channels
    database_format='dbc',
  File "C:\Local\Continuum\anaconda2\lib\site-packages\cantools\db\__init__.py", line 129, in load_string
    raise UnsupportedDatabaseFormatError(e_dbc, e_kcd, e_sym)
cantools.db.UnsupportedDatabaseFormatError: DBC: "Invalid DBC syntax at line 1, column 1: '>!<': Expected {VERSION | NS_ | BS_ | BU_ | BO_ | CM_ | BA_DEF_ | BA_DEF_DEF_ | BA_ | VAL_ | VAL_TABLE_ | SIG_VALTYPE_ | SG_MUL_VAL_ | BO_TX_BU_ | BA_DEF_REL_ | BA_DEF_DEF_REL_ | BA_REL_ | SIG_GROUP_ | EV_}."
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}}
ATTACHED database "" (first 10 lines):
[]

Process finished with exit code 1
danielhrisca commented 6 years ago

The attachment points to an arxml file. Currently only dbc files are supported. The new code should give an warning about this and ignore the bus logging handling; this means you will not be able to select signals as described in the data base (arxml file in your case).

bhagivinni commented 6 years ago

I think it is raising error for .dbc files also,


C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:455: FutureWarning: The behavior of this method will change in future versions.  Use specific 'len(elem)' or 'elem is not None' test instead.
  if common_properties:
C:\Local\Continuum\anaconda2\lib\site-packages\asammdf\mdf_v4.py:3564: 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:893: UserWarning: Expected .dbc file as CAN channel attachment but got "C:\..\File_data\sample_mdf.arxml"
  warnings.warn('Expected .dbc file as CAN channel attachment but got "{}"'.format(at_name))
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}}
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}}
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}}
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}}
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}}
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}}
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}
{'file_name_addr': {'text': 'c:\..\File_data\sample_mdf.dbc\x00\x00\x00\x00\x00\x00': {'text': 'application/x-dbc\x00\x00\x00\x00\x00\x00\x00', 'block_len': 48, 'id': '##TX', 'links_nr': 0, 'reserved0': 0}}
Traceback (most recent call last):
  File "C:\Desktop/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 898, in _read_channels
    database_format='dbc',
  File "C:\Local\Continuum\anaconda2\lib\site-packages\cantools\db\__init__.py", line 129, in load_string
    raise UnsupportedDatabaseFormatError(e_dbc, e_kcd, e_sym)
cantools.db.UnsupportedDatabaseFormatError: DBC: "Invalid DBC syntax at line 1, column 1: '>!<': Expected {VERSION | NS_ | BS_ | BU_ | BO_ | CM_ | BA_DEF_ | BA_DEF_DEF_ | BA_ | VAL_ | VAL_TABLE_ | SIG_VALTYPE_ | SG_MUL_VAL_ | BO_TX_BU_ | BA_DEF_REL_ | BA_DEF_DEF_REL_ | BA_REL_ | SIG_GROUP_ | 
```EV_}."
danielhrisca commented 6 years ago

Do you have the files at the location specified ? C:\File_data\sample_mdf.dbc??

bhagivinni commented 6 years ago

Yes, files are there in the path specified.