Xenomai API  2.6.4
User API
Collaboration diagram for User API:

Files

file  rtdm.h
 Real-Time Driver Model for Xenomai, user API header.

Functions

int rt_dev_open (const char *path, int oflag,...)
 Open a device.
int rt_dev_socket (int protocol_family, int socket_type, int protocol)
 Create a socket.
int rt_dev_close (int fd)
 Close a device or socket.
int rt_dev_ioctl (int fd, int request,...)
 Issue an IOCTL.
ssize_t rt_dev_read (int fd, void *buf, size_t nbyte)
 Read from device.
ssize_t rt_dev_write (int fd, const void *buf, size_t nbyte)
 Write to device.
ssize_t rt_dev_recvmsg (int fd, struct msghdr *msg, int flags)
 Receive message from socket.
ssize_t rt_dev_recvfrom (int fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen)
 Receive message from socket.
ssize_t rt_dev_recv (int fd, void *buf, size_t len, int flags)
 Receive message from socket.
ssize_t rt_dev_sendmsg (int fd, const struct msghdr *msg, int flags)
 Transmit message to socket.
ssize_t rt_dev_sendto (int fd, const void *buf, size_t len, int flags, const struct sockaddr *to, socklen_t tolen)
 Transmit message to socket.
ssize_t rt_dev_send (int fd, const void *buf, size_t len, int flags)
 Transmit message to socket.
int rt_dev_bind (int fd, const struct sockaddr *my_addr, socklen_t addrlen)
 Bind to local address.
int rt_dev_connect (int fd, const struct sockaddr *serv_addr, socklen_t addrlen)
 Connect to remote address.
int rt_dev_listen (int fd, int backlog)
 Listen for incomming connection requests.
int rt_dev_accept (int fd, struct sockaddr *addr, socklen_t *addrlen)
 Accept a connection requests.
int rt_dev_shutdown (int fd, int how)
 Shut down parts of a connection.
int rt_dev_getsockopt (int fd, int level, int optname, void *optval, socklen_t *optlen)
 Get socket option.
int rt_dev_setsockopt (int fd, int level, int optname, const void *optval, socklen_t optlen)
 Set socket option.
int rt_dev_getsockname (int fd, struct sockaddr *name, socklen_t *namelen)
 Get local socket address.
int rt_dev_getpeername (int fd, struct sockaddr *name, socklen_t *namelen)
 Get socket destination address.

Detailed Description

This is the upper interface of RTDM provided to application programs both in kernel and user space. Note that certain functions may not be implemented by every device. Refer to the Device Profiles for precise information.

Function Documentation

int rt_dev_accept ( int  fd,
struct sockaddr *  addr,
socklen_t *  addrlen 
)

Accept a connection requests.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[out]addrBuffer for remote address
[in,out]addrlenAddress buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
accept() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_bind ( int  fd,
const struct sockaddr *  my_addr,
socklen_t  addrlen 
)

Bind to local address.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]my_addrAddress buffer
[in]addrlenAddress buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
bind() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
Examples:
rtcanrecv.c, and rtcansend.c.
int rt_dev_close ( int  fd)

Close a device or socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_open() or rt_dev_socket()
Returns
0 on success, otherwise a negative error code.
Note
If the matching rt_dev_open() or rt_dev_socket() call took place in non-real-time context, rt_dev_close() must be issued within non-real-time as well. Otherwise, the call will fail.

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
close() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_connect ( int  fd,
const struct sockaddr *  serv_addr,
socklen_t  addrlen 
)

Connect to remote address.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]serv_addrAddress buffer
[in]addrlenAddress buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
connect() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_getpeername ( int  fd,
struct sockaddr *  name,
socklen_t *  namelen 
)

Get socket destination address.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[out]nameAddress buffer
[in,out]namelenAddress buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
getpeername() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_getsockname ( int  fd,
struct sockaddr *  name,
socklen_t *  namelen 
)

Get local socket address.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[out]nameAddress buffer
[in,out]namelenAddress buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
getsockname() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_getsockopt ( int  fd,
int  level,
int  optname,
void *  optval,
socklen_t *  optlen 
)

Get socket option.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]levelAddressed stack level
[in]optnameOption name ID
[out]optvalValue buffer
[in,out]optlenValue buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
getsockopt() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_ioctl ( int  fd,
int  request,
  ... 
)

Issue an IOCTL.

Parameters
[in]fdFile descriptor as returned by rt_dev_open() or rt_dev_socket()
[in]requestIOCTL code
...Optional third argument, depending on IOCTL function (void * or unsigned long)
Returns
Positiv value on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
ioctl() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_listen ( int  fd,
int  backlog 
)

Listen for incomming connection requests.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]backlogMaximum queue length
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
lsiten() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_open ( const char *  path,
int  oflag,
  ... 
)

Open a device.

Parameters
[in]pathDevice name
[in]oflagOpen flags
...Further parameters will be ignored.
Returns
Positive file descriptor value on success, otherwise a negative error code.

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
open() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_read ( int  fd,
void *  buf,
size_t  nbyte 
)

Read from device.

Parameters
[in]fdFile descriptor as returned by rt_dev_open()
[out]bufInput buffer
[in]nbyteNumber of bytes to read
Returns
Number of bytes read, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
read() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_recv ( int  fd,
void *  buf,
size_t  len,
int  flags 
)

Receive message from socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[out]bufMessage buffer
[in]lenMessage buffer size
[in]flagsMessage flags
Returns
Number of bytes received, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
recv() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_recvfrom ( int  fd,
void *  buf,
size_t  len,
int  flags,
struct sockaddr *  from,
socklen_t *  fromlen 
)

Receive message from socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[out]bufMessage buffer
[in]lenMessage buffer size
[in]flagsMessage flags
[out]fromBuffer for message sender address
[in,out]fromlenAddress buffer size
Returns
Number of bytes received, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
recvfrom() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399

References rt_dev_recvfrom().

Referenced by rt_dev_recvfrom().

ssize_t rt_dev_recvmsg ( int  fd,
struct msghdr *  msg,
int  flags 
)

Receive message from socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in,out]msgMessage descriptor
[in]flagsMessage flags
Returns
Number of bytes received, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
recvmsg() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_send ( int  fd,
const void *  buf,
size_t  len,
int  flags 
)

Transmit message to socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]bufMessage buffer
[in]lenMessage buffer size
[in]flagsMessage flags
Returns
Number of bytes sent, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
send() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
Examples:
rtcansend.c.
ssize_t rt_dev_sendmsg ( int  fd,
const struct msghdr *  msg,
int  flags 
)

Transmit message to socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]msgMessage descriptor
[in]flagsMessage flags
Returns
Number of bytes sent, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
sendmsg() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_sendto ( int  fd,
const void *  buf,
size_t  len,
int  flags,
const struct sockaddr *  to,
socklen_t  tolen 
)

Transmit message to socket.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]bufMessage buffer
[in]lenMessage buffer size
[in]flagsMessage flags
[in]toBuffer for message destination address
[in]tolenAddress buffer size
Returns
Number of bytes sent, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
sendto() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
Examples:
rtcansend.c.
int rt_dev_setsockopt ( int  fd,
int  level,
int  optname,
const void *  optval,
socklen_t  optlen 
)

Set socket option.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]levelAddressed stack level
[in]optnameOption name ID
[in]optvalValue buffer
[in]optlenValue buffer size
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
setsockopt() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
Examples:
rtcanrecv.c, and rtcansend.c.
int rt_dev_shutdown ( int  fd,
int  how 
)

Shut down parts of a connection.

Parameters
[in]fdFile descriptor as returned by rt_dev_socket()
[in]howSpecifies the part to be shut down (SHUT_xxx)
Returns
0 on success, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
shutdown() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
int rt_dev_socket ( int  protocol_family,
int  socket_type,
int  protocol 
)

Create a socket.

Parameters
[in]protocol_familyProtocol family (PF_xxx)
[in]socket_typeSocket type (SOCK_xxx)
[in]protocolProtocol ID, 0 for default
Returns
Positive file descriptor value on success, otherwise a negative error code.

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
socket() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399
ssize_t rt_dev_write ( int  fd,
const void *  buf,
size_t  nbyte 
)

Write to device.

Parameters
[in]fdFile descriptor as returned by rt_dev_open()
[in]bufOutput buffer
[in]nbyteNumber of bytes to write
Returns
Number of bytes written, otherwise negative error code

Environments:

Depends on driver implementation, see Device Profiles.

Rescheduling: possible.

See Also
write() in IEEE Std 1003.1, http://www.opengroup.org/onlinepubs/009695399