org.openmuc.canopen.lib
Interface CLibrary

All Superinterfaces:
com.sun.jna.Library

public interface CLibrary
extends com.sun.jna.Library

CLibary to interact wit libc.so in Linux. Implemented for communication with CAN.

See Also:
JNA

Nested Class Summary
static class CLibrary.can_frame
          Implements the C-structure can_frame.
static class CLibrary.fd_set
          Implements the C-structure fd_set.
static class CLibrary.ifmap
          Implements the C-structure ifmap.
static class CLibrary.ifreq
          Implements the C-structure ifreq.
static class CLibrary.sockaddr
          Implements the C-structure sockaddr.
static class CLibrary.sockaddr_can
          Implements the C-structure sockaddr_can.
static class CLibrary.timeval
          Implements the C-structure timeval.
 
Nested classes/interfaces inherited from interface com.sun.jna.Library
com.sun.jna.Library.Handler
 
Field Summary
static int AF_CAN
           
static int CAN_RAW
           
static int EAGAIN
           
static int ENETDOWN
           
static int ENODEV
           
static int EWOULDBLOCK
           
static int F_DUPFD
           
static int F_GETFD
           
static int F_GETFL
           
static int F_SETFD
           
static int F_SETFL
           
static int FD_SETSIZE
           
static int IFNAMESIZE
           
static CLibrary INSTANCE
           
static int O_NONBLOCK
           
static int PF_CAN
           
static com.sun.jna.NativeLong SIOCGIFINDEX
           
static int SOCK_RAW
           
 
Fields inherited from interface com.sun.jna.Library
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER
 
Method Summary
 int bind(int __fd, com.sun.jna.Structure.ByReference __addr, int __len)
          Give the socket FD the local address ADDR (which is LEN bytes long).
 int close(int __fd)
          Close the file descriptor FD.
 int fcntl(int __fd, int __cmd, java.lang.Object... objects)
          Do the file control operation described by CMD on FD.
 int ioctl(int __fd, com.sun.jna.NativeLong __request, java.lang.Object... objects)
          Perform the I/O control operation specified by REQUEST on FD.
 void printf(java.lang.String format, java.lang.Object... objects)
          Write formatted output to stdout.
 int read(int __fd, java.lang.Object __buf, int __nbytes)
          Read NBYTES into BUF from FD.
 int select(int __nfds, CLibrary.fd_set.ByReference __readfds, CLibrary.fd_set.ByReference __writefds, CLibrary.fd_set.ByReference __exceptfds, CLibrary.timeval.ByReference __timeout)
          Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS (if not NULL) for exceptional conditions.
 int socket(int __domain, int __type, int __protocol)
          Create a new socket of type TYPE in domain DOMAIN, using protocol PROTOCOL.
 java.lang.String strcpy(byte[] __dest, java.lang.String __src)
          Copy SRC to DEST.
 java.lang.String strerror(int errnum)
          Return a string describing the meaning of the 'errno' code in ERRNUM.
 int write(int __fd, java.lang.Object __buf, int __nbytes)
          Write N bytes of BUF to FD.
 

Field Detail

INSTANCE

static final CLibrary INSTANCE

PF_CAN

static final int PF_CAN
See Also:
Constant Field Values

SOCK_RAW

static final int SOCK_RAW
See Also:
Constant Field Values

CAN_RAW

static final int CAN_RAW
See Also:
Constant Field Values

AF_CAN

static final int AF_CAN
See Also:
Constant Field Values

SIOCGIFINDEX

static final com.sun.jna.NativeLong SIOCGIFINDEX

IFNAMESIZE

static final int IFNAMESIZE
See Also:
Constant Field Values

FD_SETSIZE

static final int FD_SETSIZE
See Also:
Constant Field Values

F_DUPFD

static final int F_DUPFD
See Also:
Constant Field Values

F_GETFD

static final int F_GETFD
See Also:
Constant Field Values

F_SETFD

static final int F_SETFD
See Also:
Constant Field Values

F_GETFL

static final int F_GETFL
See Also:
Constant Field Values

F_SETFL

static final int F_SETFL
See Also:
Constant Field Values

O_NONBLOCK

static final int O_NONBLOCK
See Also:
Constant Field Values

EAGAIN

static final int EAGAIN
See Also:
Constant Field Values

EWOULDBLOCK

static final int EWOULDBLOCK
See Also:
Constant Field Values

ENODEV

static final int ENODEV
See Also:
Constant Field Values

ENETDOWN

static final int ENETDOWN
See Also:
Constant Field Values
Method Detail

socket

int socket(int __domain,
           int __type,
           int __protocol)
Create a new socket of type TYPE in domain DOMAIN, using protocol PROTOCOL. If PROTOCOL is zero, one is chosen automatically. Returns a file descriptor for the new socket, or -1 for errors.

Parameters:
__domain - DOMAIN
__type - TYPE
__protocol - PROTOCOL If PROTOCOL is zero, one is chosen automatically.
Returns:
A file descriptor for the new socket, or -1 for errors

ioctl

int ioctl(int __fd,
          com.sun.jna.NativeLong __request,
          java.lang.Object... objects)
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST. Return value depends on REQUEST. Usually -1 indicates error.

Parameters:
__fd - File descriptor
__request - REQUEST Specifies the operation
objects - Varargs
Returns:
Value depends on REQUEST. Usually -1 indicates error.

bind

int bind(int __fd,
         com.sun.jna.Structure.ByReference __addr,
         int __len)
Give the socket FD the local address ADDR (which is LEN bytes long).

Parameters:
__fd - File descriptor
__addr - The local address ADDR.
__len - The size of ADDR in bytes.
Returns:
-1 for errors.

close

int close(int __fd)
Close the file descriptor FD.

Parameters:
__fd - File descriptor
Returns:
-1 for errors.

select

int select(int __nfds,
           CLibrary.fd_set.ByReference __readfds,
           CLibrary.fd_set.ByReference __writefds,
           CLibrary.fd_set.ByReference __exceptfds,
           CLibrary.timeval.ByReference __timeout)
Check the first NFDS descriptors each in READFDS (if not NULL) for read readiness, in WRITEFDS (if not NULL) for write readiness, and in EXCEPTFDS (if not NULL) for exceptional conditions. If TIMEOUT is not NULL, time out after waiting the interval specified therein. Returns the number of ready descriptors, or -1 for errors.

Parameters:
__nfds - NFDS
__readfds - READFDS
__writefds - WRITEFDS
__exceptfds - EXCEPTFDS
__timeout - TIMEOUT
Returns:
The number of ready descriptors, 0 if timeout, -1 if error.

fcntl

int fcntl(int __fd,
          int __cmd,
          java.lang.Object... objects)
Do the file control operation described by CMD on FD. The remaining arguments are interpreted depending on CMD.

Parameters:
__fd - File descriptor
__cmd - CMD
objects - Varargs
Returns:

write

int write(int __fd,
          java.lang.Object __buf,
          int __nbytes)
Write N bytes of BUF to FD. Return the number written, or -1.

Parameters:
__fd - File descriptor
__buf - BUF
__nbytes - Bytes to be written.
Returns:
The number written, or -1.

read

int read(int __fd,
         java.lang.Object __buf,
         int __nbytes)
Read NBYTES into BUF from FD. Return the number read, -1 for errors or 0 for EOF.

Parameters:
__fd - File descriptor
__buf - BUF
__nbytes - Bytes to be read.
Returns:
The number read, -1 for errors or 0 for EOF.

printf

void printf(java.lang.String format,
            java.lang.Object... objects)
Write formatted output to stdout.

Parameters:
format - Formatted string.
objects - Varargs to be written.

strerror

java.lang.String strerror(int errnum)
Return a string describing the meaning of the 'errno' code in ERRNUM.

Parameters:
errnum - errno
Returns:
A string describing the meaning of the 'errno' code in ERRNUM.

strcpy

java.lang.String strcpy(byte[] __dest,
                        java.lang.String __src)
Copy SRC to DEST.

Parameters:
__dest - DEST
__src - SRC
Returns:
The String copied.