HOW TO DETERMINE with vb WHETHER LPT1 PORT CAN BE OPENED without freezing my application

A

Avi

Hello to all the experst,

The following paragraph is an introduction to the setup in which I
experience a an everlasting problem that I hope the expertise on the
part of those reading this e-nail will help.

PROBLEM STORY :

I'm currently working on buliding a vb Point of Sale application, and
I'm very close to the end. The end product software is to be used by
different clients on their respective machines. To each of those
machines which a special printer designed to print receipts (3.14"
wide receipts) will be connected. Each printer, aside from being
connected to the machine in which the software will rin, will be
connected to a metal box (cash drawer) that will open upon getting a
signal from a telephone line connected from the printer to the drawer.
To bw more specifix, the vb code will need to print some special
string that will direct the printer to send a signal to the drawer to
be opened, such as at the end of a sales transaction when the cashier
prints out the receipt and exchanges money with the customer. I do
have such printer and drawer that work fine. The printer works just
like any other printer. At the end of each sales transaction, I
produce a report which I then print on an Epson Printer (the point of
sale printer). Immediately after executing the line reponsible for
printing the receipt, the code is executing the following 3 lines of
code :

Open "LPT1" For Output As #1
Print #1, Chr(27) & Chr(112) & Chr(0) & Chr(25) & Chr(250)
Close #1

Those lines are passed to the printer and the printer recognizes the
special combination of characters as a signal to open the drawer,
which works fine.

This whole scenarion is successful so long that the printer is
connected to the machine where the code is. The problems begin when I
run the same code of printing and openning the drawer from another
machine in a private network. In this private network setup, all the
machines are able to print anything using the POS printer in virtue of
sharing the printer, but if any of the machines NOT DIRECTLY connected
to the printer tries to send the printer a signal through the above
mentioned 'Open "LPT1" For Output As #1... snippet of code, the
appliation freezes and the only way to extricate the computer out of
this state is to 'kill' the application with Windows Task Manager.

While this private network setup is not going to be practical, I use
it for the purpose of testing cases when a machine has a printer but
is not connected to a drawer. So far, as I explained above, the
application freezes if it tries to use a darwer that does not really
exist. The private network with the is someewhat a simulation of such
scenarion. In terms of the private network I described above,only one
machine can open the drawer that is connected to the printer -- the
machine that is DIRECTLY CONNECTED to the printer, call it machine A.
All the other machines in the private network sharing the printer of
machine A through a WORKGROUP netweork setup can not open the drawer
-- when attempting to do so, the respective execution of the point of
sale software brings about a 'freeze'.


WHAT I WOULD LIKE TO DO:

In the context of the point of sale application, I would like to be
able to print receipts from any computer in the private network, but
when it comes to openning the drawer, I would like to include a piece
of code in VB that will determine if a given machine is connected to a
printer that is connected, in turn, to a drawer. It all comes down to
DETERMINING IF a given MACHINES on the private network CAN OPEN the
DRAWER.

The 3 lines of code sending the signal to the printer to open the
drawer is where the problem is. In the case when the application
freezes, I think those lines are sent to the port of the machine on
which the code runs, NOT to the machine where that port can listen and
act according to the signal to open the drawer. So if that is true,
which I'm not really sure about it, then the machine running the code
needs to check the port (LPT1) on its machine and see if the relevant
(i.e., printer and/or drawer) device is connected.



thanks

avi
 
J

Jim

My expert opinion is that you should send this query to a Windows newsgroup.
While I don't know how to open a remote printer, it would seem to be more
complicated than your piece of code.

Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top