nixnet.types

class nixnet.types.DriverVersion[source]

Bases: nixnet.types.DriverVersion_

Driver Version

The arguments align with the following fields: [major].[minor].[update][phase][build].

major
Type:int
minor
Type:int
update
Type:int
phase
Type:nixnet._enums.Phase
build
Type:int
class nixnet.types.CanComm[source]

Bases: nixnet.types.CanComm_

CAN Communication State.

state

Communication State

Type:nixnet._enums.CanCommState
tcvr_err

Transceiver Error. Transceiver error indicates whether an error condition exists on the physical transceiver. This is typically referred to as the transceiver chip NERR pin. False indicates normal operation (no error), and true indicates an error.

Type:bool
sleep

Sleep. Sleep indicates whether the transceiver and communication controller are in their sleep state. False indicates normal operation (awake), and true indicates sleep.

Type:bool
last_err

Last Error. Last error specifies the status of the last attempt to receive or transmit a frame

Type:nixnet._enums.CanLastErr
tx_err_count

Transmit Error Counter. The transmit error counter begins at 0 when communication starts on the CAN interface. The counter increments when an error is detected for a transmitted frame and decrements when a frame transmits successfully. The counter increases more for an error than it is decreased for success. This ensures that the counter generally increases when a certain ratio of frames (roughly 1/8) encounter errors. When communication state transitions to Bus Off, the transmit error counter no longer is valid.

Type:int
rx_err_count

Receive Error Counter. The receive error counter begins at 0 when communication starts on the CAN interface. The counter increments when an error is detected for a received frame and decrements when a frame is received successfully. The counter increases more for an error than it is decreased for success. This ensures that the counter generally increases when a certain ratio of frames (roughly 1/8) encounter errors.

Type:int
class nixnet.types.LinComm[source]

Bases: nixnet.types.LinComm_

CAN Communication State.

sleep

Sleep. Indicates whether the transceiver and communication controller are in their sleep state. False indicates normal operation (awake), and true indicates sleep.

Type:bool
state

Communication State

Type:nixnet._enums.LinCommState
last_err

Last Error. Last error specifies the status of the last attempt to receive or transmit a frame

Type:nixnet._enums.LinLastErr
err_received

Returns the value received from the network when last error occurred.

When last_err is READBACK, this is the value read back.

When last_err is CHECKSUM, this is the received checksum.

Type:int
err_expected

Returns the value that the LIN interface expected to see (instead of last received).

When last_err is READBACK, this is the value transmitted.

When last_err is CHECKSUM, this is the calculated checksum.

Type:int
err_id

Returns the frame identifier in which the last error occurred.

This is not applicable when last_err is NONE or UNKNOWN_ID.

Type:int
tcvr_rdy

Indicates whether the LIN transceiver is powered from the bus.

True indicates the bus power exists, so it is safe to start communication on the LIN interface.

If this value is false, you cannot start communication successfully. Wire power to the LIN transceiver and run your application again.

Type:bool
sched_index

Indicates the LIN schedule that the interface currently is running.

This index refers to a LIN schedule that you requested using the nixnet._session.base.SessionBase.change_lin_schedule function. It indexes the array of schedules represented in the nixnet._session.intf.Interface.lin_sched_names.

This index applies only when the LIN interface is running as a master. If the LIN interface is running as a slave only, this element should be ignored.

Type:int
class nixnet.types.CanIdentifier(identifier, extended=False)[source]

Bases: object

CAN frame arbitration identifier.

identifier

CAN frame arbitration identifier

Type:int
extended

If the identifier is extended

Type:bool
classmethod from_raw(raw)[source]

Parse a raw frame identifier into a CanIdentifier

Parameters:raw (int) – A raw frame identifier
Returns:parsed value
Return type:CanIdentifier
>>> CanIdentifier.from_raw(0x1)
CanIdentifier(0x1)
>>> CanIdentifier.from_raw(0x20000001)
CanIdentifier(0x1, extended=True)
class nixnet.types.FrameFactory[source]

Bases: object

ABC for creating nixnet.types.Frame objects.

classmethod from_raw(frame)[source]

Convert from RawFrame.

class nixnet.types.Frame[source]

Bases: nixnet.types.FrameFactory

ABC for frame objects.

to_raw()[source]

Convert to RawFrame.

type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.RawFrame(timestamp, identifier, type, flags=0, info=0, payload=b'')[source]

Bases: nixnet.types.Frame

Raw Frame.

timestamp

Absolute time the XNET interface received the end-of-frame.

Type:int
identifier

Frame identifier.

Type:int
type

Frame type.

Type:nixnet._enums.FrameType
flags

Flags that qualify the type.

Type:int
info

Info that qualify the type.

Type:int
payload

Payload.

Type:bytes
classmethod from_raw(frame)[source]

Convert from RawFrame.

to_raw()[source]

Convert to RawFrame.

type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.CanFrame(identifier, type=<FrameType.CAN_DATA: 0>, payload=b'')[source]

Bases: nixnet.types.Frame

CAN Frame.

identifier

CAN frame arbitration identifier.

Type:nixnet.types.CanIdentifier
echo

If the frame is an echo of a successful transmit rather than being received from the network.

Type:bool
type

Frame type.

Type:nixnet._enums.FrameType
timestamp

Absolute time the XNET interface received the end-of-frame.

Type:int
payload

Payload.

Type:bytes
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(5, 0x20000001, constants.FrameType.CAN_DATA, _cconsts.NX_FRAME_FLAGS_TRANSMIT_ECHO, 0, b'')
>>> CanFrame.from_raw(raw)
CanFrame(CanIdentifier(0x1, extended=True), echo=True, timestamp=0x5)
to_raw()[source]

Convert to RawFrame.

>>> CanFrame(CanIdentifier(1, True), constants.FrameType.CAN_DATA).to_raw()
RawFrame(timestamp=0x0, identifier=0x20000001, type=FrameType.CAN_DATA)
>>> c = CanFrame(CanIdentifier(1, True), constants.FrameType.CAN_DATA)
>>> c.echo = True
>>> c.to_raw()
RawFrame(timestamp=0x0, identifier=0x20000001, type=FrameType.CAN_DATA, flags=0x80)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.CanBusErrorFrame(timestamp, state, tcvr_err, bus_err, tx_err_count, rx_err_count)[source]

Bases: nixnet.types.Frame

Error detected on hardware bus of a nixnet.session.FrameInStreamSession.

See also nixnet.types.CanComm.

timestamp

Absolute time when the bus error occurred.

Type:int
state

Communication State

Type:nixnet._enums.CanCommState
tcvr_err

Transceiver Error.

Type:bool
bus_err

Last Error.

Type:nixnet._enums.CanLastErr
tx_err_count

Transmit Error Counter.

Type:int
rx_err_count

Receive Error Counter.

Type:int
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(0x64, 0x0, constants.FrameType.CAN_BUS_ERROR, 0, 0, b'\x00\x01\x02\x03\x04')
>>> CanBusErrorFrame.from_raw(raw)
CanBusErrorFrame(0x64, CanCommState.ERROR_ACTIVE, True, CanLastErr.ACK, 1, 2)
to_raw()[source]

Convert to RawFrame.

>>> CanBusErrorFrame(100, constants.CanCommState.BUS_OFF, True, constants.CanLastErr.STUFF, 1, 2).to_raw()
RawFrame(timestamp=0x64, identifier=0x0, type=FrameType.CAN_BUS_ERROR, len(payload)=5)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.LinFrame(identifier, type=<FrameType.LIN_DATA: 64>, payload=b'')[source]

Bases: object

LIN Frame.

identifier

LIN frame arbitration identifier.

Type:int
echo

If the frame is an echo of a successful transmit rather than being received from the network.

Type:bool
type

Frame type.

Type:nixnet._enums.FrameType
timestamp

Absolute time the XNET interface received the end-of-frame.

Type:int
eventslot

Whether the frame was received within an event-triggered slot or an unconditional or sporadic slot.

Type:bool
eventid

Identifier for an event-triggered slot.

Type:int
payload

A byte string representing the payload.

Type:bytes
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(5, 2, constants.FrameType.LIN_DATA, 0x81, 1, b'')
>>> LinFrame.from_raw(raw)
LinFrame(identifier=0x2, echo=True, timestamp=0x5, eventslot=True, eventid=1, len(payload)=1)
>>> raw = RawFrame(5, 2, constants.FrameType.LIN_DATA, _cconsts.NX_FRAME_FLAGS_TRANSMIT_ECHO, 0, b'')
>>> LinFrame.from_raw(raw)
LinFrame(identifier=0x2, echo=True, timestamp=0x5, len(payload)=1)
to_raw()[source]

Convert to RawFrame.

>>> LinFrame(2, constants.FrameType.LIN_DATA).to_raw()
RawFrame(timestamp=0x0, identifier=0x2, type=FrameType.LIN_DATA)
>>> l = LinFrame(2, constants.FrameType.LIN_DATA)
>>> l.echo = True
>>> l.eventslot = True
>>> l.eventid = 1
>>> l.to_raw()
RawFrame(timestamp=0x0, identifier=0x2, type=FrameType.LIN_DATA, flags=0x81, info=0x1)
class nixnet.types.LinBusErrorFrame(timestamp, state, bus_err, err_id, err_received, err_expected)[source]

Bases: nixnet.types.Frame

Error detected on hardware bus of a nixnet.session.FrameInStreamSession.

See also nixnet.types.LinComm.

timestamp

Absolute time when the bus error occurred.

Type:int
state

Communication State.

Type:nixnet._enums.LinCommState
bus_err

Last Error.

Type:nixnet._enums.LinLastErr
err_id

Identifier on bus.

Type:int
err_received

Received byte on bus

Type:int
err_expected

Expected byte on bus

Type:int
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(0x64, 0x0, constants.FrameType.LIN_BUS_ERROR, 0, 0, b'\x00\x01\x02\x03\x04')
>>> LinBusErrorFrame.from_raw(raw)
LinBusErrorFrame(0x64, LinCommState.IDLE, LinLastErr.UNKNOWN_ID, 0x2, 3, 4)
to_raw()[source]

Convert to RawFrame.

>>> LinBusErrorFrame(100, constants.LinCommState.INACTIVE, constants.LinLastErr.UNKNOWN_ID, 2, 3, 4).to_raw()
RawFrame(timestamp=0x64, identifier=0x0, type=FrameType.LIN_BUS_ERROR, len(payload)=5)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.DelayFrame(offset)[source]

Bases: nixnet.types.Frame

Delay hardware when DelayFrame is outputted.

Note

This requires nixnet._session.intf.Interface.out_strm_timng to be in replay mode.

offset

Time to delay in milliseconds.

Type:int
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(5, 0, constants.FrameType.SPECIAL_DELAY, 0, 0, b'')
>>> DelayFrame.from_raw(raw)
DelayFrame(5)
to_raw()[source]

Convert to RawFrame.

>>> DelayFrame(250).to_raw()
RawFrame(timestamp=0xfa, identifier=0x0, type=FrameType.SPECIAL_DELAY)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.LogTriggerFrame(timestamp)[source]

Bases: nixnet.types.Frame

Timestamp of when a trigger occurred.

This frame is generated on input sessions when a rising edge is detected on an external connection.

Note

This requires using nixnet._session.base.SessionBase.connect_terminals to connect an external connection to the internal LogTrigger terminal.

timestamp

Absolute time that the trigger occurred.

Type:int
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(5, 0, constants.FrameType.SPECIAL_LOG_TRIGGER, 0, 0, b'')
>>> LogTriggerFrame.from_raw(raw)
LogTriggerFrame(0x5)
to_raw()[source]

Convert to RawFrame.

>>> LogTriggerFrame(250).to_raw()
RawFrame(timestamp=0xfa, identifier=0x0, type=FrameType.SPECIAL_LOG_TRIGGER)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.StartTriggerFrame(timestamp)[source]

Bases: nixnet.types.Frame

Timestamp of nixnet.session.FrameInStreamSession start.

timestamp

Absolute time that the trigger occurred.

Type:int
classmethod from_raw(frame)[source]

Convert from RawFrame.

>>> raw = RawFrame(5, 0, constants.FrameType.SPECIAL_START_TRIGGER, 0, 0, b'')
>>> StartTriggerFrame.from_raw(raw)
StartTriggerFrame(0x5)
to_raw()[source]

Convert to RawFrame.

>>> StartTriggerFrame(250).to_raw()
RawFrame(timestamp=0xfa, identifier=0x0, type=FrameType.SPECIAL_START_TRIGGER)
type

Frame format.

Type:nixnet._enums.FrameType
class nixnet.types.XnetFrame[source]

Bases: nixnet.types.FrameFactory

Create Frame based on RawFrame content.

classmethod from_raw(frame)[source]

Convert from RawFrame.

class nixnet.types.PduProperties[source]

Bases: nixnet.types.PDU_PROPERTIES_

Properties that map a PDU onto a frame.

Mapping PDUs to a frame requires setting three frame properties that are combined into this tuple.

pdu

Defines the sequence of values for the other two properties.

Type:Pdu
start_bit

Defines the start bit of the PDU inside the frame.

Type:int
update_bit

Defines the update bit for the PDU inside the frame. If the update bit is not used, set the value to -1.

Type:int