-
Serial data strings
I'm trying to emulate an old piece of DOS software with a newer VB
version that I can modify.(while learning VB serial communications)
So I have been looking at the serial output of the old software with a RS232
monitor as in this sample: Like: 02 0D 0A 31 32 33 34 35 36 0D 0A(SOT CR LF 123456 CR LF). The code
I've created produces "31 0D 0A 32 33 34 0D 0A 35 36". I'm trying to
understand how to get the SOT CR LF in the correct places.
I'm having trouble finding a simple explanation of doing this from scratch.
Is this related to a Checksum routine possibly?
Code:
Private Sub cmdTest_Click()
Dim OutTask$
Dim Textstr$
OutTask$ = "123456"
TXString = OutTask$
frmMain.MSComm1.PortOpen = True
If Index = 0 Then
frmMain.MSComm1.Output = TXString
End If
If frmMain.MSComm1.PortOpen = True Then
frmMain.MSComm1.PortOpen = False
End If
End Sub
Any suggestions appreciated
-
Re: Serial data strings
The serial data stream is the 11 characters SOT CR LF 123456 CR LF. Their hex values are 02 0D 0A 31 32 33 34 35 36 0D 0A.
What you want (no need to use 2 string variables) is
Code:
TXString = Chr$(2) & vbCR & vbLF & "123456" & vbCR & vbLF
frmMain.MSComm1.PortOpen = True
If Index = 0 Then
frmMain.MSComm1.Output = TXString
End If
No idea what Index is, since you didn't define it in the sub.