Hardware Reference
In-Depth Information
older equipment because modern signaling technology no longer needs parity
checking, but it is still available if needed.
Stop Bits
Stop bits are automatically sent at the end of every packet. They allow the receiv-
ing hardware to detect the end of a character and to resynchronize with the
incoming stream. Modern electronic devices usually use 1 stop bit, but older
systems can use 1 1/2 or 2 bits.
Debugging and Output
Systems developers have a wide variety of debugging techniques to help them.
Programs can be run and “frozen,” allowing the developer to look inside the
program and see what is happening. You can run a program line by line, watch-
ing variables change during a program. In some cases, you can even rewrite
lines of code before they are executed, without having to restart your program.
Embedded systems offer an alternative, a physical port that connects directly
to the processor that allows a hardware debugger to take control. Again, pro-
grams can be run step by step; variables can be examined and modii ed; and
advanced debugging techniques can be used. All this comes at a cost; some
debuggers can cost tens of thousands of dollars.
Arduinos forgo these complex and costly implementations for less expensive
alternatives. The most common tool used for this purpose is the serial port.
Debugging with a serial port can be effective. It is possible to add a single
line to a program, printing out information and simple statements:
Debug: We are about to enter the function connectServer()
Debug: Connected!
Debug: Leaving connectServer()
Debug: Connecting to a client...
Debug: Connected with status 2! (should be 1)
This is an example of a debug output. First, you can tell that the function con-
nectServer() was called and that the program also cleanly exited the function.
Don't laugh; this is still in use on lots of development projects!
The last line is where things get interesting. You can use the serial output to
display values as shown here. If you can't use a debugger to look at a variable's
content, then print it out. In a single line, the developer knows that a return
value was not what he expected it to be, and now he has a good idea of where
to look for the problem.
 
Search WWH ::




Custom Search