|
Serial Communications: A C++ Developer's Guide, 2nd Edition by Mark Nelson IDG Books Worldwide, May 2000 ISBN 0-76454-570-1 864 pages. List price in the US is $49.99 |
|
First Edition
The page for the first edition is still on line. You can read it at this link. The first edition has been out of print for some time, so you probably won't find this page much use.
Availability
| Unfortunately, this book is out of print. However, you can frequently find used copies available on Amazon.com for reasonable prices. Be sure to order the second edition. If you use the link posted here, you will be helping me with the costs of keeping this web site up and running. Thanks! |
Errata
The 32 bit code in this book was developed for the most part with Visual C++ 5. Readers have run into a few compiler glitches with Visual C++ 6. If you use VC++ 6, please be sure to apply all of Microsoft's service packs. At this time, the latest is SP3. You can download these from the Microsoft web site. (I'd provide a link, but Microsoft changes their web page often enough to make this an exercise in frustration.
Chapter 1
Figure 1-5 on Page 10 has an extra 0 bit in the middle of the world. There should be a string of 5, not six. Here's an improved version of the image:

Chapter 11
Win32Port.h
If you are developing for a Windows 2000 target, or for NT 4 with SP3 or later, you will need to modify a single line in Win32Port.h. Around line 76 of this file, you will find a line of code that looks like this:
-
enum { EV_RINGTE = 0x2000 }
Change it to look like this:
-
enum { EV_RINGTE = 0 }
This flag is used to get the serial driver to report changes on the input RLSD (ringer) control line under Windows 9X. This undocumented feature allows things to work properly in that environment, but breaks things under Windows 2000.
Keep in mind that if you make this change, your program won't respond to incoming rings under Win32, unless you watch for "RING" messages coming from your modem. (Watching for messages is probably a better way to do it in general, so maybe it's time to change!)
If you are deploying your code on both Windows 2K and Windows 9X, you might want to create a more general purpose solution by determining whether or not to use the EV_RINGTE mask at runtime, based on detection of the O/S type.
Win32Port.cpp
I botched the definition of a loop in this code, and despite the compiler warning, I failed to note the problem until alerted by several readers.
The loop in output_worker() used to start like this:
-
for ( bool done = false ; ; !done ) {
Now it starts like this:
-
for ( bool done = false ; !done ; ) {
Chapter 12
For some reason, the publisher decided to leave this chapter's executable off the CD-ROM. This shouldn't be a big deal, since you ought to be able to build it with the included project file. But, just in case you can't, here is the executable. Note that this is built with debug options turned off.
Chapter 13
There are a few errors that showed up in this project in Visual C++ 6. They are all related to minor changes in header files or the way the compiler parses them.
Win32Term.cpp
In Win32Term::Paint(), a call to SelectObject() needed a cast of the return type before it could be assigned to hOldFont. The line was:
-
HFONT hOldFont = SelectObject( hDC, m_hFont ) ;
It is now
-
HFONT hOldFont = (HFONT) SelectObject( hDC, m_hFont );
Win32Term.h
I use a pragma in this header file to turn off compiler warnings for error C4786, which are unavoidable, and are really pointing to problems in the compiler, not in my code. In VC++ 6, the pragma has to be moved to be ahead of the #include for header file vector. The resulting code now looks like this:
-
//
-
// The vector<vector<>> variables in this class
-
// end up with incredibly long expanded names. This
-
// pragma disables the associated warnings
-
//
-
#pragma warning( disable : 4786 )
-
-
#include <windows.h>
-
#include <vector>
-
using namespace std;
Download changed files
Win32Term.cpp
Win32Term.h
Win32Port.cpp
Win32Port.h
You should be able to build the new executable by coping these files to the correct locations.
Chapter 16
Bill Jacques noticed that the SendSingleFile() function in Zmodem.cpp gets stuck in an infinite loop if the remote end has an allocation problem. He sends an update of the function (as a Word Doc.) Bill wrote a Win32-specific version of the function, so don't try to include this code if you are running in some other environment.
You will have to replace the existing function in Zmodem.cpp.
14 users commented in " Serial Communications: A C++ Developer’s Guide, 2nd Edition "
Follow-up comment rss or Leave a TrackbackI would be grateful if you could send me detail table of contents or some links where I can find it. I need it to make decision to buy this book or not.
@amp:
The good people at Amazon.com will let you look inside the book here:
http://www.amazon.com/Serial-Communications-Developers-Guide-Nelson/dp/0764545701
Just go to the table of contents and you can see what you need. I f you have specific questions about content I'll try to answer them here or in email.
- Mark
Hi Mr Nelson,
I was looking for a way to do ZModem in a Win32 environnement. So I used the information in chapter 12 and chapter 16. Now, my application is working fine.
During the process of testing the application, I had some problem with the ZModem sender.
I finally resolved the problem by adding the line :
in the "SendFileContents" function.
Without that line, then sender/receiver was always stuck after 2 packets. (2048 bytes).
It seems that the driver was not sending the data quick enough...
Do you know why I need to add this line ? Is it a problem with the Win32 driver ? It's because the program was working fine in DOS without this line.
Let me know if you want the project source code so you could post it on your website.
Thanks for your answer and for your very good book.
ssinfod
Here is the function :
@ssinfod:
No, I can't explain the problem. Remember, this code was written back in the Windows 3.1 days, so timing issues on faster processors under Windows 95 and XP are bound to appear.
Dear NelSon,
Currently I'm doing serial communication project by using Windows API in Visual Studio 2008 standard version platform. Because in my project, com port worked in a very high speed (921600 bps), receiver loss data in most of testing time. There is few document related to such high speed. Can you give me some advice on this issue?
Thanks you very much!
[...] Win32Port.h If you are developing for a Windows 2000 target, or for NT 4 with SP3 or later, you will need to modify a single line in Win32Port.h. Around line 76 of this file, you will find a line of code that looks like this: PLAIN TEXT [...]
I am looking for an interrupt driven program for serial communication using RS232 port in visual C++ 2008 version 9 platform.
I would like to send/ receive data and change the status of RTS ,.... I want to be able to change the receive interrupt rutine as ai wish.
Can I find such a program in your book? do you know where I can find/buy this program code?
Thanks,
John
@FJOHN:
I think you should still be able to get the interrupt driven code in the book to work on Visual C++ 2008, although it might take some tweaking.
The problem of course is the platform. This code will only run in an MS-DOS compatibility box, and who knows how well.
The Win32 driver gives you the ability to change the state of RTS, but not at the interrupt level.
- Mark
I am using your source code as an ANSI terminal emulation program to operate a PIC chip device.
The baud rate is 57600 and the response is EXTREMELY SLOW.
Hyperterminal on the other hand is fast and crisp.
I'm not losing received characters but I perceive there is a huge delay. It can take about 5 to 10 seconds before a key press is sent.
Any advice that can assist me in solving this problem would be appreciated.
Thanks
ejoee
@ejoee:
Did you write a Win32 program, or are you running an MS-DOS program in a Windows compatibility box?
- Mark
a Win32 program.
ejoee
@ejoee:
I'm not sure I have a good answer for you.
There are a number of places where your program could be running slow, and the first step is to locate those.
You could start by using the MS-DOS demo program and verify that things work at a reasonable speed. I would then test the Win32 demo program from the book and see how it performs.
Keep in mind that the Windows examples were written for Win95, so they may be running into rendering issues. You should try to determine if the serial port can run at full speed if screen rendering issues are removed - you could do this just dumping character counts to a dialog box, for example.
- Mark
In chapter 12 of your book, you mention a test program to exercise the Win32Port functions, but do not list this in your book. You mention the source code is on the CD.
Could you post, or provide a link to this code?
Thanks
-Harold
@Lost:
The sample program is in the CHAP12 folder of the source CD. Have you checked there?
- Mark
Leave A Reply
You can insert source code in your comment without fear of too much mangling by tagging it to use the iG:Syntax Hiliter plugin. A typical usage of this plugin will look like this:[c]
Note that tags are enclosed in square brackets, not angle brackets. Tags currently supported by this plugin are: as (ActionScript), asp, c, cpp, csharp, css, delphi, html, java, js, mysql, perl, python, ruby, smarty, sql, vb, vbnet, xml, code (Generic). If you post your comment and you aren't happy with the way it looks, I will do everything I can to edit it to your satisfaction.int main()
{
printf( "Hello, world!\n" );
return 1;
}
[/c]