AdvancedHMI Software

General Category => Open Discussion => Topic started by: aquilmustafa on May 30, 2016, 06:21:14 AM

Title: Zebra Printer with AHMI
Post by: aquilmustafa on May 30, 2016, 06:21:14 AM
Hi,

I have AHMI running on a Machine communicating with Clx via Ethernet port. Tricky part is that i want to print the String to Zebra Barcode printer via Ethernet on 9100 port when i receive a command from PLC.
OR
Is there a way to close port no 44818 and open 9100 send Printer data and close 9100 and restart 44818 for communicating with PLC

How is that possible please help me 
Title: Re: Zebra Printer with AHMI
Post by: Archie on May 30, 2016, 09:16:08 AM
It's not necessary to close 44818. You can have multiple Ethernet ports open at the same time.
Title: Re: Zebra Printer with AHMI
Post by: aquilmustafa on May 30, 2016, 09:42:49 AM
Hey Archie,
Thanks for the prompt reply. Could you please guide me as to how it could be done I've been trying this method

Dim client As New System.Net.Sockets.TcpClient

            client.Connect(ip, port)

            'Write ZPL String to Connection
            Dim writer As New System.IO.StreamWriter(client.GetStream())
            writer.Write(ZPLString)
            writer.Flush()

            'Close Connection
            writer.Close()
            client.Close()


Thanks for the reply
Title: Re: Zebra Printer with AHMI
Post by: Godra on May 30, 2016, 09:45:36 AM
Until Archie provides some solution, take a look at this and see if that might help:

http://stackoverflow.com/questions/16063822/i-am-trying-to-print-via-ethernet-on-a-thermal-printer-in-vb-net
Title: Re: Zebra Printer with AHMI
Post by: aquilmustafa on May 30, 2016, 09:52:33 AM
Hey Godra,
Thanks for the link.
This program when written in a different solution prints out perfectly. Only problem comes when trying to Print through AHMI.
Title: Re: Zebra Printer with AHMI
Post by: Archie on May 30, 2016, 10:21:01 AM
See if this works:
Code: [Select]
        Dim endPoint As System.Net.IPEndPoint
        endPoint = New System.Net.IPEndPoint("192.168.0.100", 9100)

        Using TCPSocket As New System.Net.Sockets.Socket(endPoint.AddressFamily, System.Net.Sockets.SocketType.Stream, System.Net.Sockets.ProtocolType.Tcp)
            TCPSocket.Connect(endPoint)

            TCPSocket.Send(System.Text.Encoding.ASCII.GetBytes("Text to send"))
        End Using
Title: Re: Zebra Printer with AHMI
Post by: aquilmustafa on May 30, 2016, 10:27:35 AM
 :) Thanks a Lot Archie,

It's working..
Title: Re: Zebra Printer with AHMI
Post by: bachphi on September 29, 2018, 10:17:46 PM
I am just starting with a ZT410. I am looking for some vb samples to print ZPL code directly using USB connection.
Would you have some codes to share. Thanks
Title: Re: Zebra Printer with AHMI
Post by: Archie on September 30, 2018, 05:44:12 AM
I made a new topic with some sample code to show how I once did this. It did required a fair amount of code to do, but the code I posted is mostly re-usable.

https://www.advancedhmi.com/forum/index.php?topic=2209.0