Top / Prog / JAVA / RS232CȤ

RS232CȤ

⤷ʤΤǤäƤߤޤ (cygwinbashǤμ¹)

Java Communications API

ץץ

//--------------------------------------------------------------------
//  JAVA  RS232C Ȥ
//--------------------------------------------------------------------

import java.io.*;

import javax.comm.*;

public class Rs232ctest
{
   public static void main(String arg[]) throws IOException
   {
       try{
           CommPortIdentifier ports = CommPortIdentifier.getPortIdentifier("COM1");
           SerialPort port = (SerialPort)ports.open("RS232C", 1000);
           port.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
           port.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
           OutputStream out = port.getOutputStream();
           String msg = "Hello World!";
           out.write(msg.getBytes());
           out.flush();
           out.close();
           port.close();
       }catch(Exception e) {
           System.out.println("Err: " + e.getMessage());
       }
   }
}

ѥ¹

$ javac Rs232ctest.java
$ java Rs232ctest
		

ȤꤢϡˡŻҤΡPIC-BASIC ޥܡɡפ LCDˡ"Hello World!"ɽޤ

ܺ٤ϡ"Java Communications API"°ΥɥȤ򻲾ȤƤ

2005-06-05 03:22:04 ()

ץߥ


ȥå   Խ ʬ Хåå ź ʣ ̾ѹ   ñ측 ǽ   إ   ǽRSS
Last-modified: 2005-12-26 () 00:53:21 (4109d)