StampDaq using MSComm
Archiver
Posts: 46,084
Has anyone converted stampdaq to use MSComm? I've been trying for a while
now but I just can't wrap my brain around it. Mostly I just can't figure out
how to handle the buffer decently. Tried using the X characters received
event but unless I get an event every character, I could be left hanging
with a portion of a command string sitting in the buffer and me not knowing
it (e.g. 15 character limit for event, last batch only being 12 characters).
If I set it to 1 character then I won't be finished parsing the characters I
got before the event fires again....
Anyone have/know of an example for parsing that kind of input?
Heh, if the stampdaq control were public I'd just use that, but its not [noparse]:([/noparse]
now but I just can't wrap my brain around it. Mostly I just can't figure out
how to handle the buffer decently. Tried using the X characters received
event but unless I get an event every character, I could be left hanging
with a portion of a command string sitting in the buffer and me not knowing
it (e.g. 15 character limit for event, last batch only being 12 characters).
If I set it to 1 character then I won't be finished parsing the characters I
got before the event fires again....
Anyone have/know of an example for parsing that kind of input?
Heh, if the stampdaq control were public I'd just use that, but its not [noparse]:([/noparse]
Comments
program as an exercise that behaved in a similar fashion. It helps to
have a specific terminating character. During the OnComm event you grab
the character and look at it. If it's the terminator then you know that
you have a token (command string). If it's not the terminating char,
you add the character to the token. Once you've received received a
token it's easy to do a compare and deal with it.
-- Jon Williams
-- Parallax
PS: No, I don't have that code. I did it as a work project for a former
employer and the code stayed there.
Original Message
From: pm [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=RLkeAAbgWZ593hYNy6N4MZVjN2qPGZ5Oa93HdQAfwH90qp9Hy3XghMvQ1nfVG7XfLW2ljKg]pmeloy@s...[/url
Sent: Thursday, July 31, 2003 3:27 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] StampDaq using MSComm
Has anyone converted stampdaq to use MSComm? I've been trying for a
while now but I just can't wrap my brain around it. Mostly I just can't
figure out how to handle the buffer decently. Tried using the X
characters received event but unless I get an event every character, I
could be left hanging with a portion of a command string sitting in the
buffer and me not knowing it (e.g. 15 character limit for event, last
batch only being 12 characters).
If I set it to 1 character then I won't be finished parsing the
characters I got before the event fires again....
Anyone have/know of an example for parsing that kind of input?
Heh, if the stampdaq control were public I'd just use that, but its not
[noparse]:([/noparse]
To UNSUBSCRIBE, just send mail to:
basicstamps-unsubscribe@yahoogroups.com
from the same email address that you subscribed. Text in the Subject
and Body of the message will be ignored.
Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/
This message has been scanned by WebShield. Please report SPAM to
abuse@p....
I'd somehow erased my global declaration of the "row" variable. Kept
overwriting the labels and I thought it was something about handling the
stream that was goofy...
So basically, its the same thing as stampdaq with two differences - The
event handler is a seperate sub from the part that parses and sends the data
to the spreadsheet. Between the event and writing to the sheet is where I
chop up the incoming stream into command lines - separated by CRs.
Private Static Sub ExtractCommandLine(data As String)
Dim i As Integer
Dim commandBuffer, line As String
commandBuffer = commandBuffer + data
While InStr(commandBuffer, Chr$(13))
i = InStr(commandBuffer, vbCr)
line = Left$(commandBuffer, i - 1)
DataReady (line)
commandBuffer = Right$(commandBuffer, Len(commandBuffer) - i - 1)
Wend
End Sub
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Thursday, July 31, 2003 2:33 PM
Subject: RE: [noparse][[/noparse]basicstamps] StampDaq using MSComm
> It's not too tough -- when StampDAQ first came out I created a little
> program as an exercise that behaved in a similar fashion. It helps to
> have a specific terminating character. During the OnComm event you grab
> the character and look at it. If it's the terminator then you know that
> you have a token (command string). If it's not the terminating char,
> you add the character to the token. Once you've received received a
> token it's easy to do a compare and deal with it.
>
> -- Jon Williams
> -- Parallax
>
> PS: No, I don't have that code. I did it as a work project for a former
> employer and the code stayed there.