asammdf
asammdf copied to clipboard
Message name info
Hi, I'm using asammdf 7.0 for MDF (v. 4.0) analisys. but in mdf struct ( mdf = MDF(fileName) ) I can't find the message name info. Example:
fileName = r'myfile.MDF' mdf = MDF(fileName , remove_source_from_channel_names = False)
<Signal mySignal: samples=[0. ... 0.] timestamps=[9.96739000e-01 ... 1.10694713e+04] invalidation_bits=None unit="°C" conversion=None source=<asammdf.blocks.source_utils.Source object at 0x0000025A35B785E0> comment="{For VehicleX: Range_MIN = -10}" mastermeta="('t', 1)" raw=False display_names={} attachment=None>
mdf.get('mySignal').source.get_details() ' ECU source on bus CAN: name=[ 'NODE' ] path=[]'
Using mdfreader library, I find this information in the mdfreader struct :
import mdfreader yop = mdfreader.Mdf(fileName )
yop
{..... 'mySignal': {'unit': '°C', 'description': '{For VehicleX: Range_MIN = -10} ', 'master': 't_51_51', 'masterType': 0, 'data': array([0., ..., 0.]), 'axis': [], 'id': ((51, 0, 72), ('mySignal', 'NODE', None), ('MESSAGE_NAME', 'NODE', 'Message'))}}
How can I find this information using asammdf 7.0?
Best Regards, Stefano Perone
Hello Stefano, it is not clear to me what is going on there. A demo file would be really helpful
Hi Daniel, unfortunately I cannot attach the file used. Is there any other 'library output' that might be useful?
Maybe a MDFValidator screenshot with the relevant blocks
Hi Daniel, I used the 'demo.py' script to create an mdf file and I opened this file using MDFValidator tool. I'd like to read the value of the 'cg_tx_acq_name' field (in demo.mf4\Header Block\Data Group 2\Channel Group 1) using an asammdf method.
I have a similar problem right now and cannot figure how to find (and edit) the information that is shown in turbolab as follows:
Is is possible?
for i, group in enumerate(mdf.groups):
group.channel_group.acq_name = 'cg_tx_acq_name'
if group.channel_group.source is not None:
group.channel_group.source.name = 'cg_si_acq_source/si_tx_name'
group.channel_group.source.path = 'cg_si_acq_source/si_tx_path'
for j, ch in enumerate(group.channels):
ch.name = 'cn_tx_name'
if ch.source is not None:
ch.source.name = 'cn_si_source/si_tx_name'
ch.source.path = 'cn_si_source/si_tx_path'
ch.source.comment = 'cn_si_source/si_md_comment'
@danielhrisca this code shows an error.
if group.channel_group.source is not None: AttributeError: 'ChannelGroup' object has no attribute 'source'
How could we solve it?
Thank you
acq_source instead of source