-
February 5th, 2019, 06:51 AM
#16
Re: Bill Acceptor Integration
When code is running and connecting bill acceptor i got this output
event listner calling == gnu.io.SerialPortEvent[source=//./COM5] and after i insert the bill no event fired or pulse recieved.
-
February 5th, 2019, 06:58 AM
#17
Re: Bill Acceptor Integration
i got this output
event listner calling == gnu.io.SerialPortEvent[source=//./COM5]
The red part of that message is text in the program that is printed with a println method
The green part could be what is read from the serial port that is printed with a print method
I don't understand why those two Strings are on the same line. The red String is printed using the println method which means that the next String that is printed should be on the next line.
Last edited by Norm; February 5th, 2019 at 07:04 AM.
Norm
-
February 5th, 2019, 07:12 AM
#18
Re: Bill Acceptor Integration
this is the statement
System.out.println("event listner calling == "+arg0);
thats why it print both simultaneously.
Last edited by Manish009; February 5th, 2019 at 07:15 AM.
-
February 5th, 2019, 07:20 AM
#19
Re: Bill Acceptor Integration
this is the statement
System.out.println("event listner calling == "+arg0);
I do not see that statement in the posted code. Do you have different versions of the program?
Please post the code for the program that you are using for testing.
Add a print statement inside of the while loop that prints each value of data as it is read so you can see if anything is being read from the serial port.
Last edited by Norm; February 5th, 2019 at 07:28 AM.
Norm
-
February 5th, 2019, 07:40 AM
#20
Re: Bill Acceptor Integration
-
February 5th, 2019, 07:48 AM
#21
Re: Bill Acceptor Integration
Below is the code nothing is updated except this statement
System.out.println("event listner calling == "+arg0); and output is same as previous.
Code:
package com;
import gnu.io.CommPort;
import gnu.io.CommPortIdentifier;
import gnu.io.SerialPort;
import gnu.io.SerialPortEvent;
import gnu.io.SerialPortEventListener;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* This version of the TwoWaySerialComm example makes use of the
* SerialPortEventListener to avoid polling.
*
*/
public class TwoWaySerialComm
{
public TwoWaySerialComm()
{
super();
}
void connect ( String portName ) throws Exception
{
CommPortIdentifier portIdentifier = CommPortIdentifier.getPortIdentifier(portName);
if ( portIdentifier.isCurrentlyOwned() )
{
System.out.println("Error: Port is currently in use");
}
else
{
CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);
if ( commPort instanceof SerialPort )
{
SerialPort serialPort = (SerialPort) commPort;//BAUDRATE_9600
serialPort.setSerialPortParams(115200,SerialPort.DATABITS_8,SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
System.out.println("getParity() == "+serialPort.getParity()+"getName()=="+serialPort.getName());
InputStream in = serialPort.getInputStream();
OutputStream out = serialPort.getOutputStream();
System.out.println("input stream object :---"+in);
System.out.println("output stream object :--"+out);
(new Thread(new SerialWriter(out))).start();
System.out.println("listening................"+serialPort.getName());
serialPort.addEventListener(new SerialReader(in));
serialPort.notifyOnDataAvailable(true);
}
else
{
System.out.println("Error: Only serial ports are handled by this example.");
}
}
}
/**
* Handles the input coming from the serial port. A new line character
* is treated as the end of a block in this example.
*/
public static class SerialReader implements SerialPortEventListener
{
private InputStream in;
private byte[] buffer = new byte[1024];
public SerialReader ( InputStream in )
{
this.in = in;
}
public void serialEvent(SerialPortEvent arg0) {
int data;
System.out.println("event listner calling == "+arg0);
try
{
System.out.println("inside try");
int len = 0;
while ( ( data = in.read()) > -1 )
{
if ( data == '\n' ) {
System.out.println("data inside loop ="+data);
break;
}
buffer[len++] = (byte) data;
}
System.out.print(new String(buffer,0,len));
}
catch ( IOException e )
{
e.printStackTrace();
System.exit(-1);
}
}
}
/** */
public static class SerialWriter implements Runnable
{
OutputStream out;
public SerialWriter ( OutputStream out )
{
this.out = out;
}
public void run ()
{
try
{ System.out.println("calling thread");
int c = 0;
System.out.println("System.in.read() === "+System.in.read());
while ( ( c = System.in.read()) > -1 )
{
this.out.write(c);
System.out.println("in run method == "+this.out);
}
}
catch ( IOException e )
{
e.printStackTrace();
System.exit(-1);
}
}
}
public static void main ( String[] args )
{
try
{
(new TwoWaySerialComm()).connect("COM5");
}
catch ( Exception e )
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
Last edited by 2kaud; February 5th, 2019 at 07:56 AM.
Reason: Added code tags
-
February 5th, 2019, 07:55 AM
#22
Re: Bill Acceptor Integration
A manual that describes the ebds protocol is at http://gamingparts.eu/downloadfiles/197.pdf - unless you have a specific manual for the ebds interface for AE 2831 D10 E?
Page 16 describes the interface. The first question is how is the 12 pin ebds connector connected to the serial port of the computer?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 5th, 2019, 07:58 AM
#23
Re: Bill Acceptor Integration
[When posting code, please use code tags. Go Advanced, select the formatted code and click '#'].
Cheers.
Moderator
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 5th, 2019, 08:07 AM
#24
Re: Bill Acceptor Integration
Thanks for your comments @Kaud !
Am stuck bill acceptor integration need help.
-
February 5th, 2019, 08:15 AM
#25
Re: Bill Acceptor Integration
Yes - but you haven't answered my question. Physically, exactly how is the bill acceptor using the ebds interface connected to the computer?
All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!
C++23 Compiler: Microsoft VS2022 (17.6.5)
-
February 5th, 2019, 08:18 AM
#26
Re: Bill Acceptor Integration
output is same as previous.
Try adding a print statement inside of the while loop that prints the value of data.
To see if anything is being read.
Last edited by Norm; February 5th, 2019 at 08:23 AM.
Norm
-
February 5th, 2019, 08:23 AM
#27
Re: Bill Acceptor Integration
Actually am working on to integrate bill acceptor through serial port and event fired on that port.
I worked on this approach.
But this bill acceptor also support EBDS protocol so according to me this is the another way of doing integration.
So i dont know about this as well.
-
February 5th, 2019, 08:24 AM
#28
Re: Bill Acceptor Integration
Norm,
Yes added print statement but did not get any response .
-
February 5th, 2019, 08:27 AM
#29
Re: Bill Acceptor Integration
Last edited by Manish009; February 5th, 2019 at 08:30 AM.
-
February 5th, 2019, 08:29 AM
#30
Re: Bill Acceptor Integration
Yes added print statement but did not get any response .
The print statement in the posted code is in the wrong place. It will only execute if the value of data is '\n'
You want to see ALL of the values of data, not just the one.
Move that print statement outside of the if statement so that it always executes.
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|