Help getting status of cash drawer in Gambas

Post your Gambas programming questions here.
Post Reply
AndyGable
Posts: 349
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Help getting status of cash drawer in Gambas

Post by AndyGable »

Reference https://reference.epson-biz.com/modules ... =124#gs_lr

Hi all,

The above page shows how I can get the status of the attached cash drawer on a Epson printer could someone please show me how it would convert into Gambas? I ask as I have a sort of working code in FreeBASIC but I am not sure as to how I can convert it to Gambas code.

Once this has been figure this out then all I need to do is work out how to process the status of the printer it self (that is normally low paper, cover open or offline)
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Help getting status of cash drawer in Gambas

Post by cogier »

I have a sort of working code in FreeBASIC but I am not sure as to how I can convert it to Gambas code.
Please post the FreeBASIC code? That may help us to help you, as I suspect no one will have your printer to experiment on.
AndyGable
Posts: 349
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Help getting status of cash drawer in Gambas

Post by AndyGable »

cogier wrote: Monday 17th January 2022 2:30pm
I have a sort of working code in FreeBASIC but I am not sure as to how I can convert it to Gambas code.
Please post the FreeBASIC code? That may help us to help you, as I suspect no one will have your printer to experiment on.
Well it seems I do not have working code in FreeBASIC i have looked at all my Code projects and For some reason in the past
I removed the cash drawer support and now I can not find the code I did.

I am looking at my emails to see if I can find the email with the code on but I am sorry at this moment in time I do not have the code
AndyGable
Posts: 349
Joined: Wednesday 2nd December 2020 12:11am
Location: Northampton, England
Contact:

Re: Help getting status of cash drawer in Gambas

Post by AndyGable »

I have finally found something from 2012 that was used to test the status of the cash drawer (and I am not sure if it works or not but
it should give a idea of what to do with the Epson code)

Code: Select all

Dim status As String
	
	Open COM "COM1:9600,N,8,1,CD0,CS0,DS0,rs" As #1
	
	Print #1, Chr(10) & Chr(4) & 1
	
	While Loc(1) =0
		Sleep 1
	Wend
	
	status = Input(Loc(1), 1)
	
	Print Bin(Val(status),8)
	
	If Bit(Val(status), 3) = -1 Then
		Print "Kickout connector high"
	Else
		Print "Kickout connector low"
	EndIf
	
	If Bit(Val(status), 4) = -1 Then
		Print "Offline"
	Else
		Print "Online"
	EndIf
	
	If Bit(Val(status), 6) = -1 Then
		Print "Waiting for Online Recovery"
	Else
		Print "Not Waiting for Online Recovery"
	EndIf
	
	If Bit(Val(status), 7) = -1 Then
		Print "Paper fed by button"
	Else
		Print "Paper not fed by button"
	EndIf
	
	Close #1

if i remember right it should get the status from the printer and load it into the location called status and then print this to the screen (example 00000000) this will change depending on the status of the printer (if the cash drawer is open then it should look something like this 00100000)

I hope this helps someone to point me in the right direction
User avatar
cogier
Site Admin
Posts: 1117
Joined: Wednesday 21st September 2016 2:22pm
Location: Guernsey, Channel Islands

Re: Help getting status of cash drawer in Gambas

Post by cogier »

You should look at the code already put up for you here.

From that, you should be able to change the Sport SerialPort command using the details from your earlier code. Have a look in your /dev folder to get the correct name of your serial port.

Further help is available here.
Post Reply