package purejavacomm.testsuite;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
public class TestFTDI {
public static int O_RDWR = 0x00000002;
public static int O_NOCTTY = 0x00020000;
public static int O_NDELAY = 0x00000004;
public static int TIOCMGET = 0x4004746A;
public static long TIOCMSET = 0x8004746DL;
// public static int TIOCMSET =-2147191699;
// TIOCMGET 4004746a
// TIOCMSET 8004746d
static MacOSX_C_lib m_Clib = (MacOSX_C_lib) Native.loadLibrary("c", MacOSX_C_lib.class);
// if (ioctl(fd, ((__uint32_t)0x40000000 | ((sizeof(int) & 0x1fff) << 16) | ((('t')) << 8) | ((106))), &x) == -1)
// if (ioctl(fd, ((__uint32_t)0x80000000 | ((sizeof(int) & 0x1fff) << 16) | ((('t')) << 8) | ((109))), &x) == -1)
public interface MacOSX_C_lib extends com.sun.jna.Library {
public int ioctl(int fd, NativeLong cmd, NativeLong[] arg);
public int ioctl(int fd, long cmd, long[] arg);
public int open(String path, int flags);
public int close(int fd);
public void perror(String msg);
}
public static void main(String[] args) {
int fd = m_Clib.open("/dev/tty.usbserial-FTOXM3NX", O_RDWR | O_NOCTTY | O_NDELAY);
if (fd == -1)
m_Clib.perror("open ");
System.out.printf("open %d\n", fd);
NativeLong[] x = new NativeLong[] { new NativeLong(0) };
long[] x2 = { 0 };
if (m_Clib.ioctl(fd, new NativeLong(TIOCMGET), x) == -1)
m_Clib.perror("TIOCMGET ");
if (m_Clib.ioctl(fd, new NativeLong(TIOCMSET), x) == -1)
m_Clib.perror("TIOCMSET ");
m_Clib.close(fd);
System.out.println("OK "+TIOCMSET);
}
}