-
February 13th, 2019, 09:36 AM
#46
Re: Bill Acceptor Integration
This is not another site. Its only pdf document location.
-
February 13th, 2019, 09:42 AM
#47
Re: Bill Acceptor Integration
Sorry, I see .ru in the URL. That is another site.
Can you post here the parts of the doc that answers my questions?
Norm
-
February 13th, 2019, 09:53 AM
#48
Re: Bill Acceptor Integration
Here is format,
Message Format
From the Host
STX
(02)
Length
(08H)
Msg type
and Ack#
Data
Byte 0
Data
Byte 1
Data
Byte 2
ETX
(03)
Check
Sum
From the
Format is changes thats why am asking you to check with url.
Last edited by Manish009; February 13th, 2019 at 09:55 AM.
-
February 13th, 2019, 10:22 AM
#49
Re: Bill Acceptor Integration
Is the PC considered the host?
Does the contents of the list you posed consist of Strings?
Does a String have a terminating character like \n or \r?
Is there a response for each String the PC sends to the device?
For example, if the PC sends: "STX\n" is the device expected to send a response?
What would the response be?
What does (02) mean?
What is that the format of?
Norm
-
February 13th, 2019, 11:09 AM
#50
Re: Bill Acceptor Integration
Thats why am posting the EBDS document. I dont have knowledge of this.
-
February 13th, 2019, 11:16 AM
#51
Re: Bill Acceptor Integration
I dont have knowledge of this.
It should be discussed in the document.
Have you read the document and considered my questions?
If you have any specific questions about text in the document, post the text from the document with your questions.
My experience with devices (GPS receivers) connected to a PC via a serial connection used protocols where the PC sent a request to the device and the device sent a response. Is that the way the device you are working with is supposed to work?
Norm
-
February 13th, 2019, 12:03 PM
#52
Re: Bill Acceptor Integration
The data sent/received is in the form of messages which have a defined format . There are 2 formats - from the PC (the host) to the device (the Acceptor) and one from the device to the PC.
From the PC each message is 8 bytes
1 byte STX (binary 2)
1 byte binary 8 (length)
1 byte message type
3 bytes of data
1 byte ETX (binary 3)
1 byte checksum - XOR of the 5 bytes between the ATX and the ETX bytes
From the device:
1 byte STX (binary 2)
1 byte binary for 11 (length)
1 byte message type
6 bytes of data
1 byte ETX (binary 3)
1 byte checksum - XOR of the 8 bytes between the ATX and the ETX bytes
Sorry, but I can't help you with Java as I only use c/c++.
Last edited by 2kaud; February 13th, 2019 at 01:26 PM.
Reason: Corected layout
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 13th, 2019, 12:10 PM
#53
Re: Bill Acceptor Integration
The From the device message contents shows 10 bytes but the length is supposed to be 11?
8 bytes between the ATX and the ETX bytes
Is ATX same as STX? Is there a byte missing?
Last edited by Norm; February 13th, 2019 at 12:12 PM.
Norm
-
February 13th, 2019, 12:56 PM
#54
Re: Bill Acceptor Integration
Hi 2Kaud,
Could you please send me the communication code in c/c++. so that i can translate into java or test the device.
-
February 13th, 2019, 01:27 PM
#55
Re: Bill Acceptor Integration
Originally Posted by Norm
The From the device message contents shows 10 bytes but the length is supposed to be 11?
Is ATX same as STX? Is there a byte missing?
Sorry, my bad. There are 6 bytes of data and not 5!
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 13th, 2019, 01:33 PM
#56
Re: Bill Acceptor Integration
Norm
-
February 13th, 2019, 01:43 PM
#57
Re: Bill Acceptor Integration
From previous post, the java code for read was
Code:
{
int len = 0;
while ( ( data = in.read()) > -1 )
{
if ( data == '\n' ) {
break;
}
buffer[len++] = (byte) data;
}
System.out.print(new String(buffer,0,len));
}
I suggest in c++ something like this (NOT tried)
Code:
if (in.read() != 2) // STX
cout << "No start STX\n";
else
if (in.read() != 8) // Length
cout << "Bad length\n";
else {
int check = 8; // Length
byte mess = in.read(); // Message code
check ^= mess;
for (int l = 0; l < 3; ++l) {
buffer[l] = in.read(); // Read the data bytes
check ^= buffer[l];// Computer check sum
}
if (in.read() != 3) // ETX
cout << "No end ETX\n";
else
if (in.read() != check) // Checksum
cout << "Invalid checksum\n";
else {
// Process mess/buffer as needed
}
}
The code for sending would be something similar, but writing bytes rather than reading them.
Another approach rather than indicting an error if first byte is not STX, is to read the input until a STX byte is received.
Code:
while (in.read() != 2); // Loop until STX received
Last edited by 2kaud; February 13th, 2019 at 02:47 PM.
Reason: Tidied up code
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 13th, 2019, 03:22 PM
#58
Re: Bill Acceptor Integration
I write the code to do aread as a method that reads the message and returns an instance of a class that contains the message type and the 3 bytes of data. It would throw an InvalidMessageException if any of the checks failed.
For the write there would be a method that would take the message type and the data to be written, build the message to send and write it.
Norm
-
February 14th, 2019, 04:27 AM
#59
Re: Bill Acceptor Integration
Thanks 2krod
But here am not seen the message format to be write on port.
-
February 14th, 2019, 04:56 AM
#60
Re: Bill Acceptor Integration
Originally Posted by Manish009
Thanks 2krod
But here am not seen the message format to be write on port.
Output is somewhat easier. Consider (NOT tried)
Code:
byte arr[11] = {2, 11};
arr[2] = mess; // Set message byte
arr[3] = data1;
arr[4] = data2;
arr[5] = data3;
arr[6] = data4;
arr[7] = data5;
arr[8] = data6;
arr[9] = 3;
for (int i = 1; i < 9; ++i)
arr[10] ^= arr[i];
for (int i = 0; i < 11; ++i)
out.write(arr[i]);
This assumes that mess is the message and data1...data6 are the 6 data bytes.
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)
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
|