Two way communcation with the serial port
From Rxtx
con armi pettine per cani pronostico partite foto studenti x 52 hotas joystick lonsdale london compagnia leone cinematografica dior anticellulite notte ubriaca grande fratello schede video asus nvidia bridgeplug tecniche dipesca subacquea warren g more free moto honda varadero uefa champions pizza cats asus a730w letra opa opa adsl router 4 porte modem jimi hendrix live at woodstock dvd shirt ringspun vendita articolo sportivo on line festival bar mp3 clipart alfabeto sesso eva engel screensaver fantasy raffaella frosinone orgoglio episodio 1 nforce 2200 fabbriche porte philips masterizzatore dvd luce al neon actionman xclassic motorola v3 razr in the house www eros com file midi vanbasco karaoche epson scanner photo olympus camedia e10 la formica www yoga it calendari 2205 contratto integrativo nome dolcissimo il corriere dello sport medical italia apparecchio tens nuer www cucina it mujeres violadas praga hotel union motoriricerca hospital gyneco examination lettore dvd per auto jip guadalupe pineda sfondi azzurri f u r b testo palmare gsm wlan de benedictis breaking through video d annata rai merrell s decoder interattivo per tv digitale auricolari per ipod www spade aste husqvarna wre da gara lavori su polistirolo maria teresa ruta www caracol com good night baby good night turchia hotel lombra del peccato google hearth dabie shan profumo amuleti non andare via abi titmuss porno gratis spyware storm antenna gps bluetooth x nokia threesome memoria sdram 100 i 27 giorni del pianeta sigma transfor parola amicizia videoregistratore combi will smith man in black uuol www pink floyd com centro formiano foto sexy pink pokemon per discoteca intel prescott processori orcehstra stampanti termiche the o c theme tune california ultravoice digital vx2496 redondela dfi lanparty stampanti minolta hoobastank reason miniature vacanze alle mauritius www tabu com seg digital tennis bag tutto max pezzali cd musicali koka concorsi per laureati www pellini it senza segreti medialine mezzora sottozero rs 1500va diabolus 66 subsonica olivetti copia 9017 bearshear abbigliamento bimbi hp 535 mp3 rio forge la notte del giorno dopo compact flash radio john lee hoker these world custodia subaquea porno maturo vecchie troie concessionaria cruiser batteria panasonic g60 gioco educativo didattico bambino acer pc 3000 scrap solo foto piede palmare hp fotocamera lane fotocamera mp3 kodak easyshare dx 6490 stereomud applicativi gestionali pix 501 notebook memoria fujitsu ram konica a200 amplificatori audio schema elettrico il testamento di tito modena city rambler lexmark x1150 reflex medio radeon 9250 tv out stand espositivi artur gold srl colpo di luna delta hf integrale batterie 1800 voyuer tds net bar 7 axis 211 network camera toshiba l10161 modena city ramblers gratis girl prato kyo music city bucaneve inno artigliere sito ufficiale scania camion e l uomo per me one more time daft punk bologna helsinki biglietti aerei link kim sun il versace noir ia riproduzione nell essere umano notizie sms bergamo londra biglietti aerei d pinball bmw 330 xd san giacomo valle aurina philips 32pf9966 iraq decapitazione albergo lourdes verkaik sistor gsm consulenza condominiali antarctica powermust 2000 brack in to the magnex dvx www bellamusica it apple ibook g4 14 ben affek csa di bologna multichannel plugin piovigginare competition porno storie pellicceria varese hit parade singoli 2004 simplu jumatatea dominic purcell radio popolare kenan dogulu album 5 5 dvd portabile Below is a simple program that shows how to open a connection to a serial device and then interact with it (receiving data and sending data). One thing to note is that the package gnu.io is used instead of javax.comm, though other than the change in package name the API follows the Java Communication API. To find the names of the available ports, see the Discovering comm ports example.
import gnu.io.CommPort; import gnu.io.CommPortIdentifier; import gnu.io.SerialPort; import java.io.FileDescriptor; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; public class TwoWaySerialComm { public TwoWaySerialComm() { super(); } void connect ( String portName ) throws Exception { CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName); if ( portIdentifier.isCurrentlyOwned() ) { System.out.println("Error: Port is currently in use"); } else { CommPort commPort = portIdentifier.open(this.getClass().getName(),2000); if ( commPort instanceof SerialPort ) { SerialPort serialPort = (SerialPort) commPort; serialPort.setSerialPortParams(57600,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE); InputStream in = serialPort.getInputStream(); OutputStream out = serialPort.getOutputStream(); (new Thread(new SerialReader(in))).start(); (new Thread(new SerialWriter(out))).start(); } else { System.out.println("Error: Only serial ports are handled by this example."); } } } /** */ public static class SerialReader implements Runnable { InputStream in; public SerialReader ( InputStream in ) { this.in = in; } public void run () { byte[] buffer = new byte[1024]; int len = -1; try { while ( ( len = this.in.read(buffer)) > -1 ) { System.out.print(new String(buffer,0,len)); } } catch ( IOException e ) { e.printStackTrace(); } } } /** */ public static class SerialWriter implements Runnable { OutputStream out; public SerialWriter ( OutputStream out ) { this.out = out; } public void run () { try { int c = 0; while ( ( c = System.in.read()) > -1 ) { this.out.write(c); } } catch ( IOException e ) { e.printStackTrace(); } } } public static void main ( String[] args ) { try { (new TwoWaySerialComm()).connect("COM3"); } catch ( Exception e ) { // TODO Auto-generated catch block e.printStackTrace(); } } }