Re: CommPort integration
AndreasW wrote:
Hello,
i've got a question about the integration of a CommPort into a Java
programm. I need it for data transfer between the PC and a
Microcontroller. I'm a newbie in programming and so it would be very
useful to have some easy examples or an introduction for the
initialisation of the port and the read/transmit- process. I've
downloaded "commapi" from Sun Microsystems, but I mean the description
is a little bit complicated.
I hope you could help me with a useful link or a helpful example file.
Thank you very much.
AW
I don't know if it is important, but I use the JBuilder from Borland.
Here is some code taken from an application I wrote. It opens the port,
sets the parameters and obtains an InputStream. After that it is just
like any other stream I/O.
CommPortIdentifier cpi =
CommPortIdentifier.getPortIdentifier("COM1");
SerialPort sp =
(SerialPort)cpi.open("LVDCClient",2500);
// set serial port parameters
sp.setSerialPortParams(9600,SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
sp.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
sp.disableReceiveTimeout();
sp.disableReceiveThreshold();
InputStream is = sp.getInputStream();
bis = new BufferedInputStream(is);
--
Knute Johnson
email s/nospam/knute/