mefistotelis / pylabview

Python reader of LabVIEW RSRC files (VI, CTL, LLB). File format description on the Wiki.
MIT License
86 stars 24 forks source link

Traceback on fixed point object #3

Open Suicidal-Insanity opened 3 years ago

Suicidal-Insanity commented 3 years ago

When running this on a realtime system VI, I get the following traceback:

Error: 'TDObjectFixedPoint' object has no attribute 'rangeFormat'
Traceback (most recent call last):
  File "readRSRC.py", line 224, in <module>
    main()
  File "readRSRC.py", line 160, in main
    vi = VI(po, rsrc_fh=rsrc_fh, text_encoding=po.textcp)
  File "pylabview-master\LVrsrcontainer.py", line 233, in __init__
    self.readRSRC(rsrc_fh)
  File "pylabview-master\LVrsrcontainer.py", line 388, in readRSRC
    self.checkSanity()
  File "pylabview-master\LVrsrcontainer.py", line 803, in checkSanity
    if not block.checkSanity():
  File "pylabview-master\LVblock.py", line 6159, in checkSanity
    ret = self.checkTypeDescListSanity(section, section_num)
  File "pylabview-master\LVblock.py", line 5845, in checkTypeDescListSanity
    if not clientTD.nested.checkSanity():
  File "pylabview-master\LVdatatype.py", line 2464, in checkSanity
    ret = super().checkSanity()
  File "pylabview-master\LVdatatype.py", line 838, in checkSanity
    if not super().checkSanity():
  File "pylabview-master\LVdatatype.py", line 672, in checkSanity
    exp_whole_len = self.expectedRSRCSize()
  File "pylabview-master\LVdatatype.py", line 2351, in expectedRSRCSize
    ref_obj_len = self.ref_obj.expectedRSRCSize()
  File "pylabview-master\LVdatatyperef.py", line 310, in expectedRSRCSize
    exp_whole_len += obj.expectedRSRCSize()
  File "pylabview-master\LVclasses.py", line 479, in expectedRSRCSize
    exp_whole_len += clientTD.nested.expectedRSRCSize()
  File "pylabview-master\LVdatatype.py", line 2706, in expectedRSRCSize
    if self.rangeFormat == 0:
AttributeError: 'TDObjectFixedPoint' object has no attribute 'rangeFormat'

I checked and the parseRSRCData function was not called for the object instance that throws the error.

Previously I received multiple warnings which may be relevant:

example.vi: Warning: Block b'LIbd' section 0 parse exception: LinkObj b'HpEr' parsing not implemented.
example.vi: Warning: Block b'LIbd' section 0 size is 55422 and does not match parsed size 21419
example.vi: Warning: Block b'LIds' section 0 parse exception: LinkObj b'DSVl' parsing not implemented.
example.vi: Warning: Block b'LIds' section 0 size is 24085 and does not match parsed size 1968
example.vi: Warning: Block b'LIvi' section 0 parse exception: LinkObj b'VIVl' parsing not implemented.
example.vi: Warning: Block b'LIvi' section 0 size is 29914 and does not match parsed size 3387
example.vi: Warning: Heap Container tag='OF__StdNumMin' parse exception: Tag 'OF__StdNumMin' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Heap Container tag='OF__StdNumMax' parse exception: Tag 'OF__StdNumMax' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Heap Container tag='OF__StdNumInc' parse exception: Tag 'OF__StdNumInc' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Heap Container tag='OF__StdNumMin' parse exception: Tag 'OF__StdNumMin' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Heap Container tag='OF__StdNumMax' parse exception: Tag 'OF__StdNumMax' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Heap Container tag='OF__StdNumInc' parse exception: Tag 'OF__StdNumInc' of Class 'SL__stdNum' could not parse its TypeDesc type=95 dependent content.
example.vi: Warning: Block b'FPTD' section 0 size is 4 and does not match parsed size 2
example.vi: Warning: Block b'CPC2' section 0 size is 4 and does not match parsed size 2
example.vi: Warning: Block b'CCST' section 0 size is 186 and does not match parsed size 4

Also, slightly off topic, but diffing the XML file with one generated from a slightly modified VI shows a massive amount of changes. Is the order of the XML output variable, or does labview regenerate all the IDs everytime?

mefistotelis commented 3 years ago

File "pylabview-master\LVdatatype.py", line 2706, in expectedRSRCSize if self.rangeFormat == 0:

Hm, that is line 2698 in current HEAD. Any interesting code you've added?

Anyway, defining all the properties in constructor (__init__) should help.

Is the order of the XML output variable, or does labview regenerate all the IDs everytime?

Yep, LabVIEW reorders things on each save. pylabview just exports everything in the order things are stored within VI. You can test that by extracting and then re-creating the VI. It should be identical.

Suicidal-Insanity commented 3 years ago

I only added some code to verify that the parse function wasnt being called, nothing interesting. And some hasattr checks, since I wasn't sure what defaults to use.

XML: Ok, so if I do end up using this as a way of keeping track of changes to the VI in version history, I would need to reorder the XML every time to some sort of consistent state? Or does reordering also involve changing IDs and so on?

mefistotelis commented 3 years ago

I would need to reorder the XML every time to some sort of consistent state? Or does reordering also involve changing IDs and so on?

Yep. Most items from sections (ie. Data types) are referenced by ID.