ESC-POS-.NET icon indicating copy to clipboard operation
ESC-POS-.NET copied to clipboard

Invalid argument when creating SerialPrinter object on Linux (Ubuntu 14.04)

Open KyryloAntoshyn opened this issue 4 years ago • 13 comments

Hi, I am trying to leverage you library in Ubuntu 14.04.

I have printer connected via USB. To communicate with it I try to use SerialPrinter class. According to the documentation I pass "/dev/ttyUSB0" file and 9600 baud rate. This file and baud rate are for my printer, I rechecked it. However, when I try to create SerialPrinter object I have exception: Unhandled exception. System.IO.IOException: Invalid argument. I use code from the documentation steps.

image

Why does it happen and how can I fix it?

Thanks in advance!

KyryloAntoshyn avatar Jul 08 '20 07:07 KyryloAntoshyn

That’s great that you’re trying it out Ubuntu! I haven’t tested the library on Linux in quite a while, since it used serialportsrream instead of system.io.ports, but we should be able to get it working.

Can you provide the code you are using to test? Have you tried pulling the code from GitHub and using the console test app?

Are you testing from an x86 machine or an ARM like a raspberry pi?

It sounds like your params to the serial port constructor may be messed up.

Any reason you’re using 9600? For USB you can use a much higher baud rate typically (I use 115200). It should speed up your printing quite a bit.

On Wed, Jul 8, 2020 at 2:08 AM Kyrylo Antoshyn [email protected] wrote:

Hi, I am trying to leverage you library in Ubuntu 14.04.

I have printer connected via USB. To communicate with it I try to use SerialPrinter class. According to the documentation I pass "/dev/ttyUSB0" file and 9600 baud rate. This file and baud rate are for my printer, I rechecked it. However, when I try to create SerialPrinter object I have exception: Unhandled exception. System.IO.IOException: Invalid argument. I use code from the documentation steps.

[image: image] https://user-images.githubusercontent.com/26432700/86888334-aa54c900-c102-11ea-8505-11d950c02b56.png

Why does it happen and how can I fix it?

Thanks in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lukevp/ESC-POS-.NET/issues/63, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJRNSEPBM4IDNADNPF45HDR2QLNHANCNFSM4OUID3SA .

lukevp avatar Jul 08 '20 12:07 lukevp

I fixed the issue today and everything works. I changed my 25-pin–usb cable to usb-usb and used FilePrinter class like you did in ConsoleTest application. It works fine now. ConsoleTest also works fine.

I had my error on ARM Ubuntu 14.04. I used plain code from the readme of the library: image I choose 9600 baud rate, because system provided me this value for /dev/ttyUSB0 port.

KyryloAntoshyn avatar Jul 08 '20 18:07 KyryloAntoshyn

I closed the issue, thanks for your attention. If you have more questions about the issue ask me here and I will try to answer.

KyryloAntoshyn avatar Jul 08 '20 18:07 KyryloAntoshyn

Glad you figured it out! That does sound familiar. In case this affects you, the FilePrinter is write only, so you will not be able to get status messages back (eg. paper out, door open). That is only implemented in the SerialPrinter right now. If you need that functionality, we probably just need to change the serial printer setup to work on Linux too. If so, reopen this and we'll look into it.

lukevp avatar Jul 08 '20 19:07 lukevp

Yes, it is necessary for me to have the "empty paper" message in a production environment. I reopen this issue and we need to make SerialPrinter working on Linux. Thanks!

KyryloAntoshyn avatar Jul 09 '20 06:07 KyryloAntoshyn

@KyryloAntoshyn could you confirm what version of the library you are using and if it is from Nuget or GitHub?

Is it possible for you to try to build the Console Test project in this repo from the latest master/ and see if it works or not?

I won't have time to look at this myself until the weekend, but I can try and guide you through this.

lukevp avatar Jul 09 '20 15:07 lukevp

I can do it next week and send you the app.

KyryloAntoshyn avatar Jul 10 '20 15:07 KyryloAntoshyn

Hi, here is test app which references your library from GitHub. Exception occurs when I create SerialPrinter object. My printer's virtual port is /dev/ttyUSB0, you can see it in code.

SerialPrinterTest.zip

KyryloAntoshyn avatar Jul 15 '20 15:07 KyryloAntoshyn

hey @KyryloAntoshyn the lib has been updated a few times since this issue was open. Could you check and see if this is still an issue with the latest version?

lukevp avatar Nov 29 '20 00:11 lukevp

Hi, @lukevp. I will test library as soon as possible.

KyryloAntoshyn avatar Dec 02 '20 13:12 KyryloAntoshyn

I have downloaded latest NuGet library version. I have Epson TM-T70 printer connected via USB. When I am trying to create SerialPrinter object the error occurs:

Code: var printer = new SerialPrinter(portName: "/dev/usb/lp0", baudRate: 115200);

Error: image

KyryloAntoshyn avatar Dec 17 '20 11:12 KyryloAntoshyn

Is it possible to use FilePrinter and check for paper status now? FilePrinter works well.

KyryloAntoshyn avatar Dec 17 '20 11:12 KyryloAntoshyn

It is not problem. I always use FileStream class for USB ports printers. It does not need baudrate, parity, handshake and other shit.

Rombersoft avatar Sep 12 '21 20:09 Rombersoft