Interface JnaLinuxSerial.LibCExt

All Superinterfaces:
com.sun.jna.platform.linux.LibC, com.sun.jna.platform.unix.LibCAPI, com.sun.jna.Library, com.sun.jna.platform.unix.Reboot, com.sun.jna.platform.unix.Resource
Enclosing class:
JnaLinuxSerial

public static interface JnaLinuxSerial.LibCExt extends com.sun.jna.platform.linux.LibC
Interface for some I/O relevant functions provided by Linux and other Unix-like operating systems.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    Structure pollfd, to be used in OS call poll().

    Nested classes/interfaces inherited from interface com.sun.jna.platform.linux.LibC

    com.sun.jna.platform.linux.LibC.Statvfs, com.sun.jna.platform.linux.LibC.Sysinfo

    Nested classes/interfaces inherited from interface com.sun.jna.Library

    com.sun.jna.Library.Handler

    Nested classes/interfaces inherited from interface com.sun.jna.platform.unix.Resource

    com.sun.jna.platform.unix.Resource.Rlimit
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static int
    Access mode value for read-only access.
    static int
    Access mode for read and write access.
    static int
    Access mode value for write-only access.
    static short
    Bit value for poll request to signal an error condition on the specified file descriptor.
    static short
    Bit value for poll request for non-blocking input.
    static short
    Bit value for poll request to signal that the specified file descriptor is invalid.
    static short
    Bit value for poll request for non-blocking output.

    Fields inherited from interface com.sun.jna.platform.linux.LibC

    INSTANCE, NAME

    Fields inherited from interface com.sun.jna.platform.unix.LibCAPI

    HOST_NAME_MAX

    Fields inherited from interface com.sun.jna.Library

    OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER

    Fields inherited from interface com.sun.jna.platform.unix.Reboot

    RB_AUTOBOOT, RB_DISABLE_CAD, RB_ENABLE_CAD, RB_HALT_SYSTEM, RB_KEXEC, RB_POWER_OFF, RB_SW_SUSPEND

    Fields inherited from interface com.sun.jna.platform.unix.Resource

    RLIMIT_AS, RLIMIT_CORE, RLIMIT_CPU, RLIMIT_DATA, RLIMIT_FSIZE, RLIMIT_LOCKS, RLIMIT_MEMLOCK, RLIMIT_MSGQUEUE, RLIMIT_NICE, RLIMIT_NLIMITS, RLIMIT_NOFILE, RLIMIT_NPROC, RLIMIT_RSS, RLIMIT_RTPRIO, RLIMIT_RTTIME, RLIMIT_SIGPENDING, RLIMIT_STACK
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    close​(int fd)
    Close a file or device
    int
    open​(String name, int mode)
    Open a file or device.
    int
    poll​(JnaLinuxSerial.LibCExt.pollfd[] fds, int count, int timeout)
    Checks whether files or devices are ready for reading or writing.
    int
    read​(int fd, byte[] buffer, int count)
    Read data from file or device.
    int
    system​(String command)
    Run a shell command and returns its exit code.
    int
    write​(int fd, byte[] buffer, int count)
    Write data to file or device.

    Methods inherited from interface com.sun.jna.platform.linux.LibC

    statvfs, sysinfo

    Methods inherited from interface com.sun.jna.platform.unix.LibCAPI

    getdomainname, getegid, getenv, geteuid, getgid, gethostname, getloadavg, getuid, setdomainname, setegid, setenv, seteuid, setgid, sethostname, setuid, unsetenv

    Methods inherited from interface com.sun.jna.platform.unix.Reboot

    reboot

    Methods inherited from interface com.sun.jna.platform.unix.Resource

    getrlimit, setrlimit
  • Field Details

    • O_RDONLY

      static final int O_RDONLY
      Access mode value for read-only access.
      See Also:
      Constant Field Values
    • O_WRONLY

      static final int O_WRONLY
      Access mode value for write-only access.
      See Also:
      Constant Field Values
    • O_RDWR

      static final int O_RDWR
      Access mode for read and write access.
      See Also:
      Constant Field Values
    • POLLIN

      static final short POLLIN
      Bit value for poll request for non-blocking input. If set in pollfd property events, it specifies that the file descriptor shall be checked for the ability to read without blocking. If set in pollfd property revents, it specifies that the next read will not block.
      See Also:
      Constant Field Values
    • POLLOUT

      static final short POLLOUT
      Bit value for poll request for non-blocking output. If set in pollfd property events, it specifies that the file descriptor shall be checked for the ability to write without blocking. If set in pollfd property revents, it specifies that the next write will not block.
      See Also:
      Constant Field Values
    • POLLERR

      static final short POLLERR
      Bit value for poll request to signal an error condition on the specified file descriptor. Whenever set in pollfd property revents, it specifies an error condition on the corresponding file descriptor.
      See Also:
      Constant Field Values
    • POLLNVAL

      static final short POLLNVAL
      Bit value for poll request to signal that the specified file descriptor is invalid. Whenever set in pollfd property revents, the corresponding file descriptor has been closed in the meantime (or has not been opened previously).
      See Also:
      Constant Field Values
  • Method Details

    • open

      int open(String name, int mode)
      Open a file or device.
      Parameters:
      name - File or device name
      mode - Access mode
      Returns:
      A positive value as a file descriptor for use in subsequent OS calls or -1 to report an error.
    • read

      int read(int fd, byte[] buffer, int count)
      Read data from file or device.
      Parameters:
      fd - File descriptor from previous open call.
      buffer - Data buffer to be filled.
      count - Maximum number of bytes to read.
      Returns:
      Number of bytes read. 0 in case of timeout, -1 in error case.
    • write

      int write(int fd, byte[] buffer, int count)
      Write data to file or device.
      Parameters:
      fd - File descriptor from previous open call.
      buffer - Data buffer to be writte.
      count - Number of bytes to be written.
      Returns:
      Number of bytes written or -1 in error cases.
    • close

      int close(int fd)
      Close a file or device
      Parameters:
      fd - File descriptor from previous open call.
      Returns:
      0 on success, -1 in error case.
    • poll

      int poll(JnaLinuxSerial.LibCExt.pollfd[] fds, int count, int timeout)
      Checks whether files or devices are ready for reading or writing.
      Parameters:
      fds - Array of pollfd structures, each specifying whether the file or device belonging to its file descriptor shall be checked for reading or writing without blocking.
      count - Number of pollfd structures to be used.
      timeout - Maximum number of milliseconds to wait before giving up.
      Returns:
      Number of file descriptors that can be used for at least one of the requested operations without blocking, 0 in case of a timeout, -1 if an error occurred.
    • system

      int system(String command)
      Run a shell command and returns its exit code.
      Parameters:
      command - Any command as it can be specified in a shell (/bin/sh).
      Returns:
      The exit code of the command.