Re: Hex 0D 0A and serial question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Re: Serial port monitoring
    ... if (!characters) return; ... you would not want to use blocking I/O on a serial port. ... I would then have a loop that checks for char in serial buffer. ...
    (microsoft.public.vc.mfc)
  • Re: keybd_event problems.
    ... applications that use it for various things like serial port wedging. ... These don't map to the ascii table at all, ... lower case non language characters? ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: display output from serial port device
    ... If your program fails to open the serial port, ... If you do want parity, restore INPCK, but also add PARENB to ... always get the right number of characters. ...
    (comp.os.linux.development.system)
  • RE: SerialPort read&write members display string value above 127 as "?
    ... Serial Port Class methods of Read and Write default to ASCII code ... namespace EncodeTest1 ... // A Unicode string with two characters outside an 8-bit code ... "This unicode string contains two characters " + ...
    (microsoft.public.dotnet.framework)
  • Re: C-MAX CME8000-BUS problems
    ... If you connect the CME-8000 module directly to the PIC's serial port ... (assuming you take care of the voltage converter circuitry), ... and this takes care of the weird one-wire serial interface that C- ... the characters I sent looped back to me. ...
    (comp.arch.embedded)