You are on page 1of 4

Page 1 of 4

Corrections List for Serial Port Complete by Jan Axelson


Last update: 3/12/02

Thanks to alert and helpful readers for pointing these out. If you find others,
please send them to me at jan@lvr.com and I'll add them to the list. This list
is available online at www.lvr.com.

These errors are corrected with each printing of the book, so your copy may have
some or all of these errors corrected.

p 12. (From Denny Diehl)


In Figure 2-1, change
Data (41H)
to
Data (61H)

p. 14. (From Joel Duran)


In Table 2-1's caption, change "0s" to "1s" and change "1s" to "0s".

p. 14, 2nd paragraph (from Kristoffer Willms).


"The number of characters transmitted per second equals the bit rate times the
number of bits in a word." should be "...divided by..." instead of
"...times...".

p. 33 (From Cornel Huth)


Change
The port at 3E0h is never detected.
to
The port at 2E0h is never detected.

p. 41 (From Dan Karmann).


Table 3-2, Address 2, IIR Register: Bits should say "11 if FCR bit 0=1" and
"00 if FCR bit 0=0", not FCR bit 7

p.43
Additional information about the UART’s MCR. In a PC, in enable changing the
state of DTR or RTS by writing to bits 0 or 1 of the MCR, you must first write 8
to the MCR (set bit 3 to 1, enabling the UART’s IRQ line). (If using MSComm,
this is handled automatically.)

p. 52
Change:
comEvDTR. Change at the DTR input.

to:
comEvDSR. Change at the DSR input.

p. 58 (and in the file vb\template\frmMain.frm) (from Ian Pavy)


Change:

'Open the port.


MsComm1.PortOpen = True

to:

'Open the port.


If MSComm1.PortOpen = False then
MsComm1.PortOpen = True
EndIf

p.70 (From Dan Karmann)


Listing 4-2, Sheet 10: The usual XON flow-control character is &H11, not &H12
in the line " 'CommDCP.XonChar = &H12 "

p.71
(and in the FindPorts routine of serport.bas in the template project)
Change:

http://www.lvr.com/files/spcerr.txt 14/06/2006
Page 2 of 4

If SaveCurrentPort = True Then


PortNumber = SavedPortNumber
End If

to:
If SaveCurrentPort = True Then
PortNumber = SavedPortNumber
frmMain.MSComm1.CommPort = PortNumber
If frmMain.MSComm1.PortOpen = False Then
frmMain.MSComm1.PortOpen = True
End If
End If

p.71 (and in the FindPorts routine of serport.bas in the template project)


(from Ian Pavy and Jim Robertson)

Change:

For Count = 1 To 16
frmMain.MSComm1.CommPort = Count
frmMain.MSComm1.PortOpen = True
If Err.Number = 8005 Then
'The port is already open
'The port exists, so add it to the list.
NumberOfPorts = NumberOfPorts + 1
CommPorts(NumberOfPorts) = "COM" & CStr(Count)
ElseIf frmMain.MSComm1.PortOpen = True Then
'If the port opens, it exists.
'Close it and add to the list.
frmMain.MSComm1.PortOpen = False
NumberOfPorts = NumberOfPorts + 1
CommPorts(NumberOfPorts) = "COM" & CStr(Count)
Err.Clear
End If
Next Count

to:

For Count = 1 To 16
frmMain.MSComm1.CommPort = Count
frmMain.MSComm1.PortOpen = True
If Err.Number = 8005 Then
'The port is already open
'The port exists, so add it to the list.
NumberOfPorts = NumberOfPorts + 1
CommPorts(NumberOfPorts) = "COM" & CStr(Count)

'****
'Prevents the SavedPortNumber from being re-opened on exit

If SavedPortNumber = Count Then


frmMain.MSComm1.PortOpen = False
End If
Err.Clear
'****

ElseIf frmMain.MSComm1.PortOpen = True Then


'If the port opens, it exists.
'Close it and add to the list.
frmMain.MSComm1.PortOpen = False
NumberOfPorts = NumberOfPorts + 1
CommPorts(NumberOfPorts) = "COM" & CStr(Count)
Err.Clear
End If
Next Count

p. 101 (From Dan Karmann)

http://www.lvr.com/files/spcerr.txt 14/06/2006
Page 3 of 4
Control+S (13h) pauses output, Control+Q (11h) resumes output.3) Pg. 101, Last
line of last paragraph before Custom Communications should say
"... then RUN ..." instead of "... than RUN ..."

p. 156 (From Dan Karmann).


Next to last paragraph, last sentence: given the bit pattern described in this
paragraph, the byte value should be 80h, not 1 as stated.

p. 171 (from Jagath Ekanayake). Listing 8-1, sheet 13.


Before the line:
End Function
Add this line:
fncInitializeComPort = True

p. 193 (From Dan Karmann)


Fig. 9-5: Vertical axis has 1 less division per major division and the plotted
vertical values do not reflect the values listed in the text (i.e.
the plotted values are lower in value than the text description).

p. 206 (From Dan Karmann).


Fig. 10-1: The rules 1 and 2 should be swapped to match the text later in the
chapter (Pg. 211, Pg. 222). The third rule should be labeled '3', not '2'.

p. 270
(the PollSlave routine of frmMain in the 485net project)
Change:
Buffer = MSComm1.Input

to:
If MSComm1.InBufferCount > 0 Then
Buffer = MSComm1.Input
End If

p. 278. (from Courtney Brown)


To make the program code match the schematic on page 257, on the top Stamp II:
Change:
'Serial receive input
SerialInput con 13
'Direction-control output
TRControl con 15

To
'Serial receive input
SerialInput con 15
'Direction-control output
TRControl con 13

(or change the schematic to match the code.)

Appendix A
See the Serial Port page at http://www.lvr.com for additions and updates to the
Sources list.

***

And here is 16-bit checksum code in VB from Jerry Wingenroth:

Public Function fncAddChecksumToAsciiHexString _


(UserString As String) _
As String

'Calculates a checksum for a string containing


'a series bytes in Ascii Hex format.
'Places the checksum in Ascii Hex format
'at the end of the string.
Dim Count As Integer

http://www.lvr.com/files/spcerr.txt 14/06/2006
Page 4 of 4
Dim Sum As Long
Dim Checksum As Byte
Dim ChecksumAsAsciiHex As String
Dim Temp As String

'Add the values of each Ascii Hex pair:


For Count = 1 To Len(UserString) - 1 Step 2
Sum = Sum + Val("&H" & Mid(UserString, Count, 2))
Next Count
Sum = Not (Sum)
ChecksumAsAsciiHex = Hex$(Sum)
'need to pull the right most two characters from
'ChecksumAsAsciiHex at this point
ChecksumAsAsciiHex = Right(ChecksumAsAsciiHex, 2)
Checksum = CByte("&H" & ChecksumAsAsciiHex)
ChecksumAsAsciiHex = fncByteToAsciiHex(Checksum)
'Add the checksum to the end of the string.
fncAddChecksumToAsciiHexString = UserString & ChecksumAsAsciiHex
End Function

http://www.lvr.com/files/spcerr.txt 14/06/2006

You might also like