Transmit a TWAI message This function queues a TWAI message for transmission. Transmission will start immediately if no other messages are queued for transmission. If the TX queue is full, this function will block until more space becomes available or until it times out. If the TX queue is disabled (TX queue length = 0 in configuration), this function will return immediately if another message is undergoing transmission. This function can only be called when the TWAI driver is in the running state and cannot be called under Listen Only Mode.
- ESP_OK: Transmission successfully queued/initiated - ESP_ERR_INVALID_ARG: Arguments are invalid - ESP_ERR_TIMEOUT: Timed out waiting for space on TX queue - ESP_FAIL: TX queue is disabled and another message is currently transmitting - ESP_ERR_INVALID_STATE: TWAI driver is not in running state, or is not installed - ESP_ERR_NOT_SUPPORTED: Listen Only Mode does not support transmissions
Notes
This function does not guarantee that the transmission is successful. The TX_SUCCESS/TX_FAILED alert can be enabled to alert the application upon the success/failure of a transmission. The TX_IDLE alert can be used to alert the application when no other messages are awaiting transmission.
Related Functions
Found 5 other functions taking a twai_message_t
argument:
Receive a TWAI message This function receives a message from the RX queue. The flags field of the message structure will indicate the type of message received. This function will block if there are no messages in the RX queue @warning The flags field of the received message should be checked to determine if the received message contains any data bytes.
Format a TWAI Frame This function takes a TWAI message structure (containing ID, DLC, data, and flags) and formats it to match the layout of the TX frame buffer.
Parse a TWAI Frame This function takes a TWAI frame (in the format of the RX frame buffer) and parses it to a TWAI message (containing ID, DLC, data and flags).
Examples
twai_transmit() is referenced by 4 libraries and example projects: