Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Read/write an USB printer

776 views
Skip to first unread message

Gerhard Reithofer

unread,
Apr 2, 2020, 11:30:28 AM4/2/20
to
Hi *,
I used a label printer for years on Linux.
It becomes registered in Linux as character device like
crw-rw---- 1 root lp 180, 1 Apr 2 16:34 /dev/usb/lp1

Syslog:
usb 1-1.2: new full-speed USB device number 24 using ehci-pci
usb 1-1.2: New USB device found, idVendor=04f9, idProduct=2044, bcdDevice= 1.00
usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
usb 1-1.2: Product: QL-720NW
usb 1-1.2: Manufacturer: Brother
usb 1-1.2: SerialNumber: 000J6Z876646
usblp 1-1.2:1.0: usblp1: USB Bidirectional printer dev 24 if 0 alt 0 proto 2 vid 0x04F9 pid 0x2044

I can comunicate with it via [file open $dev {RDWR}] and anything works
perfect.
But now my customer must change to Windows and he wants to use it the
same way.

I think that it is some sort of USB serial but really dont know.
Using the enum_usb script from the TCL wiki it is found as:
USB Printing Support
usbprint
USB Printing Support
BrotherQL-720NW

What I do not know is the possibilty to access the device via file IO or
any other way. The bidirect mode is necessary because the printer has a
very powerful interface and it provides information about loaded label
format, the device capabilities like label sizes, error handling, etc.

I know some usb-serial adapters which can be used via COM:devices but
in this case I do not even know which device (COM1:, LPT3:, ...) I
could try.

Any hints where I could further dig in to talk to my printer?

TIA,
Gerhard

--
Gerhard Reithofer - Techn. EDV Reithofer - http://www.tech-edv.co.at

Harald Oehlmann

unread,
Apr 2, 2020, 12:16:22 PM4/2/20
to
Am 02.04.2020 um 17:19 schrieb Gerhard Reithofer:
> Hi *,
> I used a label printer for years on Linux.
> It becomes registered in Linux as character device like
> crw-rw---- 1 root lp 180, 1 Apr 2 16:34 /dev/usb/lp1
>
> Syslog:
> usb 1-1.2: new full-speed USB device number 24 using ehci-pci
> usb 1-1.2: New USB device found, idVendor=04f9, idProduct=2044, bcdDevice= 1.00
> usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> usb 1-1.2: Product: QL-720NW
> usb 1-1.2: Manufacturer: Brother
> usb 1-1.2: SerialNumber: 000J6Z876646
> usblp 1-1.2:1.0: usblp1: USB Bidirectional printer dev 24 if 0 alt 0 proto 2 vid 0x04F9 pid 0x2044
>
> I can comunicate with it via [file open $dev {RDWR}] and anything works
> perfect.
> But now my customer must change to Windows and he wants to use it the
> same way.

If you write "communicate", you think about a bidirectional communication ?
If no... I have wrapped this C code to a tcl dll:
https://web.archive.org/web/20150224220157/http://www.tonyedgecombe.com/2012/09/10/Raw-printing-in-Windows-8-and-Server-2012.html

That is not easy stuff, sorry.

Hope this helps,
Harald




Gerhard Reithofer

unread,
Apr 2, 2020, 1:46:30 PM4/2/20
to
Hallo Harald,

On Thu, 2 Apr 2020, Harald Oehlmann wrote:

> Am 02.04.2020 um 17:19 schrieb Gerhard Reithofer:
> > Hi *,
> > I used a label printer for years on Linux.

[...]

> If you write "communicate", you think about a bidirectional communication ?
> If no... I have wrapped this C code to a tcl dll:
> https://web.archive.org/web/20150224220157/http://www.tonyedgecombe.com/2012/09/10/Raw-printing-in-Windows-8-and-Server-2012.html

the problem is not the data which I have to send to the label printer or
what to receive, this is all well documented.

In the meantime I found in the depths ow the Windows that it uses the
"Universal Serial Bus Controller".

It's only the way how I can read/write to the interface which I don't
know, I tried "COM1:" up to "COM8:" but all failed.

I even found the device "port" in Windows - thanks to the Wiki:
https://wiki.tcl-lang.org/page/serial+ports+on+Windows

It has the name "USB001" but this also cannot be used as device name
with the TCL [open] command, but I will try some possibilities.

> That is not easy stuff, sorry.

I only want to open a serial interface (in that case IMHO a virtual) and
read and write to it. Absolutely simple in Linux
...
set fd [open $device r+]
set input [read $df]
puts -nonewline $df $result
close $fd
...

My problem is the content of $device for writing to it, it's
/dev/usb/lp1 in my case.

And finally the printer has a really serial interface but many computers
(mainly laptops) don't have this interface anymore.

Thank you very much Harald,

Ted Nolan <tednolan>

unread,
Apr 2, 2020, 1:54:35 PM4/2/20
to
In article <alpine.DEB.2.21.2...@mecano.tech-edv.co.at>,
Could you just write the print data to a file and then spawn a dos command
to copy it to the printer?

A quick google suggests something like:

copy test.ps \\127.0.0.1\<printershare>

might work if the printer is shared. Might need to be a "copy /b" for
non PS printer data I suppose.
--
columbiaclosings.com
What's not in Columbia anymore..

Robert Heller

unread,
Apr 2, 2020, 2:09:43 PM4/2/20
to
If it has a RS232 interface, you can get a RS232 <=> USB adapter (US Connector
sells good quality ones), which WILL show up under MS-Windows as COM<number>:
and you can open that up from Tcl and everything will work as expected.

>
> Thank you very much Harald,
> Gerhard
>

--
Robert Heller -- 978-544-6933 Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
hel...@deepsoft.com -- Webhosting Services

Uwe Klein

unread,
Apr 2, 2020, 2:26:57 PM4/2/20
to
Am 02.04.2020 um 19:43 schrieb Gerhard Reithofer:
> My problem is the content of $device for writing to it, it's
> /dev/usb/lp1 in my case.
>
> And finally the printer has a really serial interface but many computers
> (mainly laptops) don't have this interface anymore.
>

Hi.

Doesn't the printer get attached as PRN: | LPT1: | LPT2: | ... "Thingy".
Have you looked into the "printers and devices" page ?
What changes if you attach/remove it ?

G!
Uwe



Gerhard Reithofer

unread,
Apr 2, 2020, 6:08:05 PM4/2/20
to
Hi Ted,

On Thu, 2 Apr 2020, Ted Nolan <tednolan> wrote:

> In article <alpine.DEB.2.21.2...@mecano.tech-edv.co.at>,
> Gerhard Reithofer <gerhard....@tech-edv.co.at> wrote:
> >Hallo Harald,

[...]

> >And finally the printer has a really serial interface but many computers
> >(mainly laptops) don't have this interface anymore.
> >
> >Thank you very much Harald,
> >Gerhard
> >
>
> Could you just write the print data to a file and then spawn a dos command
> to copy it to the printer?
>
> A quick google suggests something like:
>
> copy test.ps \\127.0.0.1\<printershare>

there are 2 problems:
1. The printer does not appear in the printer area (Printers &
Scanners in W10) it appears under "Bluetooth & other devices" threfor I
cannot "Share" it (I think).

2. I would like to do a bidriectional communication, reading from and
writing to.

Nevertheless it could be one possibility for the application.

Gerhard Reithofer

unread,
Apr 2, 2020, 7:02:09 PM4/2/20
to
Hi Uwe,
I've already wrote it before, it does not appear in the "Printers &
Scanner" section it is displayed under "Bluetooth & other devices".

If I unplug it the device disappears and after plugging in it reappears
again.
What I tried until now on my notebook which has no COM and LPT ports:
open COM1: failed - couldn't open "COM1:": no such file or directory
open COM2: failed - couldn't open "COM2:": no such file or directory
open COM3: failed - couldn't open "COM3:": no such file or directory
open COM4: failed - couldn't open "COM4:": no such file or directory
open COM5: failed - couldn't open "COM5:": no such file or directory
open COM6: failed - couldn't open "COM6:": no such file or directory
open COM7: failed - couldn't open "COM7:": no such file or directory
open LPT1: failed - couldn't open "LPT1:": no such file or directory
open LPT2: failed - couldn't open "LPT2:": no such file or directory
open LPT3: failed - couldn't open "LPT3:": no such file or directory
open PRN: failed - couldn't open "PRN:": no such file or directory
open USB001: failed - couldn't open "USB001:": no such file or
directory

The USB device is displayed in the printer management ports list of the
Print Management dialog without COLON, the PRN: was not present in that
list.

The command sequence
[catch {set com [open $comport]} err]
was used in an older script successfully a few years ago communicating
with a 3d printer via COM1 with success on a standard PC.

I will try to do FileIO via twapi later.

Has no one tried to print to a device via these interfaces from Windows
10?

TIA,

Gerhard Reithofer

unread,
Apr 2, 2020, 7:02:09 PM4/2/20
to
Hi Robert,

On Thu, 2 Apr 2020, Robert Heller wrote:

> At Thu, 2 Apr 2020 19:43:26 +0200 Gerhard Reithofer <gerhard....@tech-edv.co.at> wrote:
>
> >
> > Hallo Harald,
> >
> > On Thu, 2 Apr 2020, Harald Oehlmann wrote:
> >
> > > Am 02.04.2020 um 17:19 schrieb Gerhard Reithofer:
> > > > Hi *,
> > > > I used a label printer for years on Linux.
> >

[...]

> If it has a RS232 interface, you can get a RS232 <=> USB adapter (US Connector
> sells good quality ones), which WILL show up under MS-Windows as COM<number>:
> and you can open that up from Tcl and everything will work as expected.

that's definitely one possibility - the most promising from my point of
view until now.
I've used RS232 <=> USB several times even on a Raspberry Pi successfully.

Nevertheless it's easier and faster using a USB-Serial connection
directly on Linux, also as simple as described before.
# just open, no speed and protocol fiddling, ...
set fd [open /dev/ttyUSB1 {RDONLY}]
puts -nonoewline $fd "\x1ba0" ; # left align
[...]

Bye,

ALX

unread,
Apr 3, 2020, 2:12:08 AM4/3/20
to
Hello Gerald, as far as I know you need a serial device for this kind of communication. The USB devices often only understand binary protocols. Have you tried the library tserialport? It lists the USB devices and if there is one, the serial port.

https://tcl.sowaswie.de/repos/fossil/tserialport/wiki?name=examples

Christian Gollwitzer

unread,
Apr 3, 2020, 2:17:58 AM4/3/20
to
Am 03.04.20 um 00:58 schrieb Gerhard Reithofer:
> Hi Uwe,
>> Doesn't the printer get attached as PRN: | LPT1: | LPT2: | ... "Thingy".
>> Have you looked into the "printers and devices" page ?
>> What changes if you attach/remove it ?
>
> I've already wrote it before, it does not appear in the "Printers &
> Scanner" section it is displayed under "Bluetooth & other devices".

Maybe you need to "install" some kind of device driver in Windows first?
Can you print to the printer with a regular application? Maybe you need
to run the printer setup dialog to from the "printer" section first.
Windows often requires extra steps to enable hardware items, which feels
strange coming from Linux that you need to "install a driver" for a USB
flashdisk.

Christian

Christian Gollwitzer

unread,
Apr 3, 2020, 2:20:33 AM4/3/20
to
Yet another idea,

maybe you can use libusb to directly talk to the device. There is a
wrapper for Tcl:

https://github.com/ray2501/tclusb

Christian

Am 03.04.20 um 08:17 schrieb Christian Gollwitzer:

Uwe Klein

unread,
Apr 3, 2020, 3:05:16 AM4/3/20
to
Am 03.04.2020 um 00:58 schrieb Gerhard Reithofer:
> Has no one tried to print to a device via these interfaces from Windows
> 10?
>
The majority of programmers are not into "hurts so good" :-))

( sorry I overread your non COM tries.)

Any driver from the manufacturer avaialbe?

What has irked me to no end is that windows updates
( I use Windows for some commercial hardware config programs)
tend to disable functioning RS232 and 422 USB Adapters.
they still work under linux. Just the USB ID has been "delisted".

I've done a test with a left over ancient CASIO label printer last night.
on an up to date WIN XP system. "unknown device" and
no driver findable via "fix problems".

If you know how to talk to the thingy under Linux:
What about taking a Raspberry and attaching the printer
there.
Write some code to have the Raspberry accept
data blobs vi the network or Wifi and convert those to printer language
there.

Uwe




Christopher Chavez

unread,
Apr 3, 2020, 3:06:15 AM4/3/20
to

> It's only the way how I can read/write to the interface which I don't
> know, I tried "COM1:" up to "COM8:" but all failed.
>
> I even found the device "port" in Windows - thanks to the Wiki:
> https://wiki.tcl-lang.org/page/serial+ports+on+Windows
>
> It has the name "USB001" but this also cannot be used as device name
> with the TCL [open] command, but I will try some possibilities.

> My problem is the content of $device for writing to it, it's
> /dev/usb/lp1 in my case.
>
> And finally the printer has a really serial interface but many computers
> (mainly laptops) don't have this interface anymore.
>
I don't have any solutions, but it sounds like your printer's USB
connection is really USB to Parallel interface (e.g. IEEE 1284 bridge),
based on how it shows up on Linux as /dev/usb/lp1 and on Windows as
USB001 (which is how USB printer ports appear; USB serial ports to my
knowledge appear just as normal COM ports do on Windows). And in Device
Manager this might show up as "USB Printing Support". So what you may be
after is being able to communicate with LPT/parallel ports, rather than
COM/serial ports. I don't know what's involved with doing this from Tcl
on Windows.

Also keep in mind the old Control Panel is still available in Windows
10: click Start and type "Control Panel".  The "Hardware and Sound"
section has a "Devices and Printers" section. I don't know for certain
that it will show anything the Windows 10 Settings doesn't, though.

Hope this helps


Christopher A. Chavez

Robert Heller

unread,
Apr 3, 2020, 8:17:13 AM4/3/20
to
Yes, given Mess-Windows 10 weirdnesses, it might be easier and really cheap to
just put a Raspberry Pi in a "black box" and use Tcp/Ip (over ethernet or
wifi) to communicate with the Mess-Windows 10 box.

Another option: get a Pocket Beagle ($25 from Seeed Systems) and the host USB
breakout (I think Seeed Systems sells that too). The Pocket Beagle can be
powered from the USB (which also acts as a network connection) and the printer
would plug into the Beagle. The Pocket Beagle runs Debian Linux (off a microSD
card). I think the Pocket Beagle will fit into a mint tin or else into a small
project box.

With either the Raspberry Pi or Pocket Beagle option, turn your existing Tcl
code into a "server", either using a custom port and protocol or (probably
more user friendly) a httpd server (using one of the Tcl http server
libraries. If the latter, the end user can just fire up a webbrowser (Edge,
Firefox, Chrome, etc.) and access the printer that way.

>
> Uwe

Gerhard Reithofer

unread,
Apr 3, 2020, 10:08:05 AM4/3/20
to
Hallo Christian,
I have newly installed all drivers then it can be seen by another tool
called "Printer Setting Tool". It looks like I can change many things -
e.g. it shows port USB001 with 9600 Baud!! - but if I want to "Save" the
settings I always get the error that the values cannot be written to
the device.

I found an additional tool called "reset printer driver" which makes me
think that there's somthing to repair.
IMHO the complete Windows/Driver environment seems to broken. Plugging
it into Linux it works immediately.

Gerhard Reithofer

unread,
Apr 3, 2020, 10:08:05 AM4/3/20
to
Hi,

On Fri, 3 Apr 2020, Christian Gollwitzer wrote:

> Yet another idea,
>
> maybe you can use libusb to directly talk to the device. There is a wrapper
> for Tcl:
>
> https://github.com/ray2501/tclusb

I currently have no development environment on Windows.
and I still do not know, how to "address" this device :-(

Rich

unread,
Apr 3, 2020, 10:27:10 AM4/3/20
to
Gerhard Reithofer <gerhard....@tech-edv.co.at> wrote:
> IMHO the complete Windows/Driver environment seems to broken.

Yes...

Even if you could find a windows 'driver' for it that worked, you'd
still likely find that in order to talk to it, you have to use windows
os calls to do so. I.e., it would not appear as a file you can just
open with the normal file access routines like on Linux.

Several posters in this thread suggested a rasberry PI or beaglebone
running Linux to talk to the printer, with ethernet or wifi on the
other side of the rpi/bb to interface with broken operating systems
(i.e., windows). This is likely going to be your best bet for gaining
access to use the device via a windows machine.

Gerhard Reithofer

unread,
Apr 3, 2020, 10:36:43 AM4/3/20
to
Hallo Uwe,

On Fri, 3 Apr 2020, Uwe Klein wrote:

> Am 03.04.2020 um 00:58 schrieb Gerhard Reithofer:
> > Has no one tried to print to a device via these interfaces from Windows
> > 10?
> >
> The majority of programmers are not into "hurts so good" :-))

[...]

> What has irked me to no end is that windows updates
> ( I use Windows for some commercial hardware config programs)
> tend to disable functioning RS232 and 422 USB Adapters.
> they still work under linux. Just the USB ID has been "delisted".
>
> I've done a test with a left over ancient CASIO label printer last night.
> on an up to date WIN XP system. "unknown device" and
> no driver findable via "fix problems".
>
> If you know how to talk to the thingy under Linux:
> What about taking a Raspberry and attaching the printer
> there.

[...]

> Write some code to have the Raspberry accept
> data blobs vi the network or Wifi and convert those to printer language
> there.

wow!
That's a real, real great idea!

Add a Raspi to an USB printer and controll it over the network
transparent!
I will make additional tests via real serial IO but I need another
hardware.
I'l keep you informed.

Thanks,

Harald Oehlmann

unread,
Apr 3, 2020, 10:50:58 AM4/3/20
to
Dear Gerhard,

I can only second, that the USB001 device may not be treated as a serial
device.
If you want read/write, I only see a C based extension.
The correct access to the USB device depends on the protocol on the USB
Bus (Packet or Stream).
In both cases you can open it with a windows system call (OpenFile).
To find the USB device name is around 30 lines of C code (Bus
enumeration loop).

In case of stream mode, you can just read and write to it.
In case of packet mode, you have to care about the package structure
which depends on many parameters. You get and write one package per
readfile/writefile call.

You can use wireshark to listen to your usb device to find out.
Other helpful software is proprietary.

Anyway, without a C extension - no way.

Just my 2 cents.

Hope this helps,
Harald

Robert Heller

unread,
Apr 3, 2020, 10:53:00 AM4/3/20
to
At Fri, 3 Apr 2020 16:05:04 +0200 Gerhard Reithofer <gerhard....@tech-edv.co.at> wrote:

>
> Hi,
>
> On Fri, 3 Apr 2020, Christian Gollwitzer wrote:
>
> > Yet another idea,
> >
> > maybe you can use libusb to directly talk to the device. There is a wrapper
> > for Tcl:
> >
> > https://github.com/ray2501/tclusb
>
> I currently have no development environment on Windows.
> and I still do not know, how to "address" this device :-(

If it was me, I'd "punt": set things up with some sort of "embeded Linux"
option. My choice would be a PocketBeagle ($25 from SeedSudios.com). The
PocketBeagle is an ARM-based embeded Linux SBC. It can run off a USB port,
which both powers it and acts as a network interface. It also has a USB host
interface and there is a breakout board for mounting a USB jack (I think an
female A). Then put your existing Tcl code on the PocketBeagle (which runs
Debian Linux) and adapt it be some kind of "server daemon" and have the
PocketBeagle start it on boot up (either by crafting a systemd service or just
launching it from /etc/rc.local). The write the client (also in Tcl) to run on
the Windows system, connecting to the PocketBeagle via the network over the
USB. That is put a "black box" between the Windows system and the printer.

It sounds like MS-Windows is just not going to let you do what you want,
without some serious hacking. I'm guessing your client is unable/unwilling to
toss MS-Windows in favor of running Linux...

Gerhard Reithofer

unread,
Apr 3, 2020, 12:08:07 PM4/3/20
to
Hi ALX,

On Thu, 2 Apr 2020, ALX wrote:

> Hello Gerald, as far as I know you need a serial device for this kind of communication. The USB devices often only understand binary protocols. Have you tried the library tserialport? It lists the USB devices and if there is one, the serial port.
>
> https://tcl.sowaswie.de/repos/fossil/tserialport/wiki?name=examples
>

currently I haven't a development environment for Windows :-(

Gerhard Reithofer

unread,
Apr 3, 2020, 12:08:07 PM4/3/20
to
Hi Christopher,

On Fri, 3 Apr 2020, Christopher Chavez wrote:

>
> > It's only the way how I can read/write to the interface which I don't
> > know, I tried "COM1:" up to "COM8:" but all failed.

[...]

> I don't have any solutions, but it sounds like your printer's USB connection
> is really USB to Parallel interface (e.g. IEEE 1284 bridge), based on how it
> shows up on Linux as /dev/usb/lp1 and on Windows as USB001 (which is how USB
> printer ports appear; USB serial ports to my knowledge appear just as normal
> COM ports do on Windows). And in Device Manager this might show up as "USB
> Printing Support". So what you may be after is being able to communicate with
> LPT/parallel ports, rather than COM/serial ports. I don't know what's involved
> with doing this from Tcl on Windows.

In the meantime I'm rather sure that it is a serial connection.
In the "Printer Settings Tool" a Baud rate of 9600 is given but it
doesn't work and I found in the Registry that it is slinked to
"Universal Serial Bus Controller".
The parallel interface was never planned to work bidiretional but I need
this and it works that way on Linux.

> Also keep in mind the old Control Panel is still available in Windows 10:
> click Start and type "Control Panel".  The "Hardware and Sound" section has a
> "Devices and Printers" section. I don't know for certain that it will show
> anything the Windows 10 Settings doesn't, though.

In the meantime I'm rather sure that my system is messed up, it doesn't
even work on Windows anymore :-(

Thank you,

Gerhard Reithofer

unread,
Apr 3, 2020, 12:08:07 PM4/3/20
to
Hi Rich,
yes, I think that will become the solution, independent of Windows as
others have also recommended ;-)
The other possibility a the "real serial interface" which I have used
already and also a Windows USB-serial. But this was years ago, probably
Win7 or even XP.

The backdraw of the PI solution is the fact that it needs additional
hardware and that are additional components which can fail.

Thanks to all for your input.
I will keep you informed and if the Corona-Virus will let us organize
the EuroTCL in Vienna, maybe I can demonstrate the solution.

THX to *
Gerhard

Christian Gollwitzer

unread,
Apr 3, 2020, 12:20:46 PM4/3/20
to
Am 03.04.20 um 17:13 schrieb Gerhard Reithofer:
> Hi ALX,
>
> On Thu, 2 Apr 2020, ALX wrote:
>
>> Hello Gerald, as far as I know you need a serial device for this kind of communication. The USB devices often only understand binary protocols. Have you tried the library tserialport? It lists the USB devices and if there is one, the serial port.
>>
>> https://tcl.sowaswie.de/repos/fossil/tserialport/wiki?name=examples
>>
>
> currently I haven't a development environment for Windows :-(
>

You'll probably go another direction now, but to get a working Windows
compiler, the easiest thing is to install the "git sdk":

https://github.com/git-for-windows/build-extra/releases

Run the "git-sdk-installer-*64*.exe". It doesn't even need admin rights,
if you install to a local disc. This gives you a terminal with bash and
everything to run configure scripts etc.

Christian

Harald Oehlmann

unread,
Apr 3, 2020, 1:27:31 PM4/3/20
to
Am 03.04.2020 um 17:08 schrieb Gerhard Reithofer:
> In the meantime I'm rather sure that it is a serial connection.

To my experience, this is only true, if the port (not the device) is
listed in windows device manager under "Serial and Parallel Ports".

On my German Windows 10 box:
-> Geräte-Manager
-> Anschlüsse (COM & LPT)

The name is typically something with "USB ..." and must have a suffix
like "(COMx)".

Hope this helps,
Harald

Gerhard Reithofer

unread,
Apr 3, 2020, 4:08:05 PM4/3/20
to
Hallo Harald,

On Fri, 3 Apr 2020, Harald Oehlmann wrote:

> Dear Gerhard,
>
> I can only second, that the USB001 device may not be treated as a serial
> device.

...

> In both cases you can open it with a windows system call (OpenFile).
> To find the USB device name is around 30 lines of C code (Bus
> enumeration loop).

thats interesting.
OpenFile could be a twapi call and bus enumeration can be done via
registry - see: https://wiki.tcl-lang.org/page/serial+ports+on+Windows

[...]

> In case of stream mode, you can just read and write to it.

Read/Write is sufficient, it works with Linux that way, don't know if
stream or packet mode.

> Anyway, without a C extension - no way.

Also no hope from TWAPI?

> Just my 2 cents.

Finally the decision is made to use a Raspberry as blackbox.

BTW: Your Yahoo address was rejected when I tried to answer your mail.

Bye,

Gerhard Reithofer

unread,
Apr 3, 2020, 4:08:05 PM4/3/20
to
Hallo,

On Fri, 3 Apr 2020, Harald Oehlmann wrote:

> Am 03.04.2020 um 17:08 schrieb Gerhard Reithofer:
> > In the meantime I'm rather sure that it is a serial connection.
>
> To my experience, this is only true, if the port (not the device) is
> listed in windows device manager under "Serial and Parallel Ports".
>
> On my German Windows 10 box:
> -> Geräte-Manager
> -> Anschlüsse (COM & LPT)

nothing available with "Anschlüsse" :-(

Bye,

Gerhard Reithofer

unread,
Apr 3, 2020, 4:08:05 PM4/3/20
to
Hi Robert,

On Fri, 3 Apr 2020, Robert Heller wrote:

> At Fri, 3 Apr 2020 16:05:04 +0200 Gerhard Reithofer <gerhard....@tech-edv.co.at> wrote:
>
> >
> > Hi,
> >
> > On Fri, 3 Apr 2020, Christian Gollwitzer wrote:
> >
> > > Yet another idea,
> > >
> > > maybe you can use libusb to directly talk to the device. There is a wrapper
> > > for Tcl:
> > >
> > > https://github.com/ray2501/tclusb
> >
> > I currently have no development environment on Windows.
> > and I still do not know, how to "address" this device :-(
>
> If it was me, I'd "punt": set things up with some sort of "embeded Linux"
> option. My choice would be a PocketBeagle ($25 from SeedSudios.com). The

[...]

sorry, I have already ordered a Raspbbery Pi 4 :-)
I enough experience with this as I'm using it since version 1B.

> It sounds like MS-Windows is just not going to let you do what you want,
> without some serious hacking. I'm guessing your client is unable/unwilling to
> toss MS-Windows in favor of running Linux...

Unfortunatelly yes, but the main reason is his commercial sotware which
runs on Windows only, my small part only affects barcode management and
this depends on his evironment. But MS-SQL server access is also easily
possible from Linux.

And I'm more flexible ;-)

Uwe Klein

unread,
Apr 3, 2020, 4:55:26 PM4/3/20
to
there are absolutely pretty enclosures around for Raspis.
ad a AC2USB Wall Wart.
( and some nice ones that integrate a mini lcd display too.)

I have used embedded Linux for better than 2 decades now.
Only time they have died on me was from lightning strikes.
( poor beasty, but the drives for the Antenna array the boxes
were controlling looked even worse. :-)

Raspberries since the V2 ones.
Mostly for protocol conversions, data stream multiplexing
and industrial automation ( like controlling hydraulic machinery )

there is a bit of software on the wiki from those projects.

Uwe

Helmut Giese

unread,
Apr 3, 2020, 5:28:40 PM4/3/20
to
I know I am (too?) late to the show, but how about a VirtualBox
running Linux on the customers PC?
It can be configured to let USB through.
He doesn't even have to 'boot' Linux himself - all he has to do is
- to install VirtualBox
- copy a Linux image _you_ can completely setup and send to him
- and press start.
Not tested, but I think it is worth a try.
Just my 0.02 €
Helmut

Rich

unread,
Apr 3, 2020, 5:42:25 PM4/3/20
to
> Just my 0.02 ?
> Helmut

Or the reverse, deploy a linux machine and use VB to constrain the
windows install into a sandbox.

greg

unread,
Apr 4, 2020, 4:22:16 PM4/4/20
to
Am Donnerstag, 2. April 2020 17:30:28 UTC+2 schrieb Gerhard Reithofer:
> Hi *,
> I used a label printer for years on Linux.
> It becomes registered in Linux as character device like
> crw-rw---- 1 root lp 180, 1 Apr 2 16:34 /dev/usb/lp1
>
> Syslog:
> usb 1-1.2: new full-speed USB device number 24 using ehci-pci
> usb 1-1.2: New USB device found, idVendor=04f9, idProduct=2044, bcdDevice= 1.00
> usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
> usb 1-1.2: Product: QL-720NW
> usb 1-1.2: Manufacturer: Brother
> usb 1-1.2: SerialNumber: 000J6Z876646
> usblp 1-1.2:1.0: usblp1: USB Bidirectional printer dev 24 if 0 alt 0 proto 2 vid 0x04F9 pid 0x2044
>
> I can comunicate with it via [file open $dev {RDWR}] and anything works
> perfect.
> But now my customer must change to Windows and he wants to use it the
> same way.
>
> I think that it is some sort of USB serial but really dont know.
> Using the enum_usb script from the TCL wiki it is found as:
> USB Printing Support
> usbprint
> USB Printing Support
> BrotherQL-720NW
>
> What I do not know is the possibilty to access the device via file IO or
> any other way. The bidirect mode is necessary because the printer has a
> very powerful interface and it provides information about loaded label
> format, the device capabilities like label sizes, error handling, etc.
>
> I know some usb-serial adapters which can be used via COM:devices but
> in this case I do not even know which device (COM1:, LPT3:, ...) I
> could try.
>
> Any hints where I could further dig in to talk to my printer?
>
> TIA,
> Gerhard
>
> --
> Gerhard Reithofer - Techn. EDV Reithofer - http://www.tech-edv.co.at



#example with twapi and SDK
#Brother b-PAC3 SDK installiert, 32 bit
#
#BrssCom.Document
#Open
#settext 0
#settext 1
#settext usw.
#doPrint
#close
#
# template created with P-Touch Editor
# brotherql62x25.lbx
# 1 line and 1 arbitrary character as a wildcard
# in directory C:/etiketten

package require twapi
set etikettlbx "brotherql62x25.lbx"
set etikettdir "C:/etiketten"
set etikettfile [file join $etikettdir $etikettlbx ]

proc bqldrucken_p {kvar etikettfile {anzahl 1} } {
set brother [::twapi::comobj BrssCom.Document]
set etikett [string map {"/" "\\" } $etikettfile ]
$brother -call Open [subst {$etikett}]
$brother -call settext 0 "$kvar"
$brother -call doPrint 0 1,$anzahl
$brother -call close
}

bqldrucken_p "123456789" $etikettfile




best regards
Greor

Gerhard Reithofer

unread,
Apr 5, 2020, 1:08:05 PM4/5/20
to
Hi Greg,

On Sat, 4 Apr 2020, greg wrote:

> Am Donnerstag, 2. April 2020 17:30:28 UTC+2 schrieb Gerhard Reithofer:
> > Hi *,
> > I used a label printer for years on Linux.
> > It becomes registered in Linux as character device like
> > crw-rw---- 1 root lp 180, 1 Apr 2 16:34 /dev/usb/lp1

[...]
I knew that there are more possibilities.

But unfortunately it doesn't work here.

V:\TCL\Projects\BC> tclsh win_print.tcl
Ungültige Klassenzeichenfolge
while executing
"CLSIDFromProgID $progid"
(procedure "progid_to_clsid" line 1)
invoked from within
"progid_to_clsid $comid"
(procedure "_convert_to_clsid" line 3)
invoked from within
"_convert_to_clsid $comid"
(procedure "::twapi::comobj" line 7)
invoked from within
"::twapi::comobj BrssCom.Document"
(procedure "bqldrucken_p" line 2)
invoked from within
"bqldrucken_p $etikettfile"
(file "win_print.tcl" line 56)

FYI:
1. I don't have installed any brother SDK.
2. I still want to have a bidirectional control of the printer.
3. I want to use "programmed" labels dynamically.

That means that if a user changes the label format (just pull out one
label roll and push in another one) I want that the corresponding label
format is used automatically. The protocol allows this, it works and I
really want to use it.

Just for "sending" the data to the printer I could also use the wireless
or wired network - it does also create the labels inependent from the
OS. But this also doesn't provide bidirectional access to query the
loaded paper format and react on it.

But I will keep this test in my mind and I may use it in another
situation.

Thank you very much,

Christian Gollwitzer

unread,
Apr 5, 2020, 2:11:54 PM4/5/20
to
Am 05.04.20 um 18:51 schrieb Gerhard Reithofer:
> That means that if a user changes the label format (just pull out one
> label roll and push in another one) I want that the corresponding label
> format is used automatically. The protocol allows this, it works and I
> really want to use it.
>
> Just for "sending" the data to the printer I could also use the wireless
> or wired network - it does also create the labels inependent from the
> OS. But this also doesn't provide bidirectional access to query the
> loaded paper format and react on it.


Are you sure? That's a shame. Ethernet is by far the easiest way to
communicate with devices, then comes RS232, USB is last.

Christian

Robert Heller

unread,
Apr 5, 2020, 6:12:44 PM4/5/20
to
If the OP uses a RaspPi to talk to the printer (which seems to be the way he
is leaning), it should be trivial to wrap his existing code into a Tcp/Ip
server deamon (either using a custom port, with a custom client or using a Tcl
HTTPD library and a standard webbrowser as the client). This deamon can
*easily* provide bidirectional functionallity (even as a HTTP: server). There
is not any reason to believe that ALL of the existing bidirectional
functionallity could not be implemented using a RaspPi connected to the
MS-Windows system via Ethernet or WiFi (using Tcp/Ip), even using the HTTP
protocol. The client program (could be a webbrowser) could query the RaspPi to
cause it to query the printer. If using the HTTP protocol and a webbrowser as
the "client", JavaScript can be used to force polling of the printer's status
(eg label roll changes).

Gerhard Reithofer

unread,
Apr 6, 2020, 7:07:24 AM4/6/20
to
On Sun, 5 Apr 2020, Robert Heller wrote:

> At Sun, 5 Apr 2020 20:11:50 +0200 Christian Gollwitzer <auri...@gmx.de> wrote:
>
> >
> > Am 05.04.20 um 18:51 schrieb Gerhard Reithofer:
> > > That means that if a user changes the label format (just pull out one

[...]

> > Are you sure? That's a shame. Ethernet is by far the easiest way to
> > communicate with devices, then comes RS232, USB is last.
> >
> > Christian
>
> If the OP uses a RaspPi to talk to the printer (which seems to be the way he
> is leaning), it should be trivial to wrap his existing code into a Tcp/Ip
> server deamon (either using a custom port, with a custom client or using a Tcl
> HTTPD library and a standard webbrowser as the client). This deamon can
> *easily* provide bidirectional functionallity (even as a HTTP: server). There
> is not any reason to believe that ALL of the existing bidirectional
> functionallity could not be implemented using a RaspPi connected to the
> MS-Windows system via Ethernet or WiFi (using Tcp/Ip), even using the HTTP
> protocol. The client program (could be a webbrowser) could query the RaspPi to
> cause it to query the printer. If using the HTTP protocol and a webbrowser as
> the "client", JavaScript can be used to force polling of the printer's status
> (eg label roll changes).

A big YES!

But the client is a specific management UI talking to the database of
the commercial ERP system because it's an extension to the not really
working label printer interface of that software ;-)

Even a UI with a small touch display on the Raspi is in discussion then
it would be completely independent from any other computer.

Gerhard Reithofer

unread,
Apr 6, 2020, 7:07:24 AM4/6/20
to
Hallo Christian,
The problem isn't the general communication capabilities but more the
protocols and their goal.
An example is the simple LPR protocol (RFC1179, August 1990). Almost all
network printers implement it and printing is possible independent from
the OS.

But printers were for decades only data receivers, they "receive" a file
and create the corresponding output. It was never planned to ask for the
toner level of any of the 5 printing colors, the loaded label format or
printer statistics for service reasons etc. The LPR protocol manages the
data transfer and adds a few commands for the server queue managment but
not the "high level device specific" special features.
In other words: A line printer protocol communicates between the
application and the server to which the printer is attached but I need
the communication with the printer itself.

Nowadays these capabilities are mostly hidden behind in vendor specific
(Windows!) drivers and there's no official way to circumvent this.
My intended existing printer uses vendor specific ESC/P commands and it
returns the required information via RS232 and bidirectional USB (prob.
USB-serial).
Fortunantely in this case it's possible with a 100+ page developers
reference - which was basically the main decision to buy this printer.

My planned solution is to use this to talk to the printer via USB on my
"blackbox" and to the application via ethernet.
The blackbox will be a Raspberry Pi which supports the bidriectional USB
access via file i/o from TCL and has an ethernet interface and the newer
ones also have Wireless LAN on board.

Let's call it my "Smart label printing box" which should run on each
system which has TCL ;-)

Regards in hope to be successful,

Uwe Klein

unread,
Apr 6, 2020, 8:10:41 AM4/6/20
to
Am 06.04.2020 um 13:04 schrieb Gerhard Reithofer:
> Even a UI with a small touch display on the Raspi is in discussion then
> it would be completely independent from any other computer.
>
some nice enclosures around that intergrate a
same size touchscreen display.

Like:
https://www.ebay.de/itm/Fur-Raspberry-Pi-4-Touchscreen-Tasche-35-Zoll-Touchscreen-Lufter-320x480-Moni/303523524839

( no connection. similar around too)

Uwe

undro...@gmail.com

unread,
Apr 6, 2020, 9:19:56 AM4/6/20
to
Servus Gerhard,

if you'd like to have your Raspi a display with touchscreen and a little Tk GUI
for local management undroidwish is your friend and doesn't require a full blown
X11 installation since it powers the Raspi's Video Core directly using the "RPI"
SDL2 video driver.

A test version is in http://www.ch-werner.de/AndroWish/undroidwish-raspi

Take care,
Christian

Ralf Fassel

unread,
Apr 6, 2020, 9:37:53 AM4/6/20
to
* Gerhard Reithofer <gerhard....@tech-edv.co.at>
| Syslog:
| usb 1-1.2: new full-speed USB device number 24 using ehci-pci
| usb 1-1.2: New USB device found, idVendor=04f9, idProduct=2044, bcdDevice= 1.00
| usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
| usb 1-1.2: Product: QL-720NW
| usb 1-1.2: Manufacturer: Brother
| usb 1-1.2: SerialNumber: 000J6Z876646
| usblp 1-1.2:1.0: usblp1: USB Bidirectional printer dev 24 if 0 alt 0 proto 2 vid 0x04F9 pid 0x2044
--<snip-snip>--
| What I do not know is the possibilty to access the device via file IO or
| any other way. The bidirect mode is necessary because the printer has a
| very powerful interface and it provides information about loaded label
| format, the device capabilities like label sizes, error handling, etc.
|
| I know some usb-serial adapters which can be used via COM:devices but
| in this case I do not even know which device (COM1:, LPT3:, ...) I
| could try.
>
| Any hints where I could further dig in to talk to my printer?

Did you try to contact Brother support desk? Maybe they have some info
whether your operating mode is available on Windows at all?

Other than that, libusb comes to mind (https://libusb.info/) to talk
directly to the device...

R'

Gerhard Reithofer

unread,
Apr 7, 2020, 12:36:46 PM4/7/20
to
Hallo Ralf,

On Mon, 6 Apr 2020, Ralf Fassel wrote:

> * Gerhard Reithofer <gerhard....@tech-edv.co.at>
> | Syslog:
> | usb 1-1.2: new full-speed USB device number 24 using ehci-pci

...

> | I know some usb-serial adapters which can be used via COM:devices but
> | in this case I do not even know which device (COM1:, LPT3:, ...) I
> | could try.
> >
> | Any hints where I could further dig in to talk to my printer?
>
> Did you try to contact Brother support desk? Maybe they have some info
> whether your operating mode is available on Windows at all?

I didn't.

But I invested much time in trying this device on Windows at all with
many backstrokes therefore I decided not to invest more time into this
approach.
It is not my main and not my intended system environment.

Bye,
Gerhard

> Other than that, libusb comes to mind (https://libusb.info/) to talk
> directly to the device...
>
> R'
>

Gerhard Reithofer

unread,
Apr 7, 2020, 12:36:46 PM4/7/20
to
Servus Christian,

On Mon, 6 Apr 2020, undro...@gmail.com wrote:

> Servus Gerhard,
>
> if you'd like to have your Raspi a display with touchscreen and a little Tk GUI
> for local management undroidwish is your friend and doesn't require a full blown
> X11 installation since it powers the Raspi's Video Core directly using the "RPI"
> SDL2 video driver.

Undroid ist mostly my main approach but I have the same dependecy from a
specific commercial database, the MS SQL-Server. You may remeber our
disussion according PostgreSQL database access from AndroWish, which I
could manage by using the TCL only PostgreSQL client because this DB is
open source.
If you undroidwish also includes the TDBC module for ODBC then it
shouldn't be a problem, otherwise it may not be possible.

But I also must confess that I haven't tested TCL TDBC on Rapberry at
all, but I was assuming that it exists and works, tdbc and tdbcodbc
packages exist and also the neccessary modules unixodbc and freetds.
Will test it and will contact you if I miss something, as I know that
everything works one day after asking you ;-) :-) :-D

Bye,
0 new messages