Re: More on MSCOMM32.ocx... some problems...
- From: "43fan" <sleap@xxxxxxxxxxxxxx>
- Date: Tue, 14 Mar 2006 10:30:46 -0500
Matthew,
The timer thing seems to work. It takes a touch "long" for the data to
actually get into the form, but it works. Not sure if I can speed the time
up or not. I'll work on that.
I've also seemed to be able to get around the non saving of data that I was
having probs with. If I set the memory variables to the values I want in
the "save" button, it seems to work as well. Not sure why this doesn't work
the same way if I put the assignment code somewhere else in the form.
"Matthew L Reed" <nousenetspam at dead ice dot us> wrote in message
news:uUhDJduRGHA.4384@xxxxxxxxxxxxxxxxxxxxxxx
OnComm fires for different reasons at different times, and not just foris
incoming data. It does fire when data comes in, but one problem I've seen
when people expect the entire data stream to be there when it fires. Thisis
not always the case, as it will fire before everything you are expectingis
in the input buffer. Also, if your code does not clear the input bufferfor
whatever reason, stuff in the buffer will sit there until OnComm firescheck
again. I find it easier and more reliable to use a timer to poll the input
buffer size property, and take action whenever data comes in.
"Neil Waterworth" <spammonkey at microsocks.com> wrote in message
news:uQmMAwJRGHA.4956@xxxxxxxxxxxxxxxxxxxxxxx
Are you saying that OnComm doesn't fire properly as an event? I have a
problem where my app works fine with MSComm in Win2000 with up to 8
simultaneously firing RF barcode scanners into one com port. It doesn't
work at all with XP.
I'd appreciate any further ideas, but will check out your timer idea.
Thanks.
"Matthew L Reed" <nousenetspam at dead ice dot us> wrote in message
news:O$irxX6QGHA.5900@xxxxxxxxxxxxxxxxxxxxxxx
My solution is to use a timer that polls the port on a regular basis,
sticks the input into a variable or property, and takes action once a
certain amount of data has been received and validated. You have to
tofor valid input, interrupted data strings, etc. Then validate the date
commake sure it is what you expected, and throw it out if not. As you are
probably finding, code like this is not always that simple - the basic
code below can't handle invalid input, truncated data streams, etc.
"43fan" <sleap@xxxxxxxxxxxxxx> wrote in message
news:qNSdnS1WRsEWy43ZRVn-rA@xxxxxxxxxxxxxxxxx
Matt,
Sent you an email. I think that's the problem, I need a trigger that
only
happens when there's data coming "in" through the port. That's how it
works
in the basic program originally written to do this.
Here's the original Basic code:
2240 OPEN "COM1:9600,N,8,1,CS,DS,CD" FOR RANDOM AS #1
2245 X = 10
2340 COM(1) ON: COMCK = 0
2360 ON COM(1) GOSUB 2490
2410 GOTO 2340 'END OF ON COM LOOP
2490 COMCK = 1: INPUT #1, A$
2497 SOUND 800, 8 ' BEEP
2530 COM(1) OFF
2570 RD% = ABS(VAL(A$) * 1000)
2590 CLOSE #1
Basically all I need is the new VFP form to "emulate" this.... *shrug*
Thanks!
Shawn
"Matthew Reed" <matty don't send me any freaking spam at zootal dot
wayremove the don't send me any freaking spam> wrote in message
news:eWtubQwQGHA.3972@xxxxxxxxxxxxxxxxxxxxxxx
Hi, Shawn, the OnComm event triggers at various times, not just whenthere
data
comes in. That is why in the OnComm event you need to check to see if
is anything in the input buffer before you try to do anything. That
regularif
it triggers and no data is coming in, nothing happens.
* InBufferCount will b 0 if no data has come in
IF ThisForm.oleComm.InBufferCount > 0
* Do stuff
ENDIF
You might also consider having a timer poll the comm port on a
thebasis
(like several times a second) instead of using OnComm. It's moreand
reliable
since OnComm fires for different events, not just incoming data.
"43fan" <sleap@xxxxxxxxxxxxxx> wrote in message
news:ifSdnbmGpJb5sZLZnZ2dnUVZ_tGdnZ2d@xxxxxxxxxxxxxxxxx
Well, I thought everything was working ok, but it's not.
It's almost as if I'm getting double readings, or, well, or
something...
here's what happens, and not always exactly the same result.
I have setup and opening of com port in the form init event.
In the OnComm event for the control, I have code to "collect" the
data
field,put it into the field I'm currently in on the screen. Sometimes it
gets
it,
sometimes it doesn't. Sometimes it gets the data, goes to the next
agets data there, and skip to the field after.
"Getting" of data should be controlled with a foot pedal. The user
has
readingdigital probe they use to measure tire depth. When the probe is
placed
into/onto the tire, they press a foot pedal and it sends the depth
to the com port. It seems as though this isn't what's activating
likeOnComm
event though, or at least not all that's activating it, because
thoughI
said,
it'll sometimes "take" a reading on the very next field, even
LostFocusthe
foot pedal hasn't been depressed again.
I tried turning the com port on and off in the GotFocus and
events, but that doesn't work either.
Help!??
Thanks!
.
- Follow-Ups:
- Re: More on MSCOMM32.ocx... some problems...
- From: Matthew Reed
- Re: More on MSCOMM32.ocx... some problems...
- References:
- More on MSCOMM32.ocx... some problems...
- From: 43fan
- Re: More on MSCOMM32.ocx... some problems...
- From: Matthew Reed
- Re: More on MSCOMM32.ocx... some problems...
- From: 43fan
- Re: More on MSCOMM32.ocx... some problems...
- From: Matthew L Reed
- Re: More on MSCOMM32.ocx... some problems...
- From: Neil Waterworth
- Re: More on MSCOMM32.ocx... some problems...
- From: Matthew L Reed
- More on MSCOMM32.ocx... some problems...
- Prev by Date: Re: grid recordmark
- Next by Date: Re: grid recordmark
- Previous by thread: Re: More on MSCOMM32.ocx... some problems...
- Next by thread: Re: More on MSCOMM32.ocx... some problems...
- Index(es):
Relevant Pages
|