Click to See Complete Forum and Search --> : USB Port like COM Port
cgarci60
Jul 25th, 2006, 11:16 AM
Hi guys !
I'm new in the forum and I want to know if it posible simulate USB port like a COM Port ? I have an app that works with a touch screen and a printer, but the PC haven't two COM Ports.
How must to do the comunication with 2 devices?
Someone could help me ?
Thanks in advance.
Al42
Jul 25th, 2006, 02:35 PM
If you want to connect 2 serial devices to a computer you need 2 COM ports (or a serial switch, if they don't have to be connected at the same time). If the computer has USB ports, use USB->serial adapters. The code is the same, just the number of the port will be different - COM5 instead of COM2, for instance.
cgarci60
Jul 27th, 2006, 09:36 AM
Hi Al42 !
I got an USB Adapter and I can instaled properly. If I try to print a document, we haven't any trouble. But when my app try to print, nothing occurs. In Our code, nothing changed.
Question : I need to configured anything else ?
Thanks
cgarci60
Jul 27th, 2006, 03:43 PM
Hi people !
For any reason, my app cant use simultaneously the printer (COM3 like USB Serial Adapter) and Touch screen (COM1). My PC have one Serial Port and one USB Port.
The point is, when I verified the printer configuration, was ok and also in the touch screen configuration. The printer works properly for any document, except with app.
Can somebody help me , and suggest any idea ?
Thanks
namrekka
Jul 28th, 2006, 03:01 AM
The printer works properly for any document, except with app.
How is that "document" print. Is "app" a VB-program. Do you print to a printer or a comm-port?
I verified the printer configuration
How?
You see, your question is not quite clear.
cgarci60
Jul 28th, 2006, 08:56 AM
Hi Namrekka, I 'll try to explain.
I have a VB App that works with touch screen and a terminal printer (like automatic cashier). Both devices need COM ports. The standardt PC have 1 COM port and 2 USB port.
The touch screen use COM1 Port and is instaled properly, because the app response very good to the events.
The printer is instaled in PC using USB Port (simulating a COM3 using
USB Serial Adapter)
When I'm going to print a flat file, the printer receive the data, it go to the buffer and goes on without problem
When I'm going to print using the VB app to print a label, the data go to the buffer and stay there permanetly and nothing it happens.
I suppose that I need configure inside the code something to manage this "simulation"... but I don't know what ?
Thanks.
namrekka
Jul 28th, 2006, 09:36 AM
When I'm going to print a flat file But how?
When the printer is installed in Windows you can use the "Printer" object in VB. It doesn't matter if the printer is physically connected to LPT, COMM or network.
cgarci60
Jul 28th, 2006, 03:39 PM
Namrekka,
I using the Printer object, the app was developed with MSComm1 commands (PortOpen, DSRHolding,etc) and each line to print is manage inside the code (dates, amounts, texts, etc) like a ticket from cashier. When whole line is configurated, is sent to printer to print (with Printer.Print ............. ) but nothing it happens.
I Dont know why not print from app.....
Al42
Jul 28th, 2006, 09:27 PM
Printer.Print goes to the default printer, so you have to configure your printers (in Windows) so that the printer on the USB port is the default printer. But you said that the app requires that the printer be on a COM port - the Printer object doesn't have such a requirement, so if that's how you're printing, you can use any printer Windows can install.
You have to send your "configurated" line to MSComm1.Output to get it to pring on the serial port.
RhinoBull
Jul 29th, 2006, 09:42 AM
Printer.Print goes to the default printer...
By default it prints to default printer. However, you may programmatically assign Printer object to any printer currently configured on your system.
namrekka
Jul 31st, 2006, 04:51 AM
Did you use "Printer.EndDoc"? Is the printer visible in Windows? And how did you print the flatfile?
cgarci60
Jul 31st, 2006, 08:19 AM
Al42,
I'm trying to use MSComm1.Output , but I get an error (invalid use of property) when compile.
Namrekka,
Yes, I use Printer.EndDoc and the printer is visible in Windows XP (set as Default Printer).
namrekka
Jul 31st, 2006, 08:31 AM
Sorry, but I don't understand a thing of it. If the printer shows up in Windows and other app's can print via Windows, why do you use the MSCOMM object?
cgarci60
Jul 31st, 2006, 09:04 AM
Because I have a touch screen in COM1 and the printer needs another COM port so is redirected to USB Port (simulating a COM Port ).
The problem is that by the app not recognize the printer.... and I don't know why ?
namrekka
Jul 31st, 2006, 09:12 AM
If you start up "Notepad", type something and print what happens?
cgarci60
Jul 31st, 2006, 09:16 AM
I did this test (like a flat file), and no problem appear
namrekka
Jul 31st, 2006, 09:23 AM
In your code from your app you don't need any MSCOMM object at all. So delete everything with MSCOMM. Just do:
Printer.Print "Bla bla"
Printer.EndDoc
Then the default printer, same printer as in NotePad before, will print.
cgarci60
Jul 31st, 2006, 10:05 AM
Namrekka,
How know the app that need use the USB Port ? (like COM Port #3 in example ) ?
I use :
MSComm1.Settings = "9600,n,8,1"
MSComm1.CommPort = 3
MSComm1.PortOpen = True
MsComm1.Output = bla...bla...
Can i do to another way ?
Please, I want to learn.
namrekka
Jul 31st, 2006, 10:17 AM
How know the app that need use the USB Port ? (like COM Port #3 in example ) ? How does "NotePad" knows? The printer is installed in Windows and Windows does all the comm-work.
As I told before, remove all the MSComm1 stuf and just try these 2 lines:
Printer.Print "Bla bla"
Printer.EndDoc
cgarci60
Jul 31st, 2006, 11:01 AM
Namrekka,
I removed all MSCOMM commands and replace by Printer.Print
I'm sorry but doesn't work. My app not recognize the printer.
How can is possible ? I don't unsderstand
May be, is somethig about printer configuration ? (Like the Flow Control, Parity, bits per second, etc...)
namrekka
Jul 31st, 2006, 11:51 AM
May be, is somethig about printer configuration ? (Like the Flow Control, Parity, bits per second, etc...)"NotePad" does not use these things as well. Windows does all these controle stuf. Did you try the 2 lines? What error codes do you get?
cgarci60
Jul 31st, 2006, 03:12 PM
Namrekka,
the problem was that in the Printer configuration the variable Flow Control was in None. When I changed it to Hardware, the printer works properly. So I'll try a couple of test and will go on.
Thanks to all.
namrekka
Aug 1st, 2006, 02:48 AM
OK.
Success.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.