1
votes

I have a tg 2460 CUSTOM ticket printer that has ESC/POS emulation, USB connected in debian linux. I'm trying to get the status of the printer in my qt c++ program with the command but with no response.

I use QFile class to deal with it, opening the device directly eg dev/usblp0 seems to bring no results so i open the mounted device eg dev/usb/lp0 and i am able to control the printer OK, but when i write the "\x10\x04\x01" command (transmission of status in real time) or any other command that implies a response i cannot get data back, using read() or readAll() hangs forever blocking the process, so how can i receive data? forgive me if i'm missing something basic

1
On which operating system? I guess some Linux, but you need to add the linux tag. Also, show some minimal reproducible exampleBasile Starynkevitch

1 Answers

0
votes

You probably want to use QSocketNotifier, assuming you are on Linux.

On Linux, QSocketNotifier works with any poll(2)-able file descriptor (so it is somehow incorrectly named, since you can use it on non-socket file descriptors).

(On Windows, things are incompatibly different)

BTW, you might want to use CUPS on your POS system. You could then run some lp (or lpr) command to print things (thru some pipe(7)), perhaps thru QProcess. And you'll use HTTP technology -client side- (so Qt Network) to query CUPS.

Read also about Qt Print Support.

Consider also debugging not only with gdb but also with strace(1).