USB PoS Printer advise

Post

Posted
Rating:
#1 (In Topic #1197)
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
 Hi all

I need some advise. I have a fully working module that talks to my Epson TM-88IV thermal printer on comport and it works perfectly

And now I want to try and use a USB version of it

So I have found on my system /dev/usb/lp1 and I can echo to it with no problems

The problem I seem to have is when I try to open the port in my status module I get a error message saying "Stream is closed"

Do I handle usb connected devices differently then serial? Some advice would be welcomed.

I can easily add a option for usb to the current module as long as I know what I need to update (I assume one the dev is open it should still communicate the same within the code)

If anyone needs to see the actual module I can upload that

Andy

Image

Error message on screen

Error message on screen

(Click to enlarge)

Online now: No Back to the top

Post

Posted
Rating:
#2
Guru
BruceSteers is in the usergroup ‘Guru’
how exactly do you try to open it?
Online now: No Back to the top

Post

Posted
Rating:
#3
Avatar
Guru
cogier is in the usergroup ‘Guru’
From what I can see, there is a Linux Printer driver for your printer. Why not install that and just send a page to the printer or as I do with a Zebra Printer, create a PDF file and send that to the printer?
Online now: No Back to the top

Post

Posted
Rating:
#4
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

cogier said

From what I can see, there is a Linux Printer driver for your printer. Why not install that and just send a page to the printer or as I do with a Zebra Printer, create a PDF file and send that to the printer?

If I used the driver I loose all control
Over the printer and I will not get any status about the cash drawer etc from the printer.
Online now: No Back to the top

Post

Posted
Rating:
#5
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

BruceSteers said

how exactly do you try to open it?

I was trying to open it just like a Serial Printer

Code (gambas)

  1.     Global.PrinterPort = New SerialPort As "PrinterPort"
  2.  
  3.     With Global.PrinterPort
  4.         Try .Close
  5.         .PortName = Global.PortName
  6.         .Speed = Global.BandRate
  7.  
  8.         Select Case Global.FlowControl
  9.             Case "Hardware"
  10.                 .FlowControl = Global.PrinterPort.Hardware
  11.  
  12.             Case "Software"
  13.                 .FlowControl = Global.PrinterPort.Software
  14.  
  15.             Case "None"
  16.                 .FlowControl = Global.PrinterPort.None
  17.         End Select
  18.  
  19.         .DataBits = Global.DataBits
  20.         .StopBits = Global.StopBits
  21.  
  22.         Select Case Global.Parity
  23.             Case "None"
  24.                 .Parity = Global.PrinterPort.None
  25.  
  26.             Case "Odd"
  27.                 .Parity = Global.PrinterPort.Odd
  28.  
  29.             Case "Even"
  30.                 .Parity = Global.PrinterPort.Even
  31.         End Select
  32.     End With
  33.    
  34.     Select Case ConnectionType
  35.         Case "Open"
  36.             Try Global.PrinterPort.Open
  37.  
  38.         Case "Close"
  39.             Try Global.PrinterPort.Close
  40.     End Select
  41.  
  42.     If Error Then
  43.         Global.AddToScreenList("Error connecting to printer")
  44.     Else
  45.         Global.AddToScreenList("Connected to printer")
  46.         EpsonPrinterInitialize        
  47.     End If

I know it is not a Serial device so I would need to do some update to my code to work with the USB Printer
Online now: No Back to the top

Post

Posted
Rating:
#6
Avatar
Guru
cogier is in the usergroup ‘Guru’
If I used the driver I loose all control
Over the printer and I will not get any status about the cash drawer etc from the printer.

I found this command online tail -f /var/log/syslog. If you run the command in Terminal, then change the cash draw status, you may be able to see it as it happens. (Press [Ctrl]+C to exit). Every time I changed a USB, or turned a printer on, data poured in.
Online now: No Back to the top

Post

Posted
Rating:
#7
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’

cogier said

If I used the driver I loose all control
Over the printer and I will not get any status about the cash drawer etc from the printer.

I found this command online tail -f /var/log/syslog. If you run the command in Terminal, then change the cash draw status, you may be able to see it as it happens. (Press [Ctrl]+C to exit). Every time I changed a USB, or turned a printer on, data poured in.

Hi cogier I tried that and I get nothing showing up

I have install my development IDE (gamabs3) onto the PoS Terminal that has the USB printer attached (/dev/usb/lp0) I have chmod 777 the port so anyone can access it and when I run the printer module now insde the IDE I get the following error message "Unable to get configuration: Inappropriate ioctl for device"

I was setting it to /dev/usb/lp0 and speed of 115200

am I thinking along the right lines for the USB Printer or do I need to re think this?
Online now: No Back to the top

Post

Posted
Rating:
#8
Enthusiast
AndyGable is in the usergroup ‘Enthusiast’
After a lot of googling and asking ChatGPT I have come up with the following code (Still needs work though)

Code (gambas)

  1.     Global.PrinterPort = New SerialPort As "PrinterPort"
  2.  
  3.     With Global.PrinterPort
  4.         Try .Close
  5.         .PortName = Global.PortName
  6.     End With
  7.    
  8.     Select Case ConnectionType
  9.         Case "Open"
  10.             Try Global.PrinterPort.Open
  11.  
  12.         Case "Close"
  13.             Try Global.PrinterPort.Close
  14.     End Select
  15.  
  16.     If Error Then
  17.         Global.AddToScreenList("Error connecting to USB Printer")
  18.     Else
  19.         Global.AddToScreenList("Connected to USB Printer")
  20.         EpsonPrinterInitialize        
  21.     End If  

But I am still getting a Error connecting to USB Printer and then the same error message steam is closed (#53) could some one have a look and see if I am on the right lines (should the device not show up as a /dev/ttyUSB and not /dev/usb/lp1 (im on debian))


Chatgpt  came up with this one

Code (gambas)

  1. Public sub Main()
  2.  Dim SerialPort as Serial
  3.  
  4. SerialPort = New Serial("/dev/usb/lp1")
  5.  
  6.   'Send Commands
  7.   Serial.write ("your commands here")
  8.   serial.close
  9.   Print "Error Opening Serial (USB) Device"

Of course I have had to update it to work
Online now: No Back to the top
1 guest and 0 members have just viewed this.