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."
and
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");
}