Hi,
You still didn't show any code.
What I would do is to create two arrays of type Byte. The first array has
the "standard" data. The second array has the pattern required to insert
the update byte. For example,
Dim Standard(9) As Byte
Standard(0) = &H1F 'or, whatever
Standard(1) = &H2A
Standard(2) = &H32
Standard(3) = &H45
Standard(4) = &H58
Standard(5) = &H60
Standard(6) = &H7E
Standard(7) = &H8C
Standard(8) = &H94
Standard(9) = &HAB
Dim Update(10) As Byte
Update(0) = &H1F 'or, whatever
Update(2) = &H2A 'this leave array index 1 for the "update byte"
Update(3) = &H32
Update(4) = &H45
Update(5) = &H58
Update(6) = &H60
Update(7) = &H7E
Update(8) = &H8C
Update(9) = &H94
Update(10) = &HAB
Then, in your code (somewhere), pseudo:
If INeedToUpdate Then
Update(1) = updatebyte
SerialPort.Writ e(Update)
Else
SerialPort.Writ e(Standard)
End If
Of course, the actual logic will be more complex than this... And, what I've
written here assumes that I understand your protocol -- which may or may not
be true.
This code will send data in the correct order. Logically, nothing can get
out-of-sequence. It does assume that a complete "standard or update" packet
will be sent and cannot be interrupted.
One thing that may be an issue. DOS is a single-tasking environment. Thus,
timing between data sent and received can be maintained very closely. On
the other hand, Windows is multitasking and is far from real-time. In
addition, Visual Studio is multithreaded, which can add its own timing
constraints. I am not sure that you aren't seeing some sort of
command/response timing issue, rather than just something that requires that
data be sent in the correct order. If that is the problem, then the solution
would require a much deeper understanding of the requirements than I have.
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.