Arduino CH340 Rx-Tx loopback test. (CH340) to use it as USB TTL converter and connect TX to RX each other. But holding reset will hold the USB-serial DTR. Contents • • • • • • • • • • General Instructions This example shows how write a Java program to write out 'Hello World' to a serial port or to a USB to serial converter. Before you start you will need to ensure that a suitable Java VM is installed, along with the RXTX Libraries (see platform specifc instructions below). These instructions all make use of the example file, which you will need to download. Once downloaded to a folder of your choice, from an editor: • Change the third import statement 'import javax.comm.*;' to read: import gnu.io.*; • Change the line 'String defaultPort = '/dev/term/a';' to refer to your serial device (see platform specifc instructions below). For example on Windows: String defaultPort = 'COM4'; This Java program can be compiled and run by typing the following from the command line: javac SimpleWrite.java java SimpleWrite 'Hello World' should then appear on the device connected to the serial port, assuming that it has been set up to receive a 9600 baud rate, 8 data bits, 1 stop bit, no parity and no handshaking. Windows XP Installing JavaVM and RXTX and Install Sun's Java software (JDK 6 Update 3 at time of writing). The JDK files are placed at C: Program Files Java jdk1.6.0_03 and the runtime files are placed at C: Program Files Java jre1.6.0_03. Ensure the System Variable 'path' (held in My Computer->properties->Advanced->Environment Varables->System Variables) includes ';C: Program Files Java jdk1.6.0_03 bin' at the end. Note: JDK 1.4 will work with RXTX, but there is not harm in being up to date. Install RxTx. This involves placing rxtxSerial.dll and rxtxParallell.dll in both C: Program Files Java jdk1.6.0_03 jre bin and C: Program Files Java jre1.6.0_03 bin. It also involves placing RXTXcomm.jar in both C: Program Files Java jdk1.6.0_03 jre lib ext and C: Program Files Java jre1.6.0_03 lib ext. The Serial Port Name If the machine doesn't have a serial port, install a USB to serial converter following the manufacturer's instructions. Select My Computer->Properties->Hardware->Device Manager->Ports(COM&LPT)->USB - Serial Comm Port (COM4). This shows a COM port to which the device was installed - in this case COM4. Serial ports on MS-Windows based systems are of the form COMn, where n is a number. For example COM4.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
January 2019
Categories |