Constant serial communication in background?

For issues with communication ports, protocols, etc.
Post Reply
skystrick
Posts: 104
Joined: May 19, 2013 23:25
Location: Florida

Constant serial communication in background?

Post by skystrick »

I'm writing a POS (cash register) program for a friend of mine who runs a small convenience store.

I want the POS to be able to control the gas pumps. The interface for the gas pumps hooks to the computer via a serial port, and constantly sends and receives data (pump authorization request, pre-pay amount, current dollars & gallons, etc.)

Is it possible, in FreeBASIC, for the program to multi-task in the background -- to constantly "listen" to the serial port and receive data from it?

Here's a screenshot (right-click and "View Image" to see the whole thing):
Image

Up at the top, where all the pumps say "Offline", I would want that to be able to change (a) when someone lifts the handle outside to request pump authorization, and (b) to display the constantly-updating dollar amount as they're pumping.

This, as I say, would need to be a multi-tasking background operation, so that the cashier could continue to do other things with the program (i.e. ring up items).

If it makes a difference, I'm using Linux.

Thanks!
TJF
Posts: 3809
Joined: Dec 06, 2009 22:27
Location: N47°, E15°
Contact:

Re: Constant serial communication in background?

Post by TJF »

It shouldn't be a problem to handle serial communication in a thread. Have a look at function family KeyPgThreadcreate.
skystrick
Posts: 104
Joined: May 19, 2013 23:25
Location: Florida

Re: Constant serial communication in background?

Post by skystrick »

TJF wrote:It shouldn't be a problem to handle serial communication in a thread. Have a look at function family KeyPgThreadcreate.
It says threading isn't allowed in -lang qb dialect, which is what I'm using in my program.

Any other options for this?

Thanks!
MichaelW
Posts: 3500
Joined: May 16, 2006 22:34
Location: USA

Re: Constant serial communication in background?

Post by MichaelW »

If you are running on a reasonably fast system you may be able to do everything you need in a loop. All of your input would need to be via polling, so depending on the serial data rate and how much buffering the serial port and keyboard (and mouse?) subsystems provide, there will be an upper limit on the loop period beyond which the program will "lose" input.

Why limit yourself to -lang qb?
Post Reply