FoxPro 2.5 DOS COM Port I/O Question 
Author Message
 FoxPro 2.5 DOS COM Port I/O Question

I am writing a program in Fox 2.5 for DOS to run in a hand held computer

with a serial wand scanner attached.  I want to activate the scanner,
and allow the user to scan a series of bar codes.  When scanning has
been completed, I want them to be able to press a key on the computer
keyboard and have the function stop.

I am using the FOPEN('COM1,0) command to open the serial port.  I then
create a loop containing the FGETS command to get the data from the
scanner.  This works great except that I am always sitting on the FGETS
statement waiting for more data and cannot see keystrokes from the
keyboard.

I have tried using the ON KEY function, but the key strokes do not
interrupt the FGETS function.  After completing the next scan, the ON
KEY routine is processed.  I'm open for suggestions on how to resolve
this problem.

When this application is in use, the user is away from the office.  I
could obviously put a special 'QUIT' bar-code on the hand held and scan
that when scanning is complete, but every other selection on the hand
held is via the keyboard, and I would like to follow the same
conventions if possible.



Sat, 13 Jan 2001 03:00:00 GMT  
 FoxPro 2.5 DOS COM Port I/O Question
why don't you use inkey() within the loop to check for keystokes?



Quote:
> I am writing a program in Fox 2.5 for DOS to run in a hand held computer

> with a serial wand scanner attached.  I want to activate the scanner,
> and allow the user to scan a series of bar codes.  When scanning has
> been completed, I want them to be able to press a key on the computer
> keyboard and have the function stop.

> I am using the FOPEN('COM1,0) command to open the serial port.  I then
> create a loop containing the FGETS command to get the data from the
> scanner.  This works great except that I am always sitting on the FGETS
> statement waiting for more data and cannot see keystrokes from the
> keyboard.

> I have tried using the ON KEY function, but the key strokes do not
> interrupt the FGETS function.  After completing the next scan, the ON
> KEY routine is processed.  I'm open for suggestions on how to resolve
> this problem.

> When this application is in use, the user is away from the office.  I
> could obviously put a special 'QUIT' bar-code on the hand held and scan
> that when scanning is complete, but every other selection on the hand
> held is via the keyboard, and I would like to follow the same
> conventions if possible.



Sun, 14 Jan 2001 03:00:00 GMT  
 FoxPro 2.5 DOS COM Port I/O Question
I don't understand how inkey() can solve my problem.  Both inkey() and fgets()
wait for input of a particular type.  I guess what I am realy looking for is
the ability to wait for either input from the COM port or the keyboard.  If I
get data from the COM port, I need to process that data, if I get information
from the keyboard, I need to process that data too.

If the fgets() had the same timeout ability that is present with inkey(), then
I would have a possible solution to the problem.

Quote:

> why don't you use inkey() within the loop to check for keystokes?



> > I am writing a program in Fox 2.5 for DOS to run in a hand held computer

> > with a serial wand scanner attached.  I want to activate the scanner,
> > and allow the user to scan a series of bar codes.  When scanning has
> > been completed, I want them to be able to press a key on the computer
> > keyboard and have the function stop.

> > I am using the FOPEN('COM1,0) command to open the serial port.  I then
> > create a loop containing the FGETS command to get the data from the
> > scanner.  This works great except that I am always sitting on the FGETS
> > statement waiting for more data and cannot see keystrokes from the
> > keyboard.

> > I have tried using the ON KEY function, but the key strokes do not
> > interrupt the FGETS function.  After completing the next scan, the ON
> > KEY routine is processed.  I'm open for suggestions on how to resolve
> > this problem.

> > When this application is in use, the user is away from the office.  I
> > could obviously put a special 'QUIT' bar-code on the hand held and scan
> > that when scanning is complete, but every other selection on the hand
> > held is via the keyboard, and I would like to follow the same
> > conventions if possible.



Mon, 15 Jan 2001 03:00:00 GMT  
 FoxPro 2.5 DOS COM Port I/O Question
OK.
Just asking. What is the value of feof() when there is no data. You could
check feof() before doing a fgets(). If data exists then read else check
for keyboard input.



Quote:
> I don't understand how inkey() can solve my problem.  Both inkey() and
fgets()
> wait for input of a particular type.  I guess what I am realy looking for
is
> the ability to wait for either input from the COM port or the keyboard.
If I
> get data from the COM port, I need to process that data, if I get
information
> from the keyboard, I need to process that data too.

> If the fgets() had the same timeout ability that is present with inkey(),
then
> I would have a possible solution to the problem.



Mon, 15 Jan 2001 03:00:00 GMT  
 FoxPro 2.5 DOS COM Port I/O Question
FEOF() always reports .T. if the open file is a Communications Port even if
there is data in the buffer.
Quote:

> OK.
> Just asking. What is the value of feof() when there is no data. You could
> check feof() before doing a fgets(). If data exists then read else check
> for keyboard input.



> > I don't understand how inkey() can solve my problem.  Both inkey() and
> fgets()
> > wait for input of a particular type.  I guess what I am realy looking for
> is
> > the ability to wait for either input from the COM port or the keyboard.
> If I
> > get data from the COM port, I need to process that data, if I get
> information
> > from the keyboard, I need to process that data too.

> > If the fgets() had the same timeout ability that is present with inkey(),
> then
> > I would have a possible solution to the problem.



Tue, 16 Jan 2001 03:00:00 GMT  
 FoxPro 2.5 DOS COM Port I/O Question
Does anyone else have any ideas.  This seems that it should be solvable, but I've
run out of ideas.
Quote:

> FEOF() always reports .T. if the open file is a Communications Port even if
> there is data in the buffer.


> > OK.
> > Just asking. What is the value of feof() when there is no data. You could
> > check feof() before doing a fgets(). If data exists then read else check
> > for keyboard input.



> > > I don't understand how inkey() can solve my problem.  Both inkey() and
> > fgets()
> > > wait for input of a particular type.  I guess what I am realy looking for
> > is
> > > the ability to wait for either input from the COM port or the keyboard.
> > If I
> > > get data from the COM port, I need to process that data, if I get
> > information
> > > from the keyboard, I need to process that data too.

> > > If the fgets() had the same timeout ability that is present with inkey(),
> > then
> > > I would have a possible solution to the problem.



Fri, 19 Jan 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. FoxPro 2.5 - writing to COM ports.

2. FoxPro 2.5/DOS and OS/2 WARP Pains

3. ?How to program Serial Port with Foxpro 2.5 for Dos

4. A couple of FoxPro 2.5 (DOS) questions...

5. Converting FOXPRO 2.5 DOS to 2.6 WIN question...

6. URGENT!!! FOXPro 2.5 DOS Question

7. Foxpro 2.5 for DOS - Y2K and new PC questions

8. Blast from the past - FOXR.EXE question FOXPRO 2.5 DOS

9. FP DOS and com port

10. Foxpro 2.5 and OS/2 2.11 problems

11. Foxpro Win 2.5 under OS/2 problems

12. FoxPro 2.5 for Windows under OS/2

 

 
Powered by phpBB® Forum Software