Re: Hex 0D 0A and serial question
- From: "Dick Grier" <dick_grierNOSPAM@.msn.com>
- Date: Thu, 29 Mar 2007 11:56:15 -0600
Hi,
I included some code in my first post, to indicate send method. There aren't
many secrets in sending data to a serial port using MSComm1.
<<
Chr(2) & Out1$ & Chr(13) & Out2$ &
Chr(13) & ChkSum & Chr(4)
The "secrets" aren't secrets -- they consist of, "How the heck to I create
data to send that are meaningful?"
STX (standard start of packet delimeter), some data in Out1$ & Out2$ + vbCr
(is this correct?), checksum, EOT character (standard end of packet
delimiter).
You say the result you see is:
00000000 02 0D 0A 31 32 33 0D 0A 34 35 36 30 0D 0A 41 31 31 54
00000010 65 0D 0A 73 74 30 33 0D 0A 3A 3A 04 0D 0A 02 0D 0A 31
The code above will have that "result" if Out1$ consists of vbCrLf & "123" &
vbCrLf & "4560" & vbCrLf & " A11Te" & vbCrLf and Out2$ consists of "st03" &
vbCrLf & "::"
However, I'm making an arbitrary assumption about the content of the
variables Out1$ and Out2$. They actual data may be partitioned differently.
To reiterate, vbCrLf are Chr(13) & Chr(10) or 0D0A when displayed as hex
data. Your code (somewhere) is adding these characters to Out1 and Out2.
Code to create the data that you seek might look like this:
Dim Buffer As String
Buffer = Chr(2) & vbCrLf & "123456" & vbCrLf & "0A11Te" & vbCrLf & "st03::"
& Chr(4) & vbCrLf 'etc
So, I believe you have placed some vbCrLf characters at the wrong point in
the variables Out1 and Out2.
Now, I presume that your interpretation of the packet structure (in the code
fragment that I quoted at the top of this reply) is incorrect. That is, the
EOT character that terminates the packet is followed by a Chr(13) & Chr(10),
not just a Chr(13) -- that is what "seems to be indicated" by the output
that you show for your DOS program. You don't show how the checksum is
calculated, nor over what values it is calculated, so I cannot tell which
data in the above Buffer actually comprise it -- though my guess would be
that the two "::" characters actually are a 16-bit checksum.
Dick
--
Richard Grier, MVP
Hard & Software
Author of Visual Basic Programmer's Guide to Serial Communications, Fourth
Edition,
ISBN 1-890422-28-2 (391 pages, includes CD-ROM). July 2004, Revised March
2006.
See www.hardandsoftware.net for details and contact information.
.
- References:
- Hex 0D 0A and serial question
- From: Rhonda
- Re: Hex 0D 0A and serial question
- From: Jim Mack
- Re: Hex 0D 0A and serial question
- From: Rhonda
- Re: Hex 0D 0A and serial question
- From: Rhonda
- Re: Hex 0D 0A and serial question
- From: Dick Grier
- Re: Hex 0D 0A and serial question
- From: Rhonda
- Hex 0D 0A and serial question
- Prev by Date: Re: vb6 -v- Net!
- Next by Date: Re: International MsgBox button captions
- Previous by thread: Re: Hex 0D 0A and serial question
- Next by thread: How to show progress bar during the files or folders deletion
- Index(es):
Relevant Pages
|