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

B*x type fields are being misinterpreted #52

Open
JackNelson opened this issue Oct 19, 2022 · 1 comment
Open

B*x type fields are being misinterpreted #52

JackNelson opened this issue Oct 19, 2022 · 1 comment

Comments

@JackNelson
Copy link
Contributor

Tasks/Steps/Elements

The bits are being read in reverse

>>> [pow(2, 7-i) for i in range(8)]
[128, 64, 32, 16, 8, 4, 2, 1]

Should be assigned in ascending order rather than descending

>>> [pow(2, i) for i in range(8)]
[1, 2, 4, 8, 16, 32, 64, 128]

https://github.com/Semi-ATE/STDF/blob/main/Semi_ATE/STDF/STDR.py#L1673-L1677

Versions checklist

  • Spyder version: >= 5
  • JupyterLab = 3.4.2
  • Python version: 3.8.13
  • Qt version: all
  • PyQt version: 5.15.1
  • Operating System name/version:
    • server : Ubuntu 20.04 Linux
    • client : Linux
JackNelson pushed a commit to JackNelson/STDF that referenced this issue Oct 19, 2022
@seimit
Copy link
Collaborator

seimit commented Oct 19, 2022

Hi Jack,
Thank you for your contribution!
I would suggest you to keep the current implementation and to add your PR as an option in the STDF library.
Because I'm not the original author of the STDF library, I assume that initial implementation of the fixed
length bit-encoded data, follow the description of the variable length bit-encoded field (Bxn) - the first
data bit is located in the least significant bit of the char array, according the "Data Type Codes and Representation"
table in page 8 in the STDF v.4 spec file.
Example:
Let's data is stored in char array named vla (stands for variable length array) with 3 elements:

vla[0] 00000010 - value 2 for data length in bytes
vla[1] 0000000x - first data bit value x (First data item in least significant bit of the second byte of the
array)
vla[1] 000000x0 - second data bit
vla[1] x0000000 - eight data bit
vla[2] 0000000x - nine data bit
vla[2] 000000x0 - ten data bit
vla[2] x0000000 - sixteen data bit

Which translates in "The bits are being read in reverse" as you mention. The first read bit in the sequence
is the last bit stored in the first byte.

So my proposal is to add an option in the STDR class to support ascending order of bits for fixed length
bit-encoded data in order to support STDF files which are generated in such format. And to keep the
original implementation as the default one. In this case we will be still compatible with the old releases.

Let me know if you have arguments to implement the ascending order as default one.

Kind Regards,
Seimit

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

2 participants