Page 49 - The Definitive Guide to Building Java Robots
P. 49

Preston_5564C02.fm  Page 30  Wednesday, September 14, 2005  5:42 AM



                 30     CHAPTER 2  ■  SERIAL COMMUNICATION




                        ■Note  More about the setup of Tomcat can be found in Chapter 8: Advanced Topics.



                        Setup

                        The following setup represents my PC with my Java IDE (Eclipse). I have a wireless connection
                        to the Tomcat Servlet Engine running on my robot’s computer. (See Figure 2-4.)






























                        Figure 2-4. Wireless WebSerialPort setup

                        Code Objective

                        The code objective is to extend the serial port so I can connect to it over my home’s wireless
                        connection using HTTP.


                        Code Discussion
                        The following example will be utilized in a Java Server Page residing on the web server.
                            The string, CMD_ACK, will be the acknowledge string returned from the webcom.jsp if
                        everything goes as planned and there are no errors.
                            The string, COMM_JSP, is the name of the JSP that will take the input and output request
                        from the client.
                            The READ_ONLY and DEFAULT_TIMEOUT variables are used to best calculate whether
                        the client should wait for the web server to respond with output from the serial port or make a
                        separate request for the output.
   44   45   46   47   48   49   50   51   52   53   54