Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MICROS 8700 Returned Fixed Message Format not logged

Status
Not open for further replies.

MaxByrne

IS-IT--Management
Nov 9, 2018
3
IE
Hello all

I am working on an interface between a POS sending MICROS 8700 fixed message over serial com port and our PMS.
My experience is in C#, MVC, AJAX, webapp side and more modern technologies. I am pretty lost with all the COM serial port communication and Micros emulation, but have done what I can.

I have created a C# windows service that receives the message and (from what I can see) returns a message.
The POS software sends its message via a serial COM port.
I have 3rd party software in the middle that converts this to TCP.(I can see data passing from the POS and to the POS on this 3rd party software.)

My software is listening on a specific TCP port.
It receives the byte stream fine.
converts to ASCII string.
a checksum is created based on the string, but without including SOH, and up to and including the ETX character. Link
the response is converted to a Byte array using ASCII Encoding.
It replies with, what I believe is the correct format, but it is not logged by the POS software.
I was working on the theory that my checksum wasn't being calculated correctly, but I have had no progress when changing how the checksum is determined.

I start every message with SOH (\u0001) character and end with EOT (\u0004). I also separate the message with STX (\u0002) and ETX (\u0003)

I can't even get a basic error message to be logged.
Just so I don't seem lazy/incompetent, all I have to work from is an example log file and what I can find on the internet.
I think I need "1000/2000/4700/8700 pms interface specifications manual" but I can't get a copy of this.

My program receives the message
 1Rev 1  1 120 2001069B
which is
SOH 1Rev 1 STX 1 120 2001ETX069BEOT

and my program responds with
 1Rev 1  1/INVALID ENTRY 0AC5
which is
SOH 1Rev 1 STX 1/INVALID ENTRY ETX0AC5EOT
SOH terminal ID STX 1/INVALID ENTRY ETXchecksumEOT

Sometimes, every 30 seconds when the connection times out from the POS side, the first character of the reply shows up in the POS logs, but I believe that has something to do with buffers.

Maybe I'm sending something very wrong and the POS software isn't getting what it expects so it doesn't log/process it.

I am sending EOT, which I believe tells the POS that the message is finished, and the windows service also closes the stream. So I don't think the POS is waiting for the end of the message.

I have read some posts on this forum from
@Moregelen
Link
Link
Link

Really I would like some suggestion on how to generate the checksum, or any other suggestions as to what my problem might be.
please see the two different checksum code blocks I have tried.

From Link
"The Checksum is the 16-bit binary addition (excluding parity, if applicable) of all
characters after the SOH, up to and including the ETX character. The Checksum is
initially set to zero. For transmission, the Checksum is represented as four ASCII-Hex
characters."

Code:
private static string GetChecksum(string data)
        {
            short checksum = 0;
            int byteCount = data.Length;
            int index = 0;
            char current;
            byte intOffset = 48;
            byte alphaOffset = 55;
            byte scale = 16;

            if (byteCount < 2) // bad string
                return "Error";

            while (index < byteCount - 1)
            {
                current = data[index++];
                if (current < 'A')
                {
                    checksum += (byte)(((byte)current - intOffset) * scale);
                }
                else
                {
                    checksum += (byte)(((byte)current - alphaOffset) * 16);
                }
                current = data[index++];
                if (current < 'A')
                {
                    checksum += (byte)(((byte)current - intOffset));
                }
                else
                {
                    checksum += (byte)(((byte)current - alphaOffset));
                }
                index++;
            }
            return checksum.ToString("X4");
        }

and

Code:
private static string GetChecksum(string s)
        {
            int checksum = 0;

            byte[] binary = Encoding.ASCII.GetBytes(s);

            foreach (byte b in binary)
            {
                checksum = ((checksum + b) & 0xFF);
            }
            checksum = (((checksum ^ 0xFF) + 1) & 0xFF);
            return checksum.ToString("X4");
        }







 
Turns out I needed to reply with an ACK
Decimal Octal Hex Binary Character
006 006 0x06 00000110 ACK (Acknowledgment)
or for C#
Code:
static char ACK = '\u0006';


byte[] ackMsg = System.Text.Encoding.ASCII.GetBytes(ACK.ToString());
                            stream.Write(ackMsg, 0, ackMsg.Length);

 
Also got the checksum code working correctly too.

now my responses are validated and displayed by the software.
"ASCII characters, representing a checksum. There
are always 4 numbers. They are HEX (0 through 9 are
represented by hex 0x30 .. 0x39, and A-F are represented by
Hex 0x41 through 0x46). Checksum is computed by initially
setting it to 0, then adding all the characters starting
with (but NOT INCLUDING) <soh>, and through (and INCLUDING)
<etx> character. The resulting number is then represented
using ASCII characters and placed in the message
"

Code:
    private static string GetChecksum(string s)
        {//this gives matching checksums
            int checksum = 0;

            byte[] binary = Encoding.ASCII.GetBytes(s);

            foreach (byte b in binary)
            {
                checksum = ((checksum + b));
            }
            return checksum.ToString("X4");
        }

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top