DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 7 of 7

Thread: Sending data to a serial/parallel port

  1. #1
    steve g Guest

    Sending data to a serial/parallel port


    The following is sent to the serial port using a DOS Prompt

    c:\>mode com1:300,n,8,1
    c:\>echo "000000000000000000000">com1

    How can I do the same but sending to the parallel port in VB? I'd like to
    be able to send a Ascii combination of my choice to the parallel port if
    possible.

    Many thanks on advance for any help.
    steve g

  2. #2
    Josaz Guest

    Re: Sending data to a serial/parallel port

    try
    printer.print chr(7) + chr(7)
    only work when printer is local to the PC no printserver

    Good Luck.

    "steve g" <vb.@127.0.0.1> wrote in message
    news:3decaaee$1@tnews.web.devx.com...
    >
    > The following is sent to the serial port using a DOS Prompt
    >
    > c:\>mode com1:300,n,8,1
    > c:\>echo "000000000000000000000">com1
    >
    > How can I do the same but sending to the parallel port in VB? I'd like to
    > be able to send a Ascii combination of my choice to the parallel port if
    > possible.
    >
    > Many thanks on advance for any help.
    > steve g




  3. #3
    Dick Grier Guest

    Re: Sending data to a serial/parallel port

    Hi,

    Sending to what?

    You can download IOocx.ocx from my homepage. It allows easy access to
    standard IO ports, including the printer port.

    --
    Richard Grier (Microsoft Visual Basic MVP)

    See www.hardandsoftware.net for contact information.

    Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
    Edition ISBN 1-890422-27-4 (391 pages) published February 2002.



  4. #4
    Steve G Guest

    Re: Sending data to a serial/parallel port


    Many thanks for the responses.

    I just need to send a cash drawer its open command (usually CTRL+K or similar)
    to the parallel port. I think distributing the IOocx.ocx may be a little
    excessive just to achieve this - is there a simpler way?

    I tried:
    Open "LPT1:" For Output As #1
    Print #1, Chr$(11) & vbCrLf
    Close #1

    But the program just hangs for several minutes if there is nothing connected
    to the parallel port and also I've not actually got it trip the drawer yet.


    Thanks
    Steve

    "**** Grier" <****_grier@msn.com> wrote:
    >Hi,
    >
    >Sending to what?
    >
    >You can download IOocx.ocx from my homepage. It allows easy access to
    >standard IO ports, including the printer port.
    >
    >--
    >Richard Grier (Microsoft Visual Basic MVP)
    >
    >See www.hardandsoftware.net for contact information.
    >
    >Author of Visual Basic Programmer's Guide to Serial Communications, 3rd


    >Edition ISBN 1-890422-27-4 (391 pages) published February 2002.
    >
    >



  5. #5
    Dick Grier Guest

    Re: Sending data to a serial/parallel port

    Hi,

    >>

    I just need to send a cash drawer its open command (usually CTRL+K or
    similar)
    to the parallel port. I think distributing the IOocx.ocx may be a little
    excessive just to achieve this - is there a simpler way?

    I tried:
    Open "LPT1:" For Output As #1
    Print #1, Chr$(11) & vbCrLf
    Close #1

    But the program just hangs for several minutes if there is nothing connected
    to the parallel port and also I've not actually got it trip the drawer yet.
    <<

    You could use the SpoolFile example code (Spool.zip) on www.mvps.org/vb.

    --
    Richard Grier (Microsoft Visual Basic MVP)

    See www.hardandsoftware.net for contact information.

    Author of Visual Basic Programmer's Guide to Serial Communications, 3rd
    Edition ISBN 1-890422-27-4 (391 pages) published February 2002.



  6. #6
    Bernie Guest

    Re: Sending data to a serial/parallel port


    "Steve G" <vb.@127.0.0.1> wrote:
    >
    >Many thanks for the responses.
    >
    >I just need to send a cash drawer its open command (usually CTRL+K or similar)
    >to the parallel port. I think distributing the IOocx.ocx may be a little
    >excessive just to achieve this - is there a simpler way?
    >
    >I tried:
    >Open "LPT1:" For Output As #1
    > Print #1, Chr$(11) & vbCrLf
    >Close #1
    >
    >But the program just hangs for several minutes if there is nothing connected
    >to the parallel port and also I've not actually got it trip the drawer yet.
    >
    >
    >Thanks
    >Steve


    Hi,

    Normally, sending characters to a parallel or serial port is easily done
    by
    issuing a

    Shell "cmd /c echo " & myString & " >> LPT1", vbHide

    When I tried to send Chr(11) the result to LPT1 becomes "ECHO is ON" (!).

    However I remember from the old 'batch-file days' some workaround to echo
    special characters, but unfortunatly i don't recall HOW. Maybe there are
    some oldtimers still out there with a little less corrupted memory than mine...

    Bernie

  7. #7
    steve g Guest

    Re: Sending data to a serial/parallel port


    Thanks guys,

    I'll try these options and see what happens.

    Anyone any ideas about sending special characters? I tried the shell (but
    without the drawer connected) and it seems to pass the info reasonably enough
    without hanging but it didn't seem to want to accept special characters.

    Steve


    "Bernie" <magnus.bernroth@rejlers.se> wrote:
    >
    >"Steve G" <vb.@127.0.0.1> wrote:
    >>
    >>Many thanks for the responses.
    >>
    >>I just need to send a cash drawer its open command (usually CTRL+K or similar)
    >>to the parallel port. I think distributing the IOocx.ocx may be a little
    >>excessive just to achieve this - is there a simpler way?
    >>
    >>I tried:
    >>Open "LPT1:" For Output As #1
    >> Print #1, Chr$(11) & vbCrLf
    >>Close #1
    >>
    >>But the program just hangs for several minutes if there is nothing connected
    >>to the parallel port and also I've not actually got it trip the drawer

    yet.
    >>
    >>
    >>Thanks
    >>Steve

    >
    >Hi,
    >
    >Normally, sending characters to a parallel or serial port is easily done
    >by
    >issuing a
    >
    >Shell "cmd /c echo " & myString & " >> LPT1", vbHide
    >
    >When I tried to send Chr(11) the result to LPT1 becomes "ECHO is ON" (!).
    >
    >However I remember from the old 'batch-file days' some workaround to echo
    >special characters, but unfortunatly i don't recall HOW. Maybe there are
    >some oldtimers still out there with a little less corrupted memory than

    mine...
    >
    >Bernie



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center