transmit()

Transmit data to hardware

Synopsis

#include <hw/libcan.h>

void transmit( CANDEV *cdev );

Arguments

cdev

A pointer to the structure corresponding to the device that should transmit the data.

Description

The transmit() function removes a message from the active message queue, transmits it to hardware, and adds the message element back to the free message element queue specified by cdev->free_queue (if the active message queue specified by cdev->msg_queue isn't empty). Once the active message queue is empty, return from the function.

If the hardware buffers fill up before the message queue is empty, then the function may also return. This is because the interrupt associated with cdev fires when it's able to accept new packages to transmit.

Example

void my_transmit(CANDEV *cdev)
{
  canmsg_t *msg;
  my_device_t *mydev = get_my_device(cdev);
  while (NULL != (msg = canmsg_dequeue_element(cdev->msg_queue)))
  {
    send_data_to_device(mydev, &msg->cmsg);
    canmsg_queue_element(cdev->free_queue, msg);
  }
}
Page updated: