Skip to content

Wrong constant values #219

Closed
Closed

Description

@pierreluctg

Some ics constant are not correct exposed in the Python layer.

The following code is currently failing.

import ics

assert ics.SPY_STATUS2_ETHERNET_T1S_ETHERNET == 0x80000000
assert ics.SPY_STATUS2_LIN_NO_SLAVE_DATA == 0x80000000
assert ics.SPY_STATUS2_MOST_CHANGED_PAR == 0x80000000
assert ics.SPY_STATUS_EXTENDED == 0x80000000

assert ics.ETHERNET_SETTINGS10G_FLAG_COMM_IN_USE == 0x80000000

Header file in source

#define SPY_STATUS2_ETHERNET_T1S_ETHERNET 0x80000000

#define SPY_STATUS2_LIN_NO_SLAVE_DATA 0x80000000 // LIN no slave data

#define SPY_STATUS2_MOST_CHANGED_PAR 0x80000000 // first byte in ack reflects what changed.

#define SPY_STATUS_EXTENDED 0x80000000 // Extended - if this bit is set than decode StatusBitField3 in AckBytes

#define ETHERNET_SETTINGS10G_FLAG_COMM_IN_USE 0x80000000

Potential source of the issue

In my opinion this line is the source of this issue:

print("\tresult += PyModule_AddIntMacro(module, %s);" % sline[1], file=f)

This line could potentially change to

print('\tresult += PyModule_AddObjectRef(module, "{0}", PyLong_FromLongLong({0}));'.format(sline[1]), file=f)

Activity

  1. pierreluctg commented on Sep 23, 2025

    @pierreluctg
    ContributorAuthor
  2. drebbe-intrepid commented on Sep 23, 2025

    @drebbe-intrepid
    Collaborator

    @pierreluctg Thanks for the report, I'll take a look at this soon. Looks like the latest release on PyPI doesn't have this issue so its something related to the new header inclusion.

  3. pierreluctg commented on Sep 23, 2025

    @pierreluctg
    ContributorAuthor

    The issue is present in 920.14.2 (the latest on PyPi) at least on Windows Python 3.12 (python_ics-920.14.2-cp312-cp312-win_amd64.whl)

  4. pierreluctg commented on Sep 23, 2025

    @pierreluctg
    ContributorAuthor

    Looks like the issue could be limited to Windows.

    Issue is not reproducible using 920.14.2 on macOS. I have not tried on Linux.

  5. drebbe-intrepid commented on Sep 23, 2025

    @drebbe-intrepid
    Collaborator

    linux doesn't have the issue, this looks to be a windows only issue.

    >>> hex(ics.SPY_STATUS2_ETHERNET_T1S_ETHERNET)
    '-0x80000000'
    
  6. drebbe-intrepid commented on Sep 23, 2025

    @drebbe-intrepid
    Collaborator

    I believe your prosed fix is the correct way. I'll investigate and provide an update soon.

  7. drebbe-intrepid commented on Sep 24, 2025

    @drebbe-intrepid
    Collaborator

    @pierreluctg This should be fixed now, I'm just waiting for the builds to pass and do one final check since I'm updating the build system.

    I added pytest moving forward so we shouldn't regress on things like this:

    https://github.com/intrepidcs/python_ics/pull/220/files#diff-5ac325061663b1ccc52c165576955977a49145210ab74ee7b44fc9e887dd8700

  8. added a commit that references this issue on Sep 26, 2025
  9. drebbe-intrepid commented on Sep 26, 2025

    @drebbe-intrepid
    Collaborator

    @pierreluctg looks to be working in latest now. Will be uploaded to PyPI in a couple hours.

    ❯ python
    Python 3.14.0rc2 (main, Aug 18 2025, 19:17:50) [MSC v.1944 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import ics
    >>> hex(ics.ETHERNET_SETTINGS10G_FLAG_COMM_IN_USE)
    '0x80000000'
    
  10. pierreluctg commented on Sep 26, 2025

    @pierreluctg
    ContributorAuthor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions