Wednesday, September 08, 2010

  • Print
  • |
  • |
  • Reprints
  • |
  • RSS
  • |
 

Java Essentials for Embedded Networked Devices - Part 6: Serial ports

Part 6 of an excerpt from the book "Designing Embedded Internet Devices" examines how to access your computer's serial ports.

Brian DeMuth and Dan Eisenreich

Page 1 of 4

[Part 1 of this article discusses how to obtain and set up Java for Windows and Linux PCs. Part 2 reviews classes, objects, and methods, as well as OOP diagrams and inheritance. Part 3 discusses exceptions and exception handling, including examples. Part 4 highlights network programming, including programming with sockets, ports and URLs. Part 5 examines Java's multitasking capabilities.]

Serial ports
We are now going to examine how to access your computer's serial ports. In order to do this, we need some sort of serial device to talk to.

A serial port loopback plug is probably the simplest. These are very cheap and easy to make using the proper female connector for your serial port. The necessary connections are shown in the figures below for both 9-pin and 25-pin serial ports.

Figure 3-13: Serial loopback 9-pin plug

Figure 3-14: Serial loopback 25-pin plug

Note that the dotted line is an optional wire that some loopback plugs have. This is not necessary for the examples in the book (but it won't hurt either). Once your loopback plug is installed on your serial port, compile and run the program SerialLoopTest.java in the listing below. Don't forget that you need comm.jar on your CLASSPATH environment variable for this to compile and run.

Page 2: SerialLoopTest.java program listing
Page 3: SerialLoopTest.java output
Page 4: Conclusion & summary

Page 1 2 3 4
Intel Embedded Design Center