Results 1 to 23 of 23

Thread: USB Port like COM Port

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    USB Port like COM Port

    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.

  2. #2
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: USB Port like COM Port

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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

  4. #4

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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

  5. #5
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    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.

  6. #6

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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.

  7. #7
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    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.

  8. #8

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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.....

  9. #9
    PowerPoster
    Join Date
    Feb 2006
    Location
    East of NYC, USA
    Posts
    5,691

    Re: USB Port like COM Port

    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.
    The most difficult part of developing a program is understanding the problem.
    The second most difficult part is deciding how you're going to solve the problem.
    Actually writing the program (translating your solution into some computer language) is the easiest part.

    Please indent your code and use [HIGHLIGHT="VB"] [/HIGHLIGHT] tags around it to make it easier to read.

    Please Help Us To Save Ana

  10. #10

  11. #11
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    Did you use "Printer.EndDoc"? Is the printer visible in Windows? And how did you print the flatfile?

  12. #12

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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).

  13. #13
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    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?

  14. #14

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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 ?

  15. #15
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    If you start up "Notepad", type something and print what happens?

  16. #16

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    I did this test (like a flat file), and no problem appear

  17. #17
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    In your code from your app you don't need any MSCOMM object at all. So delete everything with MSCOMM. Just do:
    [VB]
    Printer.Print "Bla bla"
    Printer.EndDoc
    [/VB]
    Then the default printer, same printer as in NotePad before, will print.

  18. #18

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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.

  19. #19
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    Quote Originally Posted by cgarci60
    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:
    [vb]
    Printer.Print "Bla bla"
    Printer.EndDoc
    [/vb]

  20. #20

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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...)

  21. #21
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    Quote Originally Posted by cgarci60
    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?

  22. #22

    Thread Starter
    New Member
    Join Date
    Jul 2006
    Posts
    14

    Re: USB Port like COM Port

    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.

  23. #23
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: USB Port like COM Port

    OK.
    Success.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width