5.1.15. CAN transmit message (pcx_CANTransmitMessage)

Pack a CAN message with data then transmit it.

5.1.15.1. Supported targets

All targets

5.1.15.2. Required license

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

5.1.15.3. Description

When a 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.

The pcx_CANdb_TransmitMessage block provides a more convenient mechanism for specifying CAN information.

5.1.15.4. Inports

  • sim_error_flag

    A dummy input for simulation purposes only; may be grounded if not required. The value of outport error_flag in simulation.

    Value type:Boolean
    Calibratable:No
  • sim_request_count

    A dummy input for simulation purposes only; may be grounded if not required. The value of outport request_count in simulation. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer
  • sim_overwrite_count

    A dummy input for simulation purposes only; may be grounded if not required. The value of outport overwrite_count in simulation. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer
  • sim_ack_count

    A dummy input for simulation purposes only; may be grounded if not required. The value of outport ack_count in simulation. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer

5.1.15.5. Outports

  • error_flag

    Set to 1 if some error has occurred which prevents CAN transmission, otherwise set to 0.

    TypeConditions setting outport error_flag to 1
    run timethe message has been queued waiting for a transmit buffer to become available
    run timethe bus is in bus off state
    configurationthe bus has not been configured
    configurationmessage not configured, because too many transmit messages

    Value type:Boolean
    Calibratable:No
  • request_count

    A free running count of the application requests to transmit a message. The counter wraps to zero after reaching 65535. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer
  • overwrite_count

    A free running count of transmission requests which were queued by the software for later transmission because the CAN controller could not immediately accept the message for transmission. A queued message can be overwritten by subsequent attempts to transmit the same message (for instance, if the CAN bus is heavily loaded and the transmission rate high, the CAN controller may not be able to transmit the message before the application requests it is sent again, possibly with different data control from the previous request). The counter wraps to zero after reaching 65535. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer
  • ack_count

    A free running count of message transmissions successfully made by the CAN controller (i.e., those transmit messages which were acknowledged by at least one CAN node on the bus, not including the transmitting node). The counter wraps to zero after reaching 65535. Only available if the mask parameter Provide Transmission Status is selected.

    Value type:Integer

5.1.15.6. Mask parameters

  • Message Identifier

    The unique can identifier of the message to be transmitted.

    Range: [0, 2047] if standard identifier

    Range: [0, 536870911] if extended identifier

    Value type:Integer
    Calibratable:No
  • Message Length

    The number of data bytes to be transmitted.

    Range: [0, 8] bytes

    Value type:Integer
    Calibratable:No
  • Field Start Bit Positions

    A vector of bit numbers indicating the position at which each input Item begins in the CAN message. 0 corresponds to the least significant bit of data byte 0 of the message and 63 to the most significant byte of data byte 7 of the message, assuming these exist. For items whose bit length entry exceeds 7, the bit length must be one of: 0, 8, 16, 24, 32, 40, 48, 56.

    Size: [1, 64] elements

    Range: [0, 8], 16, 24, 32, 40, 48, 56 bit positions

    Value type:Integer
    Calibratable:No
  • Field Widths

    A vector of bit lengths indicating the number of bits used to transmit each input Item. The following values are allowed: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 24 and 32. Items of 8 bits or fewer may not be defined so as to straddle CAN byte boundaries.

    Size: [1, 64] elements

    Range: [1, 16], 24 or 32 bit width

    Value type:Integer
    Calibratable:No
  • Field Signs

    A vector of 1 or 0 values. Corresponding data items for which this is set 1 are transmitted as twos-complement signed numbers, or unsigned numbers otherwise.

    Size: [1, 64] elements

    Range: 0 or 1

    Value type:Integer
    Calibratable:No
  • Type Codes

    This block provides one data field input for each element in Field Start Positions, as given in Table 5.2, “CAN block type codes”.

    Value type:Integer
    Calibratable:No
  • Field Mnemonics

    A string containing a comma-separated list of names with which to label the simulation input and CAN data output ports.

    Value type:String
    Calibratable:No
  • CAN Bus Identifier

    Which can bus the message will be transmitted on.

    Value type:List
    Calibratable:No
  • Use Extended Message Identifier?

    If box is checked the 29 bit identifier is to be used, otherwise the 11 bit standard identifier is to be used.

    Value type:Boolean
    Calibratable:No
  • Provide Transmission Status

    If selected then outports request_count, overwrite_count and ack_count, and their corresponding simulation inports, are made available.

    Value type:Boolean
    Calibratable:No
  • Provide Simulation Output?

    If selected then dummy outputs for each of the inport can message signals, such as sim_signal_name, are provided by the block.

    Value type:Boolean
    Calibratable:No

5.1.15.7. Notes

  • Unused signals in a CAN message need not be specified in the Field Start Bit Positions parameter.

  • Not all OpenECU modules have both CAN buses populated (see Section 1.1, “ECU hardware reference documentation” for details about each device).

  • If the block shows unnamed inports, it is likely that one or more of the block fields is incorrect. Check the fields for mistakes and correct them.

  • The restrictions involving alignment of data items with 8 or more bits can be overcome by combining the smaller data items from the CAN message into larger data items using some Simulink math blocks, or by using the pcx_CANdb_TransmitMessage block.

  • All data is packed in Motorola byte ordering (MS byte first, LS byte last). The order of byte packing can be overcome by combining the smaller data items from the CAN message into larger data items using some Simulink math blocks, or by using the pcx_CANdb_TransmitMessage block.

  • Providing fewer than 8 entries in the Field Mnemonics parameter will result in some ports not being named. Providing greater than 8 entries in the Field Mnemonics parameter will result in corruption in the mask displayed on the block. This is a display artifact only and in both cases the port signals will still function as normal.