fix indexing for tokens

This commit is contained in:
Andrew Welker
2021-06-09 16:41:49 -06:00
parent e137edec73
commit 0a77b8681d
3 changed files with 3 additions and 3 deletions

View File

@@ -29,7 +29,7 @@ namespace PepperDash.Core.Intersystem.Tokens
public override byte[] GetBytes()
{
return new[] {
(byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index >> 7)),
(byte)(0xC0 | ((Value & 0xC000) >> 10) | (Index-1 >> 7)),
(byte)((Index - 1) & 0x7F),
(byte)((Value & 0x3F80) >> 7),
(byte)(Value & 0x7F)

View File

@@ -29,7 +29,7 @@ namespace PepperDash.Core.Intersystem.Tokens
public override byte[] GetBytes()
{
return new[] {
(byte)(0x80 | (Value ? 0 : 0x20) | (Index >> 7)),
(byte)(0x80 | (Value ? 0 : 0x20) | ((Index - 1) >> 7)),
(byte)((Index - 1) & 0x7F)
};
}

View File

@@ -32,7 +32,7 @@ namespace PepperDash.Core.Intersystem.Tokens
var serialBytes = String.IsNullOrEmpty(Value) ? new byte[0] : Encoding.GetEncoding(28591).GetBytes(Value);
var xsig = new byte[serialBytes.Length + 3];
xsig[0] = (byte)(0xC8 | (Index >> 7));
xsig[0] = (byte)(0xC8 | (Index-1 >> 7));
xsig[1] = (byte)((Index - 1) & 0x7F);
xsig[xsig.Length - 1] = 0xFF;