Skip to content

Commit

Permalink
Merge 0d2d8c2 into efe3f4e
Browse files Browse the repository at this point in the history
  • Loading branch information
d-bohls committed Aug 20, 2018
2 parents efe3f4e + 0d2d8c2 commit 062dd2d
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 5 deletions.
23 changes: 19 additions & 4 deletions nixnet/_cconsts.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@
NX_ERR_FRAME_SIZE_MISMATCH = (NX_ERROR_BASE | 0x0AA)
NX_ERR_INDEX_TOO_BIG = (NX_ERROR_BASE | 0x0AB)
NX_ERR_SESSION_MODE_INCOMPATIBILITY = (NX_ERROR_BASE | 0x0AC)
NX_ERR_SESSION_TYPE_FRAME_INCOMPATIBILITY = (NX_ERROR_BASE | 0x15D)
NX_ERR_TRIGGER_SIGNAL_NOT_ALLOWED = (NX_ERROR_BASE | 0x0AD)
NX_ERR_ONLY_ONE_CLUSTER = (NX_ERROR_BASE | 0x0AE)
NX_ERR_CONVERT_INVALID_PAYLOAD = (NX_ERROR_BASE | 0x0AF)
Expand All @@ -119,6 +118,8 @@
NX_ERR_BAD_IMAGE_FILE = (NX_ERROR_BASE | 0x0B7)
NX_ERR_INVALID_LOGFILE = (NX_ERROR_BASE | 0x0B8)
NX_ERR_DONGLE_COMMUNICATION_LOST = (NX_ERROR_BASE | 0xB9)
NX_ERR_LOW_LEVEL_COMMUNICATION_TIMEOUT = (NX_ERROR_BASE | 0xBA)
NX_ERR_CDAQ_TRANSFER_ABORTED = (NX_ERROR_BASE | 0xBB)
NX_ERR_INVALID_PROPERTY_VALUE = (NX_ERROR_BASE | 0x0C0)
NX_ERR_FLEX_RAY_INTEGRATION_FAILED = (NX_ERROR_BASE | 0x0C1)
NX_ERR_PDU_NOT_FOUND = (NX_ERROR_BASE | 0x0D0)
Expand Down Expand Up @@ -178,17 +179,18 @@
NX_ERR_AMBIGUOUS_SUBFRAME_NAME = (NX_ERROR_BASE | 0x157)
NX_ERR_AMBIGUOUS_SCHEDULE_NAME = (NX_ERROR_BASE | 0x158)
NX_ERR_DUPLICATE_SCHEDULE_NAME = (NX_ERROR_BASE | 0x159)
NX_ERR_DIAGNOSTIC_SCHEDULE_NOT_DEFINED = (NX_ERROR_BASE | 0x18F)
NX_ERR_PROTOCOL_MUX_NOT_SUPPORTED = (NX_ERROR_BASE | 0x15A)
NX_ERR_SAVE_LI_NNOT_SUPPORTED = (NX_ERROR_BASE | 0x15B)
NX_ERR_LI_NMASTER_NOT_DEFINED = (NX_ERROR_BASE | 0x15C)
NX_ERR_SESSION_TYPE_FRAME_INCOMPATIBILITY = (NX_ERROR_BASE | 0x15D)
NX_ERR_MIX_AUTO_MANUAL_OPEN = (NX_ERROR_BASE | 0x15E)
NX_ERR_AUTO_OPEN_NOT_SUPPORTED = (NX_ERROR_BASE | 0x15F)
NX_ERR_WRONG_NUM_SIGNALS_WRITTEN = (NX_ERROR_BASE | 0x160)
NX_ERR_MULTIPLE_LV_PROJECT = (NX_ERROR_BASE | 0x161)
NX_ERR_SESSION_CONFLICT_LV_PROJECT = (NX_ERROR_BASE | 0x162)
NX_ERR_DB_OBJECT_NAME_EMPTY = (NX_ERROR_BASE | 0x163)
NX_ERR_MISSING_ALIAS_IN_DB_OBJECT_NAME = (NX_ERROR_BASE | 0x164)
NX_ERR_DATABASE_IMPORT_VERSION = (NX_ERROR_BASE | 0x165)
NX_ERR_FIBEX_IMPORT_VERSION = (NX_ERROR_BASE | 0x165)
NX_ERR_EMPTY_SESSION_NAME = (NX_ERROR_BASE | 0x166)
NX_ERR_NOT_ENOUGH_MESSAGE_RAM_FOR_OBJECT = (NX_ERROR_BASE | 0x167)
Expand Down Expand Up @@ -227,6 +229,7 @@
NX_ERR_ADD_ROUTE = (NX_ERROR_BASE | 0x18C)
NX_ERR_REMOTE_SLEEP_ON_LIN_SLAVE = (NX_ERROR_BASE | 0x18D)
NX_ERR_SLEEP_WAKEUP_NOT_SUPPORTED = (NX_ERROR_BASE | 0x18E)
NX_ERR_DIAGNOSTIC_SCHEDULE_NOT_DEFINED = (NX_ERROR_BASE | 0x18F)
NX_ERR_LIN_TRANSPORT_LAYER = (NX_ERROR_BASE | 0x192)
NX_ERR_LOGFILE = (NX_ERROR_BASE | 0x193)
NX_ERR_STRM_OUT_TMG_LIN_SCHEDULER_CONFLICT = (NX_ERROR_BASE | 0x200)
Expand Down Expand Up @@ -280,8 +283,17 @@
NX_ERR_INV_UNCONDITIONAL_ENTRY = (NX_ERROR_BASE | 0x022F)
NX_ERR_EVENT_ENTRY_NO_SCHEDULE = (NX_ERROR_BASE | 0x0230)
NX_ERR_UNSUPPORTED_USB_SPEED = (NX_ERROR_BASE | 0x0231)

NX_WARN_FD_BAUD_EXCEEDS_CAPABILITY = (NX_WARNING_BASE | 0x40)
NX_ERR_EVENT_UNEQUAL_PAYLOAD_LENGTH = (NX_ERROR_BASE | 0x0232)
NX_ERR_EVENT_UNEQUAL_CHECKSUM_TYPE = (NX_ERROR_BASE | 0x0233)
NX_ERR_CRIO_BAD_DRIVER_VERSIONS = (NX_ERROR_BASE | 0x0234)
NX_ERR_CRIO_MISSING_SLOT_SUPPORT = (NX_ERROR_BASE | 0x0235)
NX_ERR_INTF_ALREADY_IN_USE_BY_NI_XNET = (NX_ERROR_BASE | 0x0236)
NX_ERR_INTF_ALREADY_IN_USE_BY_NI_XCL = (NX_ERROR_BASE | 0x0237)
NX_ERR_BYTE_ARRAY_NOT_ALLOWED = (NX_ERROR_BASE | 0x0238)
NX_ERR_NO_BYTE_ARRAY_MIX = (NX_ERROR_BASE | 0x0239)
NX_ERR_ONLY_ONE_BYTE_ARRAY = (NX_ERROR_BASE | 0x023A)

NX_WARN_FD_BAUD_EXCEEDS_CAPABILITY = (NX_WARNING_BASE | 0x040)
NX_WARN_DATABASE_IMPORT = (NX_WARNING_BASE | 0x085)
NX_WARN_DATABASE_IMPORT_FIBEX_NO_XNET_FILE = (NX_WARNING_BASE | 0x086)
NX_WARN_DATABASE_IMPORT_FIBEX_NO_XNET_FILE_PLUS_WARNING = (NX_WARNING_BASE | 0x087)
Expand Down Expand Up @@ -400,6 +412,7 @@
NX_PROP_SESSION_INTF_LIN_ALW_START_WO_BUS_PWR = (0x00000078 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_LINO_STR_SLV_RSP_LST_BY_NAD = (0x00000079 | NX_CLASS_SESSION | NX_PRPTYPE_1_DU32)
NX_PROP_SESSION_INTF_LIN_NO_RESPONSE_TO_IN_STRM = (0x00000080 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_LIN_CHECKSUM_TO_IN_STRM = (0x00000081 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_SRC_TERM_START_TRIGGER = (0x00000090 | NX_CLASS_SESSION | NX_PRPTYPE_STRING)
NX_PROP_SESSION_J1939_ADDRESS = (0x00000092 | NX_CLASS_SESSION | NX_PRPTYPE_U32)
NX_PROP_SESSION_J1939_NAME = (0x00000094 | NX_CLASS_SESSION | NX_PRPTYPE_U64)
Expand All @@ -417,6 +430,7 @@
NX_PROP_SESSION_J1939_FILL_BYTE = (0x0000009F | NX_CLASS_SESSION | NX_PRPTYPE_U32)
NX_PROP_SESSION_J1939_WRITE_QUEUE_SIZE = (0x000000A0 | NX_CLASS_SESSION | NX_PRPTYPE_U32)
NX_PROP_SESSION_J1939_ECU_BUSY = (0x000000A1 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_J1939_INCLUDE_DEST_ADDR_IN_PGN = (0x000000A5 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_CAN_EDGE_FILTER = (0x000000A2 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_CAN_TRANSMIT_PAUSE = (0x000000A3 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
NX_PROP_SESSION_INTF_CAN_DISABLE_PROT_EXCEPTION_HANDLING = (0x000000A4 | NX_CLASS_SESSION | NX_PRPTYPE_BOOL)
Expand Down Expand Up @@ -789,6 +803,7 @@
NX_DEV_FORM_C_SERIES = 2
NX_DEV_FORM_PXIE = 3
NX_DEV_FORM_USB = 4
NX_DEV_FORM_PCIE = 5

NX_CAN_TERM_CAP_NO = 0
NX_CAN_TERM_CAP_YES = 1
Expand Down
12 changes: 11 additions & 1 deletion nixnet/_enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -1674,12 +1674,22 @@ class Phase(enum.Enum):


class DevForm(enum.Enum):
'''Device physical form factor.'''
'''Device physical form factor.
Values:
PXI
PCI
C_SERIES
PXIE
USB
PCIE
'''
PXI = _cconsts.NX_DEV_FORM_PXI
PCI = _cconsts.NX_DEV_FORM_PCI
C_SERIES = _cconsts.NX_DEV_FORM_C_SERIES
PXIE = _cconsts.NX_DEV_FORM_PXIE
USB = _cconsts.NX_DEV_FORM_USB
PCIE = _cconsts.NX_DEV_FORM_PCIE


class CanTermCap(enum.Enum):
Expand Down
44 changes: 44 additions & 0 deletions nixnet/_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,28 @@ def set_session_intf_lin_no_response_to_in_strm(
)


def get_session_intf_lin_checksum_to_in_strm(
ref, # type: int
):
# type: (...) -> bool
return _cprops.get_session_bool(
ref,
_cconsts.NX_PROP_SESSION_INTF_LIN_CHECKSUM_TO_IN_STRM,
)


def set_session_intf_lin_checksum_to_in_strm(
ref, # type: int
value, # type: bool
):
# type: (...) -> None
_cprops.set_session_bool(
ref,
_cconsts.NX_PROP_SESSION_INTF_LIN_CHECKSUM_TO_IN_STRM,
value,
)


def get_session_intf_src_term_start_trigger(
ref, # type: int
):
Expand Down Expand Up @@ -1858,6 +1880,28 @@ def set_session_j1939_ecu_busy(
)


def get_session_j1939_include_dest_addr_in_pgn(
ref, # type: int
):
# type: (...) -> bool
return _cprops.get_session_bool(
ref,
_cconsts.NX_PROP_SESSION_J1939_INCLUDE_DEST_ADDR_IN_PGN,
)


def set_session_j1939_include_dest_addr_in_pgn(
ref, # type: int
value, # type: bool
):
# type: (...) -> None
_cprops.set_session_bool(
ref,
_cconsts.NX_PROP_SESSION_J1939_INCLUDE_DEST_ADDR_IN_PGN,
value,
)


def get_session_intf_can_edge_filter(
ref, # type: int
):
Expand Down
15 changes: 15 additions & 0 deletions nixnet/_session/intf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,21 @@ def lin_no_response_to_in_strm(self, value):
# type: (bool) -> None
_props.set_session_intf_lin_no_response_to_in_strm(self._handle, value)

@property
def lin_checksum_to_in_strm(self):
# type: () -> bool
"""bool: LIN Checksum to Input Stream?
Configure the hardware to place the received checksum for each LIN Data frame into the Event ID (Info) field.
When ``False``, the Event ID field contains ``0`` for all LIN Data stream input frames.
"""
return _props.get_session_intf_lin_checksum_to_in_strm(self._handle)

@lin_checksum_to_in_strm.setter
def lin_checksum_to_in_strm(self, value):
# type: (bool) -> None
_props.set_session_intf_lin_checksum_to_in_strm(self._handle, value)

@property
def src_term_start_trigger(self):
# type: () -> typing.Text
Expand Down
31 changes: 31 additions & 0 deletions nixnet/_session/j1939.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,34 @@ def ecu_busy(self):
@ecu_busy.setter
def ecu_busy(self, value):
_props.set_session_j1939_ecu_busy(self._handle, value)

@property
def include_dest_addr_in_pgn(self):
# type: () -> bool
"""bool: SAE J1939 Include Destination Address in PGN
Incoming J1939 frames are matched to an XNET database by the Parameter Group Number (PGN) of the frame.
When receiving PDU1 frames,
the destination address of the frame (J1939 PS field) is ignored when calculating the PGN,
in accordance to the J1939 specification.
This causes an XNET session to receive all frames that share the same PGN,
making it difficult to distinguish destinations for traffic.
When set to ``True``,
this property instructs NI-XNET to include the destination address when extracting the PGN from the frame.
This allows the same PGN sent to different destination addresses to be handled by separate input sessions.
This property may be set at any time.
When set after session start,
it will not affect frames already received.
This property is valid only for input sessions.
It is not valid for stream sessions.
This property affects all frames in a session.
"""
return _props.get_session_j1939_include_dest_addr_in_pgn(self._handle)

@include_dest_addr_in_pgn.setter
def include_dest_addr_in_pgn(self, value):
# type: (bool) -> None
_props.set_session_j1939_include_dest_addr_in_pgn(self._handle, value)
21 changes: 21 additions & 0 deletions tests/test_j1939.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import mock # type: ignore

from nixnet import _cfuncs
from nixnet import _ctypedefs

from nixnet._session import j1939


MockXnetLibrary = mock.create_autospec(_cfuncs.XnetLibrary, spec_set=True, instance=True)
MockXnetLibrary.nx_get_property.return_value = _ctypedefs.u32(0)
MockXnetLibrary.nx_set_property.return_value = _ctypedefs.u32(0)


@mock.patch('nixnet._cfuncs.lib', MockXnetLibrary)
def test_j1939_properties():
# This test should be expanded to cover more J1939 properties.
j1939.J1939.include_dest_addr_in_pgn = j1939.J1939.include_dest_addr_in_pgn
15 changes: 15 additions & 0 deletions tests/test_session_intf.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,27 @@
from __future__ import print_function
from __future__ import unicode_literals

import mock # type: ignore
import pytest # type: ignore

import nixnet
from nixnet import _cfuncs
from nixnet import _ctypedefs
from nixnet import constants
from nixnet import errors

from nixnet._session import intf

MockXnetLibrary = mock.create_autospec(_cfuncs.XnetLibrary, spec_set=True, instance=True)
MockXnetLibrary.nx_get_property.return_value = _ctypedefs.u32(0)
MockXnetLibrary.nx_set_property.return_value = _ctypedefs.u32(0)


@mock.patch('nixnet._cfuncs.lib', MockXnetLibrary)
def test_intf_properties():
# This test should be expanded to cover more session interface properties.
intf.Interface.lin_checksum_to_in_strm = intf.Interface.lin_checksum_to_in_strm


@pytest.mark.integration
def test_intf_container(can_in_interface):
Expand Down

0 comments on commit 062dd2d

Please sign in to comment.