Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_fmt_v4() does not handle all cases #343

Closed
timheb opened this issue Apr 3, 2020 · 12 comments
Closed

get_fmt_v4() does not handle all cases #343

timheb opened this issue Apr 3, 2020 · 12 comments

Comments

@timheb
Copy link

timheb commented Apr 3, 2020

Python version

('python=3.7.5 (tags/v3.7.5:5c02a39a0b, Oct 15 2019, 00:11:34) [MSC v.1916 64 '
'bit (AMD64)]')
'os=Windows-10-10.0.17763-SP0'
'numpy=1.17.4'
'asammdf=5.19.10'

Code

MDF version

4.11

Code snippet

  get_fmt_v4(data_type=v4c.DATA_TYPE_BYTEARRAY, size=8, channel_type=v4c.CHANNEL_TYPE_VLSD)

Traceback

  ---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
d:\repo\MRGen21_DevScene\070_Test\PerfEval\playground.py in 
      51 breakpoint()
----> 52 mdf = MDF(file_path)

D:\Software\Python37_64\lib\site-packages\asammdf\mdf.py in __init__(self, name, version, **kwargs)
    121                 self._mdf = MDF3(name, **kwargs)
    122             elif version in MDF4_VERSIONS:
--> 123                 self._mdf = MDF4(name, **kwargs)
    124             elif version in MDF2_VERSIONS:
    125                 self._mdf = MDF2(name, **kwargs)

D:\Software\Python37_64\lib\site-packages\asammdf\blocks\mdf_v4.py in __init__(self, name, version, **kwargs)
    360                     self._file = mmap.mmap(x.fileno(), 0, access=mmap.ACCESS_READ)
    361                     self._from_filelike = False
--> 362                     self._read(mapped=True)
    363 
    364                     self._file.close()

D:\Software\Python37_64\lib\site-packages\asammdf\blocks\mdf_v4.py in _read(self, mapped)
    581                 # starting from the first channel
    582                 self._read_channels(
--> 583                     ch_addr, grp, stream, dg_cntr, ch_cntr, mapped=mapped
    584                 )
    585 

D:\Software\Python37_64\lib\site-packages\asammdf\blocks\mdf_v4.py in _read_channels(self, ch_addr, grp, stream, dg_cntr, ch_cntr, channel_composition, mapped)
   1061                         ch_cntr,
   1062                         True,
-> 1063                         mapped=mapped,
   1064                     )
   1065                     dependencies[index] = ret_composition

D:\Software\Python37_64\lib\site-packages\asammdf\blocks\mdf_v4.py in _read_channels(self, ch_addr, grp, stream, dg_cntr, ch_cntr, channel_composition, mapped)
   1100                         channel.data_type,
   1101                         channel.bit_offset + channel.bit_count,
-> 1102                         channel.channel_type,
   1103                     )
   1104                 )

D:\Software\Python37_64\lib\site-packages\asammdf\blocks\utils.py in get_fmt_v4(data_type, size, channel_type)
    423                 fmt = f">c{size}"
    424 
--> 425     return fmt
    426 
    427 

UnboundLocalError: local variable 'fmt' referenced before assignment

Description

It seems to me that the function get_fmt_v4() cannot handle all cases

@danielhrisca
Copy link
Owner

Hello Tim,

can you print the variable channel before calling get_fmt_v4 ?

@danielhrisca
Copy link
Owner

get_fmt_v4(data_type=v4c.DATA_TYPE_BYTEARRAY, size=1, channel_type=v4c.CHANNEL_TYPE_VLSD)

This looks strange: a VLSD channel with bit count = 1? Did you open the file with MDFValidator?

@timheb
Copy link
Author

timheb commented Apr 3, 2020

thanks for your quick reply

you are right the bit count = 8 = > size = 8

the MDF Validator finds no objections to the file
image

@danielhrisca
Copy link
Owner

you will find the fix in version 5.19.11

@danielhrisca
Copy link
Owner

actually version 5.19.12

@danielhrisca
Copy link
Owner

can you share a MDFValidator screenshot of the Channel group that contains this channel?

@timheb
Copy link
Author

timheb commented Apr 6, 2020

thanks a lot

image

image

@david-gwa
Copy link

hey, @danielhrisca , there are still some un-handles casees in version 5.20.6

e.g. DATA_TYPE_MIMME_SAMPLE(11)

there is no fmt implemented yet in utils.py ..

@david-gwa
Copy link

I added the following inside while ch_addr loop of `mdf_v4.py :

            # by-pass MIME_SAMPLE || MIME_STREAM types 
            if channel.data_type == 11 or channel.data_type == 12 :
                print("**WARNING** channel.data_type", channel.data_type, " is ignored\n")
                ch_addr = channel.next_ch_addr
                continue  

            # by-pass additionaly VALUE_TYPEs
            # e.g.  Functions(Matlab/Simulink, Algorithms),  
            #       Global variables
            #       Objects
            #       Measurement signal(multimedia)
            if channel.data_type > 16 or channel.data_type < 0 :
                print("**WARNING** channel.data_type", channel.data_type, "is ignored\n")
                ch_addr = channel.next_ch_addr
                continue      

@danielhrisca
Copy link
Owner

@david-gwa
I've pushed some fixes to the development branch. I would be interested in analyzing your file, if you can share it (as it is, or scrambled)

@david-gwa
Copy link

@david-gwa
I've pushed some fixes to the development branch. I would be interested in analyzing your file, if you can share it (as it is, or scrambled)

there are Simulink objects/ cam-stream data in our mf4 files. which are very customized, thanks

@david-gwa
Copy link

I am not sure it's a good idea to play cam-stream as a plugin in asammdf... there maybe some needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants