This is a reference example that provides basic functionality of a netowkr server that interfaces a network connection (possibly from a Java applet) to an embedded system that is connected to a serial port. This server uses TCP/IP protocol and allows multiple clients to connect at the same time.
Please see the basic COM Port example to for explanation about COM port accessibility. You will need to place the following files in the same folder with your project:
When compiling the COMport class include comm.jar in the class path:
c:\progra~1\java\bin\javac -classpath c:\progra~1\java\lib;.;.\comm.jar COMPort.java
You do not need to include it when compiling classes that do not import directly the jar library features:
c:\progra~1\java\bin\javac ReferenceTCPIPServer.java c:\progra~1\java\bin\javac EmbedImplementation.java
When running your program, include comm.jar in the class path. For example:
c:\progra~1\java\bin\java -classpath c:\progra~1\java\lib;.;.\comm.jar ReferenceTCPIPServer
More sophisticated execution is possible. The following example allows to rerun the server if it is terminated. A developer may combine it with replacing the java classes with the newer version before restarting the server. One can replace the classes using FTP. That allows for remote development on win32 platform that does not have a telnet service that allows to stop and start the program directly from a console.
@echo off echo Starting the XXX Server... :RERUN REM c:\progra~1\java\bin\java -classpath c:\progra~1\java\jre\lib\rt.jar;.;.\comm.jar ReferenceTCPIPServer REM if ERRORLEVEL 10 goto TERMINATE echo Restarting the XXX Server ... goto RERUN :TERMINATE echo Terminating the XXX Server ... exit
Download the complete example