5.1.58. J1939 parameter group receive message (pj1939_PgReceive)

Extract the data contents from a received J1939 message.

5.1.58.1. Supported targets

All targets

5.1.58.2. Required license

None (Main library). (See Section 2.3, “Licensed Features”.)

5.1.58.3. Description

When a matching J1939 message to this block is received, the block unpacks the message contents into individual signals, as specified by the block mask parameters, and provides them as outports.

Warning

The PCX feature takes precedence over the PJ1939 feature. If you configure the PCX feature to receive a J1939 frame, the PJ1939 feature will not see the frame, and it will not be processed by the platform. This especially causes problems when receiving J1939 DM14 'Boot Load' commands.

5.1.58.4. Inports

  • sim_error_flag

    Simulation value for the outport error_flag.

    Value type:Boolean
    Calibratable:No
  • sim_rx_trig_flag

    Simulation value for the outport rx_trig_flag.

    Value type:Boolean
    Calibratable:No
  • sim_overrun_flag

    Simulation value for the outport overrun_flag.

    Value type:Boolean
    Calibratable:No
  • sim_source_addr

    Simulation value for the outport source_addr.

    Value type:Integer
    Calibratable:No
  • sim_dest_addr

    Simulation value for the outport dest_addr.

    Value type:Integer
    Calibratable:No
  • sim_timestamp

    The simulation value for the outport timestamp. Available only if the mask parameter Provide timestamp is selected.

    Value type:Integer
  • sim_fields

    A set of simulation inports for the corresponding outports fields. Available if there is at least one field and the parameter Provide simulation input? is selected.

    Value type:Integer
    Calibratable:No

5.1.58.5. Outports

  • error_flag

    Set to 1 if some error has occurred which prevents CAN reception, or 0 otherwise. Errors which prevent reception are: CAN bus detected as bus-off, or the length of the received J1939 message does not match the Message length parameter.

    Range: 0 or 1

    Value type:Boolean
    Calibratable:No
  • rx_trig_flag

    Set to 1 if the block has detected reception of the J1939 message since the last iteration of this block, set to zero otherwise.

    Range: 0 or 1

    Value type:Boolean
    Calibratable:No
  • overrun_flag

    Set to 1 if the block has detected reception of the same J1939 message more than once between iterations of this block.

    Range: 0 or 1

    Value type:Boolean
    Calibratable:No
  • source_addr

    The source J1939 network address of the message.

    Range: [0, 253] or 255

    Value type:Integer
    Calibratable:No
  • dest_addr

    The destination J1939 network address of the message.

    Range: [0, 253] or 255

    Value type:Integer
    Calibratable:No
  • timestamp

    The time when the last valid message was received. Strictly this gives the time when the message was assembled from the possibly multiple CAN packets, and has a resolution of 50 ms. The timestamp is a free-running microsecond timer that wraps to zero approximately every 70 minutes. Available only if the mask parameter Provide timestamp is selected.

    Range: [0, 4294967295] us

    Value type:Integer
  • fields

    An outport for each field specified in the block.

    Value type:Real
    Calibratable:No

5.1.58.6. Mask parameters

  • J1939 Channel

    The logical J1939 channel on which the message will arrive. Must be a channel declared with a pj1939_ChannelConfiguration block.

    Value type:Integer
    Calibratable:No
  • PDU datapage

    The pdu datapage value of the PGN of the J1939 message to receive.

    Range: 0 or 1

    Value type:Integer
    Calibratable:No
  • PDU format

    The pdu format value of the PGN of the J1939 message to receive.

    Range: [0, 255]

    Value type:Integer
    Calibratable:No
  • PDU specific

    The pdu specific value of the PGN of the J1939 message to receive. If the PDU format parameter is less than 240, then this parameter is not available for editing and does not form part of the PGN.

    Range: [0, 255]

    Value type:Integer
    Calibratable:No
  • Message length

    The length of the data bytes in the message to be received.

    Range: [0, 1785]

    Value type:Integer
    Calibratable:No
  • Field start positions

    A vector of bit numbers indicating the start position of each field in the CAN message.

    Field start positions correspond to the message data bytes as follows:

    Data byteBit number
    LSMS      LS
    187654321
    2161514131211109
    ......
    17851428014279142781427714276142751427414273
    MSMS      LS

    where byte 1 corresponds to the first received data byte in the first CAN message for the J1939 message. This numbering scheme matches the J1939 specification but differs from the existing CAN blocks. Although this may cause some confusion when both blocks are used in the same model, it will help reduce mistakes when using the J1939 blockset with the J1939 specification of message contents.

    Value type:Integer
    Calibratable:No
  • Field widths

    A vector of bit lengths indicating the number of bits allocated to each field.

    Range: [1, 32] bits

    A field which starts at bit 5 and has 10 bits of width is identified as follows:

    Data byteBit number
    18765----
    2--14131211109

    Value type:Integer
    Calibratable:No
  • Field signs

    A vector of zero or one values, corresponding to each field. Fields for which this is set 1 are received as twos-complement signed numbers, or unsigned numbers otherwise.

    Range: 0 or 1

    Value type:Integer
    Calibratable:No
  • Field packing

    A vector of zero or one values, corresponding to each field. Fields for which this is set 1 are received as MS packing, or LS packing otherwise.

    Range: 0 or 1

    J1939 message fields are generally packed LS byte first, so the field which starts at bit 5 and has 10 bits of width, would be interpreted as:

    MSLS
    Data byte 2Data byte 1
    ------141312111098765
    ssssssxxxxxxxxxx

    where 'x' is the corresponding bit taken from the J1939 message data bytes, and 's' is the sign extension of the data. In this case, bit 14 may be considered the sign bit, if the data in the J1939 message data is signed.

    However, if the J1939 message field was packed MS byte first, the bits would be interpreted as:

    MSLS
    Data byte 1Data byte 2
    ------651413121110987
    ssssssxxxxxxxxxx

    where 'x' is the corresponding bit taken from the J1939 message data bytes, and 's' is the sign extension of the data. In this case, bit 6 may be considered the sign bit, if the data in the J1939 message data is signed.

    Value type:Integer
    Calibratable:No
  • Field mnemonics

    A string containing a comma-separated list of names with which to label the simulation field inports and message field outports.

    Range: 0 or 1

    Value type:String
    Calibratable:No
  • Provide simulation input?

    If selected then create simulation inports (sim_fields) for each of the outport message signals (fields).

    Value type:Boolean
    Calibratable:No
  • Provide timestamp

    If selected then inport sim_timestamp and outport timestamp are made available.

    Value type:Boolean
    Calibratable:No
  • Sample time

    The periodicity of the block execution.

    Range: [0.001, 3600] seconds

    Value type:Real
    Calibratable:No

5.1.58.7. Notes

  • Unused fields in a J1939 message need not be specified in the Field start positions parameter.

  • If the block shows unnamed outports, or if the field outports are not shown, it is likely that one or more of the block's parameter fields is incorrect. Check the parameter fields for mistakes and correct them.

  • The following example illustrates the least significant (LS) and most significant (MS) byte ordering in J1939 messages. The message is received as follows:

    MSLS
    Byte123456
    Message (hex)1110FFFF2021

    where the first parameter is in LS byte format, starts at bit 0, is 16 bits wide and unsigned, and the second parameter is in MS byte format, starts at bit 32, and is also 16 bit wide and unsigned.

    Parameter 1 is unpacked using LS byte formatting giving 0x1011. The LS byte is unpacked from the LS byte of its position within the message (byte 1) giving 0x11, and the MS byte is unpacked from the MS byte of its position within the message (byte 2) giving 0x10.

    Parameter 2 is unpacked using MS byte formatting giving 0x2021. The LS byte is unpacked from the MS byte of its position within the message (byte 6) giving 0x21, and the MS byte is unpacked from the MS byte of its position within the message (byte 5) giving 0x20.