5.1.60. J1939 parameter group transmit (pj1939_PgTransmit)

Construct the contents of a J1939 message, and attempt to transmit it.

5.1.60.1. Supported targets

All targets

5.1.60.2. Required license

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

5.1.60.3. Description

When a J1939 message is to be transmitted, the block packs each of the signal inports into the message, as specified by the block mask parameters, and transmits the message.

5.1.60.4. Inports

  • sim_error_flag

    Simulation value of the outport error_flag.

    Value type:Boolean
    Calibratable:No
  • sim_transport_errors

    Simulation value of the outport transport_errors.

    Value type:Integer
    Calibratable:No
  • priority

    The priority of the J1939 message to transmit.

    Range: [0, 7]

    Value type:Integer
    Calibratable:No

5.1.60.5. Outports

  • error_flag

    Set to 1 when there an a problem transmitting the message, set to zero otherwise.

    Value type:Boolean
    Calibratable:No
  • transport_errors

    Saturated count of transport errors (timeout or aborts) for this message.

    Range: [0, 255]

    Value type:Integer
    Calibratable:No

5.1.60.6. Mask parameters

  • J1939 Channel

    The logical J1939 channel on which to transmit. 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 transmit.

    Range: 0 or 1

    Value type:Integer
    Calibratable:No
  • PDU format

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

    Range: [0, 255]

    Value type:Integer
    Calibratable:No
  • PDU specific

    The pdu specific value of the PGN of the J1939 message to transmit. 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 transmit. Maximum size is the smaller of maximum range or buffer size.

    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
    ......
    17851427914278142771427614275142741427314272
    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 packing

    A vector of zero or one values, corresponding to each field. Fields for which this is set 1 are transmitted 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 message field inports.

    Range: 0 or 1

    Value type:String
    Calibratable:No

5.1.60.7. Notes

  • Unused fields in a J1939 message need not be specified in the Field start positions parameter (bits in unused fields are set to 1 for transmission).

  • If the block shows unnamed inports, or if the field inports 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. Given two parameters:

    MSLS
    Byte12
    Parameter 1 (hex)1011
    Parameter 2 (hex)2021

    the first parameter is packed into the J1939 message in LS byte format, starting at bit 0, is 16 bits wide and unsigned, and the second parameter is packed in MS byte format, starting at bit 32, and is also 16 bit wide and unsigned.

    MSLS
    Byte123456
    Message (hex)1110FFFF2021

    Parameter 1 has been packed using LS byte formatting. The LS byte of 0x1011 (0x11) has been packed into the LS byte of its position within the message (byte 1), and the MS byte of 0x1011 (0x10) has been packed into the MS byte of its position within the message (byte 2).

    Parameter 2 is packed using MS byte formatting. The LS byte of 0x2021 (0x21) has been packed into the MS byte of its position within the message (byte 6), and the MS byte of 0x2021 (0x20) has been packed into the MS byte of its position within the message (byte 5).

    Bytes 2 and 3 are not used and are therefore set with all bits at 1.