We have a Zebra QLn420 label printer and I am writing a .Net application to allow the user to scan an item, process it through our system, create a shipping label, then send it in a .ZPL file to the Zebra label printer. Where I'm running into trouble is getting the VB.Net application connected to the Zebra label printer.

The application is run on a wearable Motorola WT41N0 wearable terminal, and the terminal is connected to the printer through Bluetooth. I can see on the terminal the two devices are indeed connected, the port it is connected through (COM9), and the baud rate (57600).

This is a new experience for me, so forgive me for missing anything obvious, but here is the code I am currently using to connect.

Try
    PrinterSerial = New IO.Ports.SerialPort(Portname, 57600, IO.Ports.Parity.None, 8, IO.Ports.StopBits.One)
    AddHandler PrinterSerial.DataReceived, AddressOf getPrinterSerialData
    PrinterSerial.Open()
Catch ex as Exception
    MsgBox(ex.tostring)
End Try

The error is occurring on the PrinterSerial.Open() line with the error "The port 'COM9' does not exist.'

Any suggestions or thoughts would be very helpful. Thank you!

Are you sure it's connected through "COM9"? (devices and printers >> printer properties >> ports), if yes then add this code before opening the serial port

PrinterSerial.DtrEnable = True
PrinterSerial.RtsEnable = True

Reference : Click Here

I added the code and I am still receiving the same error. I'm beginning to think this may not work as intended...the printer is connected through bluetooth via the terminal, and the terminal is remotely connected to our Windows 2012 server where the app resides. Would it be possible that the "COM9" port that the printer is connected to on the terminal is not the same "COM9" the app is looking for (IE: the app is trying to connect to "COM9" on the app server instead of "COM9" on the terminal)? If so, is there a way to get around this?

Thank you, but unfortunately I'm unable to link that to my issue. It would seem the main issue has become that I need to be able to see the "COM9" port that the wearble terminal is connected to the wireless printer too through bluetooth from the server where the application actually resides. It seems as though when trying to open "COM9", the application is looking to open "COM9" on the app server, which is NOT where the printer is connected to.

Btw what is your portname in runtime? (msgbox(portname))

My apologies, the variable Portname contains the string "COM9"

Ok so you are assuming it's COM9, to be sure add this code and tell me what happens

dim List As New ListBox
List.items.addRange(IO.Ports.SerialPort.GetPortNames)
for each item In List.Items
msgBox(item)
next

As suspected, it is only pulling the COM ports for the server and not for the wearable terminal running the application. Listing all the ports with the code you so kindly posted above only yielded "COM1", and no other results. I can plainly see that "COM9" is the port on the wearable terminal that the printer is connected to, but obviously the server that I am connecting to remotely is not pulling that information.

Is there anyway to access the COM ports on the wearable terminal while remotely connected to the server? Even so, there will be 8 of these wearable terminals with different user logins all running the same application, there would need to be some way to differentiate "COM9" for user 1 from user 2.

Since your printer is on a network and inaccessible through ports you are left with one option, you should target the ip address of that printer so don't use a serialport because you can't assign a printer's ip as a portname.
I highly recommend you to read the link cgeier gave, your answer is there.
gd luck.

I can do it through an IP address over our wireless connection from the wearable to the wireless printer, but we were hoping to find some way to allow us to utilize the bluetooth connection. I suppose that using the IP address is the best/only way to go at this point if there is no way for the remote desktop session to pass the devices connected to it to the server when logging in. Thanks for you help, it is much appreciated!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.