misuse serial port for I2C

I want to translate c++ code (below) to java

how can i do that?

#include <sys/types.h>

#include <sys/stat.h>

#include <sys/ioctl.h>

#include <fcntl.h>

#include <stdio.h>

#include <unistd.h>

#include <stdlib.h>

#include"i2c_m.h"

#define DBG 0

staticint fd = -1;

void scl_high(void){

if (DBG) printf("c");//dbg

int arg=TIOCM_RTS;

ioctl(fd, TIOCMBIS, &arg);

}

void scl_low(void){

if (DBG) printf("_");//dbg

int arg=TIOCM_RTS;

ioctl(fd, TIOCMBIC, &arg);

}

void sda_high(void){

if (DBG) printf("1");//dbg

int arg=TIOCM_DTR;

int r=0;

r=ioctl(fd, TIOCMBIS, &arg);

}

void sda_low(void){

if (DBG) printf("0");//dbg

int arg=TIOCM_DTR;

ioctl(fd, TIOCMBIC, &arg);

}

int wait_port(void){

if (DBG) printf("w");//dbg

usleep(1);

return(0);

}

// open port and set sda/scl to high

int open_tty(char *comport){

fd = open(comport, O_RDWR | O_NOCTTY);

if (fd <0){

fprintf(stderr,"ERROR: can not open serial port %s\n",comport);

exit(1);

}

sda_high();

scl_high();

return(fd);

}

int close_tty(void){

return( close(fd) );

}

...skip...

[3159 byte] By [Ricardosa] at [2007-10-2 13:41:02]
# 1
Hi,You should compile and link this to a shared library then call each function with a wrapper tool like JNative.If this is C++ then you need to create an extern C factory function to create an instance of your C++ class.--Marc ( http:///jnative.sf.net)
mdentya at 2007-7-13 11:34:22 > top of Java-index,Java HotSpot Virtual Machine,Specifications...
# 2
how about using the setRTS() and setDTR methods in javax.comm.CommPort?
gtbradleya at 2007-7-13 11:34:22 > top of Java-index,Java HotSpot Virtual Machine,Specifications...