I have some simle sketch and I made also a simble vb6 application, but something is not right about serial output from the Arduino side, or maybe I wrong?
No experience with VB6; if you post it here, someone can have a look at it; maybe it's obvious.
I wanted to suggest that your report your post and ask it to be moved to the Interfacing w/ Software on the Computer section; but I see that that already has happened.
sterretje:
Read till you receive a '\n'. Next print it.
No experience with VB6; if you post it here, someone can have a look at it; maybe it's obvious.
I wanted to suggest that your report your post and ask it to be moved to the Interfacing w/ Software on the Computer section; but I see that that already has happened.
Okay, I aready have a topic on VBForums opened, but I will post the VB6 code here too...and, yes I see that my post was moved there, good choice!
Private Sub comRS232_OnComm()
Dim vrBuffer As String
Dim lgFwV As Long
Dim lgFwDate As Long
Dim lgFwTime As Long
comRS232.InputLen = 0
vrBuffer = ""
vrBuffer = comRS232.Input
lgFwV = InStr(vrBuffer, "FWVER=")
lgFwDate = InStr(vrBuffer, "DATE=")
lgFwTime = InStr(vrBuffer, "TIME=")
If lgFwV > 0 Then
lblFwVer.Caption = Mid$(vrBuffer, lgFwV + 6, 3)
End If
If lgFwDate > 0 Then
lblFwDate.Caption = Mid$(vrBuffer, lgFwDate + 5, 11)
End If
If lgFwTime > 0 Then
lblFwTime.Caption = Mid$(vrBuffer, lgFwTime + 5, 8)
End If
Debug.Print vrBuffer
txtSerial.Text = txtSerial.Text + vrBuffer
txtSerial.SelStart = Len(txtSerial.Text)
Exit Sub
End Sub
I don't recall how VB5 and VB6 worked very well now, but I did use it for some time. I think the OnComm event was run whenever the GUI had a chance to test if the serial buffer had data available. The OnComm event should be used to empty the serial buffer each time the VB dispatch loops through the events.
So I think you need to collect the chunks of data from as many OnComm events as it takes until you have a command line.
The way I define commands nowadays is probably based on what I learned back then. To me, a command starts with the character after a newline ("\n"), and ends with a newline. Once I have a command line I can check if it is valid and then process it.
I recall using lots of string functions for testing the commands and chomping out data.
The modern way to do this is to have the Arduino output JSON and then the computer can decode that into a database-ish object (e.g. Python's Dictionary object).