Keil™, An ARM® Company

RL-ARM User's Guide

Technical Support

On-Line Manuals

RL-ARM User's Guide

RL-RTX
RL-FlashFS
RL-TCPnet
RL-CAN
Example Programs
Library Reference
Data Types
BIT
BOOL
CAN_ERROR
CAN_msg
FILE
S8
S16
S32
S64
U8
U16
U32
U64
Include Files
can_cfg.h
can_error.h
file_config.h
net_config.h
rtl.h
rtx_can.h
rtx_config.h
stdio.h
Reference
_alloc_box
_calloc_box
_declare_box
_declare_box8
_free_box
_init_box
_init_box8
arp_cache_ip
CAN_init
CAN_receive
CAN_request
CAN_rx_object
CAN_send
CAN_set
CAN_start
CAN_tx_object
cgi_func
cgi_process_data
cgi_process_var
com_getchar
com_putchar
com_tx_active
dhcp_disable
fanalyse
fcheck
fclose
fdefrag
fdelete
feof
ferror
ffind
fflush
fformat
ffree
fgetc
fgets
finit
fopen
fprintf
fputc
fputs
fread
frename
fs_EraseSector
fs_get_date
fs_get_time
fs_Init
fs_ProgramPage
fs_spi_EraseSector
fs_spi_Init
fs_spi_ProgramPage
fs_spi_ReadData
fscanf
fseek
ftell
fwrite
get_host_by_name
http_get_info
http_get_lang
http_get_session
http_get_var
igmp_join
igmp_leave
init_ethernet
init_modem
init_serial
init_TcpNet
int_disable_eth
int_enable_eth
interrupt_ethernet
isr_evt_set
isr_mbx_check
isr_mbx_receive
isr_mbx_send
isr_sem_send
main_TcpNet
mci_init
mci_read_config
mci_read_sect
mci_write_sect
modem_dial
modem_hangup
modem_listen
modem_online
modem_process
modem_run
os_dly_wait
os_evt_clr
os_evt_get
os_evt_set
os_evt_wait_and
os_evt_wait_or
os_itv_set
os_itv_wait
os_mbx_check
os_mbx_declare
os_mbx_init
os_mbx_send
os_mbx_wait
os_mut_init
os_mut_release
os_mut_wait
os_sem_init
os_sem_send
os_sem_wait
os_sys_init
os_sys_init_prio
os_sys_init_user
os_tmr_call
os_tmr_create
os_tmr_kill
os_tsk_create
os_tsk_create_ex
os_tsk_create_user
os_tsk_create_user_ex
os_tsk_delete
os_tsk_delete_self
os_tsk_pass
os_tsk_prio
os_tsk_prio_self
os_tsk_self
poll_ethernet
ppp_close
ppp_connect
ppp_is_up
ppp_listen
rewind
send_frame
slip_close
slip_connect
slip_is_up
slip_listen
smtp_cbfunc
smtp_connect
spi_hi_speed
spi_init
spi_send
spi_ss
tcp_abort
tcp_check_send
tcp_close
tcp_connect
tcp_get_buf
tcp_get_socket
tcp_get_state
tcp_listen
tcp_max_dsize
tcp_release_socket
tcp_reset_window
tcp_send
tftp_fclose
tftp_fopen
tftp_fread
tftp_fwrite
timer_tick
tnet_cbfunc
tnet_ccmp
tnet_get_info
tnet_msg_poll
tnet_process_cmd
tnet_set_delay
tsk_lock
tsk_unlock
udp_close
udp_get_buf
udp_get_socket
udp_mcast_ttl
udp_open
udp_release_socket
udp_send
ungetc
Library Files
Appendix

CAN_send

Summary 
#include <rtx_can.h>

CAN_ERROR CAN_send (
  U32 ctrl,        /* CAN Controller */
  CAN_msg *msg,    /* CAN Message */
  U16 timeout);    /* Time to Wait */
Description 

The CAN_send function transmits msg using the CAN controller specified by ctrl.

If the CAN controller hardware is ready (no other transmissions are in progress), the CAN_send function sends the msg to the CAN controller for transmission. If the CAN controller is busy, the msg is put into a FIFO (that is managed using an RTX mailbox). Messages stored in the the FIFO are sent in order.

The timeout specifies how long to wait for the FIFO (mailbox slot) to become available.

timeoutDescription
0Return immediately.
0x0001-0xFFFEWait the specified number of RTX Kernel ticks.
0xFFFFWait infinitely.

If a message is not stored in the FIFO by the specified time, an error is returned.

The CAN_send function executes quickly since all data transfers use software buffers. Only in situations where the FIFO is full is the CAN_send function delayed.

The CAN_send function is part of RL-CAN. The prototype is defined in rtx_can.h.

Return Value 

The CAN_send function returns one of the following manifest constants.

  • CAN_OK
    Success.
  • CAN_ALLOC_MEM_ERROR
    Indicates there is no available memory in the CAN memory pool.
  • CAN_DEALLOC_MEM_ERROR
    Indicates that the memory used by the transmitted message was not correctly deallocated.
  • CAN_TIMEOUT
    Indicates that the timeout expired before a message was transmitted.
See Also CAN_receive
Example 
#include <rtx_can.h>

void task_send_CAN (void) __task
{
unsined int i = 0;

CAN_msg msg_buf =
  {
  33,                           // ID
  { 0x00, 0x00, 0x00, 0x00,
    0x00, 0x00, 0x00, 0x00 },   // Data
  1,                            // Length
  1,                            // Channel
  STANDARD_FORMAT,              // Format
  DATA_FRAME                    // Type
  };

while (1)
  {
// Put data (i) into the transmit buffer
// Send CAN message on controller 2
  msg_buf.data[0] = ++i;
  CAN_send (2, &msg_buf, 0x0F00);

// Wait 100ms
  os_dly_wait (10);
  }
}