def can_comm(self):
     # type: () -> types.CanComm
     """:any:`nixnet.types.CanComm`: CAN Communication state"""
     state_value_ctypes = _ctypedefs.u32()
     state_size = ctypes.sizeof(state_value_ctypes)
     _funcs.nx_read_state(self._handle, constants.ReadState.CAN_COMM,
                          state_size, ctypes.pointer(state_value_ctypes))
     bitfield = state_value_ctypes.value
     return _utils.parse_can_comm_bitfield(bitfield)
 def state(self):
     # type: () -> constants.SessionInfoState
     """:any:`nixnet._enums.SessionInfoState`: Session running state."""
     state_value_ctypes = _ctypedefs.u32()
     state_size = ctypes.sizeof(state_value_ctypes)
     _funcs.nx_read_state(self._handle, constants.ReadState.SESSION_INFO,
                          state_size, ctypes.pointer(state_value_ctypes))
     state = state_value_ctypes.value
     return constants.SessionInfoState(state)
 def time_current(self):
     # type: () -> int
     """int: Current interface time."""
     state_value_ctypes = _ctypedefs.nxTimestamp_t()
     state_size = ctypes.sizeof(state_value_ctypes)
     _funcs.nx_read_state(self._handle, constants.ReadState.TIME_CURRENT,
                          state_size, ctypes.pointer(state_value_ctypes))
     time = state_value_ctypes.value
     return time
 def lin_comm(self):
     # type: () -> types.LinComm
     """:any:`nixnet.types.LinComm`: LIN Communication state"""
     state_value_ctypes = (_ctypedefs.u32 * 2)()  # type: ignore
     state_size = ctypes.sizeof(state_value_ctypes)
     _funcs.nx_read_state(self._handle, constants.ReadState.LIN_COMM,
                          state_size, ctypes.pointer(state_value_ctypes))
     first = state_value_ctypes[0].value
     second = state_value_ctypes[1].value
     return _utils.parse_lin_comm_bitfield(first, second)
 def time_start(self):
     # type: () -> int
     """int: Time the interface was started."""
     state_value_ctypes = _ctypedefs.nxTimestamp_t()
     state_size = ctypes.sizeof(state_value_ctypes)
     _funcs.nx_read_state(self._handle, constants.ReadState.TIME_START,
                          state_size, ctypes.pointer(state_value_ctypes))
     time = state_value_ctypes.value
     if time == 0:
         # The interface is not communicating.
         _errors.check_for_error(constants.Err.SESSION_NOT_STARTED.value)
     return time
예제 #6
0
    def time_communicating(self):
        # type: () -> int
        """int: Time the interface started communicating.

        The time is usually later than ``time_start`` because the interface
        must undergo a communication startup procedure.
        """
        state_value_ctypes = _ctypedefs.nxTimestamp_t()
        _funcs.nx_read_state(
            self._handle,
            constants.ReadState.TIME_COMMUNICATING,
            ctypes.pointer(state_value_ctypes))
        time = state_value_ctypes.value
        if time == 0:
            # The interface is not communicating.
            _errors.check_for_error(constants.Err.SESSION_NOT_STARTED.value)
        return time
예제 #7
0
    def check_fault(self):
        # type: () -> None
        """Check for an asynchronous fault.

        A fault is an error that occurs asynchronously to the NI-XNET
        application calls. The fault cause may be related to network
        communication, but it also can be related to XNET hardware, such as a
        fault in the onboard processor. Although faults are extremely rare,
        nxReadState provides a detection method distinct from the status of
        NI-XNET function calls, yet easy to use alongside the common practice
        of checking the communication state.
        """
        state_value_ctypes = _ctypedefs.u32()
        fault = _funcs.nx_read_state(
            self._handle,
            constants.ReadState.SESSION_INFO,
            ctypes.pointer(state_value_ctypes))
        _errors.check_for_error(fault)