[kaffe] Serial Port on Kaffe

Josef Nordangård Josef.Nordangard at ascomtateco.se
Tue Oct 29 07:28:04 PST 2002


It is also possible to open the serial port as a file. Init the port using system calls. A small example for linux:

------------------------
    public Serial(int baudrate, boolean evenparity, int stopbits, 
		  int charsize) throws FileNotFoundException, IOException{

	Runtime rt = Runtime.getRuntime();

	// Sets up the port with specified baudrate, parity, stopbits, 
	// and character size.

	if (evenparity)
	    parity = "-parodd";
	if (stopbits == 2)
	    sbits = "cstopb";

	String cmd = 
	    "settty " + comPath + " " + 
	    baudrate + " " + parity + " " + sbits + " cs" + charsize;
	try {
	    Process p = rt.exec(cmd);
	
	    if ((p.waitFor()) != 0) 
		throw new IOException("Error initzialising serial port");
	} catch (InterruptedException e) {
	    throw new IOException("Error initzialising serial port");
	}

	out = new BufferedWriter(new FileWriter(comPath), 50);
	in = new BufferedReader(new FileReader(comPath), 50);
    }

------------------------

settty is just a small script.

/Josef

-----Original Message-----
From: cfowler [mailto:cfowler at outpostsentinel.com]
Sent: tisdag den 29 oktober 2002 14:37
To: Etienne Julien
Cc: kaffe at kaffe.org
Subject: Re: [kaffe] Serial Port on Kaffe


My belief is that you'll need to resort to using JNI to do this.  Sun
has the Java Communications API for Windows but it use JNI.  Maybe
others have insight on the best method.

Chris


On Tue, 2002-10-29 at 08:03, Etienne Julien wrote:
> Hi,
> 
> I'm newbie to kaffe and I want to know if it is possible to use serial port with it.
> I see a file comm.jar in the share directory but I don't know how to use it.
> 
> Thanks for response
> 
> Julien



_______________________________________________
kaffe mailing list
kaffe at kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe




More information about the kaffe mailing list