Ejemplo n.º 1
0
        public static void PostPublishDown(IHttpContext context)
        {
            string payload = context.Request.Payload;
            // payload: source, publish

            string source = "";

            // string publish = "";

            try
            {
                TransmitFrame tf = new TransmitFrame();
                tf     = Newtonsoft.Json.JsonConvert.DeserializeObject <TransmitFrame>(context.Request.Payload);
                source = tf.source;

                Console.WriteLine(countWriteLine++ + " PostPublishDown " + source + " -> " + sourceName);

                if (source != "" && tf.data.Count != 0 && childs.Count != 0)
                {
                    for (int i = 0; i < publishResponse.Length; i++)
                    {
                        if (publishResponse[i] == null)
                        {
                            publishResponse[i] = tf.data;
                            if (childs.Count != 0)
                            {
                                publishResponseChilds[i] = new List <string> {
                                };
                                foreach (string value in childs)
                                {
                                    publishResponseChilds[i].Add(value);
                                }
                            }
                            break;
                        }
                    }
                }
            }
            catch
            {
            }

            string responseJson = "";

            if (publishRequest.Count != 0)
            {
                TransmitFrame response = new TransmitFrame();
                response.source = sourceName;
                response.data   = publishRequest;

                responseJson = JsonConvert.SerializeObject(response, Formatting.Indented);
                publishRequest.Clear();
            }

            context.Response.ContentType     = ContentType.JSON;
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentLength64 = responseJson.Length;
            context.Response.SendResponse(responseJson);
        }
Ejemplo n.º 2
0
        public static async void ThreadLoop()
        {
            while (true)
            {
                // Test data to publish
                string testPublish = "";
                if (testRequest == "")
                {
                    testPublish = "{ \"source\" : \"" + sourceName + "\" , \"count\" : \"" + count + "\" }";
                    count++;
                }
                else
                {
                    testPublish = await getTestData(testRequest);
                }

                TransmitData td = new TransmitData();
                td.source = sourceName; // must be a unique name in the overall node network
                td.type   = "test";     // AASX Server publishes type "submodel"
                td.publish.Add(testPublish);

                TransmitFrame tf = new TransmitFrame();
                tf.source = sourceName;
                tf.data.Add(td);

                string publish = JsonConvert.SerializeObject(tf, Formatting.Indented);
                Console.WriteLine("Publish data:\n" + publish + "\n");

                var handler = new HttpClientHandler();
                handler.DefaultProxyCredentials = CredentialCache.DefaultCredentials;
                var client = new HttpClient(handler);

                string content = "";
                try
                {
                    var contentJson = new StringContent(publish, System.Text.Encoding.UTF8, "application/json");
                    var result      = client.PostAsync(connectDomain + "/publish", contentJson).Result;
                    content = ContentToString(result.Content);
                }
                catch
                {
                    Console.WriteLine("ERROR: Publish Timeout!\n");
                }

                if (content != "")
                {
                    // Received JSON content as TransmitFrame
                    Console.WriteLine("Received Subscribe Data:\n" + content + "\n");
                }

                Thread.Sleep(3000);
            }
        }
Ejemplo n.º 3
0
        // Just publish, no /connect before needed
        public static void PostPublish(IHttpContext context)
        {
            string source       = "";
            string responseJson = "";

            try
            {
                TransmitFrame tf = new TransmitFrame();
                tf     = Newtonsoft.Json.JsonConvert.DeserializeObject <TransmitFrame>(context.Request.Payload);
                source = tf.source;

                if (!childs.Contains(source))
                {
                    childs.Add(source);
                }

                responseJson = executeTransmitFrames(tf);

                DateTime now = DateTime.UtcNow;
                lock (timeStampLock)
                {
                    if (!childsTimeStamps.ContainsKey(source))
                    {
                        childsTimeStamps.Add(source, now);
                    }
                    else
                    {
                        childsTimeStamps[source] = now;
                    }
                }

                // Console.WriteLine(countWriteLine++ + " PostPublish " + source + " " + now);
            }
            catch
            {
            }

            context.Response.ContentType     = ContentType.JSON;
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentLength64 = responseJson.Length;
            context.Response.SendResponse(responseJson);
        }
Ejemplo n.º 4
0
        public static void PostPublishUp(IHttpContext context)
        {
            string source       = "";
            string responseJson = "";

            try
            {
                TransmitFrame tf = new TransmitFrame();
                tf     = Newtonsoft.Json.JsonConvert.DeserializeObject <TransmitFrame>(context.Request.Payload);
                source = tf.source;

                Console.WriteLine(countWriteLine++ + " PostPublishUp " + source);

                responseJson = executeTransmitFrames(tf);
            }
            catch
            {
            }

            context.Response.ContentType     = ContentType.JSON;
            context.Response.ContentEncoding = Encoding.UTF8;
            context.Response.ContentLength64 = responseJson.Length;
            context.Response.SendResponse(responseJson);
        }
Ejemplo n.º 5
0
        public static TransmitFrame TransmitFrameBuild(Station stl, Station.CommandResponse cmdResp, Int32 pfBit, FrameTypes frameType, Byte[] buf)
        {
            //
            // Build AX25 frames
            //
            Int32 doBufLen = 0;

            if (buf != null)
            {
                doBufLen = buf.Length;
            }

            TransmitFrame transmitFrame = new TransmitFrame();

            Byte[] stlB = stl.GetStationAddresBuffer(cmdResp);

            transmitFrame.ibuf        = new Byte[stlB.Length + 1 + doBufLen];
            transmitFrame.frameType   = frameType;
            transmitFrame.pfBit       = pfBit;
            transmitFrame.seqNumMode  = SequenceNumberMode.Mod8;
            transmitFrame.cmdOctetPtr = stlB.Length;

            if (cmdResp.Equals(Station.CommandResponse.DoCommand) && pfBit == 1) // (JNW Jan15)
            {
                transmitFrame.AckModeID = 0xff;                                  // Use ackmode if enabled  (JNW Jan15)
            }
            stlB.CopyTo(transmitFrame.ibuf, 0);                                  // Load station address fields
            transmitFrame.ibuf[stlB.Length] = (Byte)(((Int32)frameType) | (pfBit << 4));

            if (doBufLen > 0)
            {
                buf.CopyTo(transmitFrame.ibuf, stlB.Length + 1);
            }

            return(transmitFrame);
        }
Ejemplo n.º 6
0
        public static void ThreadLoop()
        {
            while (loop)
            {
                // testing
                if (test)
                {
                    string       testPublish = "{ \"source\" : \"" + sourceName + "\" , \"count\" : \"" + count + "\" }";
                    TransmitData td          = new TransmitData();
                    td.source = sourceName;
                    td.publish.Add(testPublish);

                    if (childs.Count == 0)
                    {
                        if (++newData == 4)
                        {
                            newData = 0;
                            if (sourceName == "TEST1" || sourceName == "TEST2" || sourceName == "TEST3")
                            {
                                publishRequest.Add(td);
                            }
                        }
                    }

                    count += 5;
                }

                if (parentDomain != "GLOBALROOT" && parentDomain != "LOCALROOT")
                {
                    TransmitFrame tf = new TransmitFrame();
                    tf.source = sourceName;

                    string publish = JsonConvert.SerializeObject(tf, Formatting.Indented);

                    if (publishRequest.Count != 0)
                    {
                        tf.data = publishRequest;
                        publish = JsonConvert.SerializeObject(tf, Formatting.Indented);
                        publishRequest.Clear();
                    }

                    HttpClient httpClient2;
                    if (clientHandler != null)
                    {
                        httpClient2 = new HttpClient(clientHandler);
                    }
                    else
                    {
                        httpClient2 = new HttpClient();
                    }

                    var contentJson = new StringContent(publish, System.Text.Encoding.UTF8, "application/json");;

                    string content = "";
                    try
                    {
                        var result = httpClient2.PostAsync(parentDomain + "/publishUp", contentJson).Result;
                        content = ContentToString(result.Content);
                    }
                    catch
                    {
                    }

                    if (content != "")
                    {
                        string source = "";
                        // string response = "";

                        try
                        {
                            TransmitFrame tf2 = new TransmitFrame();
                            tf2 = Newtonsoft.Json.JsonConvert.DeserializeObject <TransmitFrame>(content);

                            source = tf2.source;

                            // if (source == sourceName)
                            {
                                Console.WriteLine(countWriteLine++ + " RECEIVE PostPublishUp " + source + " : " + content);
                                if (childs.Count != 0)
                                {
                                    for (int i = 0; i < publishResponse.Length; i++)
                                    {
                                        if (publishResponse[i] == null)
                                        {
                                            publishResponse[i] = tf2.data;
                                            if (childs.Count != 0)
                                            {
                                                publishResponseChilds[i] = new List <string> {
                                                };
                                                foreach (string value in childs)
                                                {
                                                    publishResponseChilds[i].Add(value);
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                    }
                }

                // pass data down to/from local root childs
                if (childDomainsCount != 0)
                {
                    TransmitFrame response = new TransmitFrame();
                    response.source = sourceName;

                    for (int i = 0; i < publishResponse.Length; i++)
                    {
                        if (publishResponse[i] != null)
                        {
                            response.data = publishResponse[i];
                            for (int j = 0; j < childDomainsCount; j++)
                            {
                                if (publishResponseChilds[i] != null)
                                {
                                    if (publishResponseChilds[i].Contains(childDomainsNames[j]))
                                    {
                                        publishResponseChilds[i].Remove(childDomainsNames[j]);
                                        if (publishResponseChilds[i].Count == 0)
                                        {
                                            publishResponse[i] = null;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    string responseJson = "";
                    responseJson = JsonConvert.SerializeObject(response, Formatting.Indented);

                    HttpClient httpClient;
                    httpClient = new HttpClient();

                    /*
                     * if (clientHandler != null)
                     * {
                     *  httpClient = new HttpClient(clientHandler);
                     * }
                     * else
                     * {
                     *  httpClient = new HttpClient();
                     * }
                     */

                    for (int i = 0; i < childDomainsCount; i++)
                    {
                        var contentJson = new StringContent(responseJson, System.Text.Encoding.UTF8, "application/json");;

                        string content = "";
                        try
                        {
                            var result = httpClient.PostAsync(childDomains[i] + "/publishDown", contentJson).Result;
                            content = ContentToString(result.Content);
                        }
                        catch
                        {
                        }

                        if (content != "")
                        {
                            try
                            {
                                TransmitFrame tf1 = new TransmitFrame();
                                tf1 = Newtonsoft.Json.JsonConvert.DeserializeObject <TransmitFrame>(content);

                                string source = tf1.source;
                                // Console.WriteLine(countWriteLine++ + " RECEIVE PostPublishDown " + source + " : " + content);
                                Console.WriteLine(countWriteLine++ + " RECEIVE PostPublishDown " + source);

                                if (tf1.data.Count != 0)
                                {
                                    foreach (TransmitData td in tf1.data)
                                    {
                                        publishRequest.Add(td);
                                    }
                                    if (parentDomain == "GLOBALROOT")
                                    {
                                        // copy publish request into response
                                        for (int j = 0; j < publishResponse.Length; j++)
                                        {
                                            if (publishResponse[j] == null)
                                            {
                                                publishResponse[j] = tf1.data;
                                                if (childs.Count != 0)
                                                {
                                                    publishResponseChilds[j] = new List <string> {
                                                    };
                                                    foreach (string value in childs)
                                                    {
                                                        publishResponseChilds[j].Add(value);
                                                    }
                                                }
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                }

                Thread.Sleep(500);
            }
        }
Ejemplo n.º 7
0
        public static string executeTransmitFrames(TransmitFrame tf)
        {
            string source = tf.source;

            Console.WriteLine("source: " + source);

            if (source != "" && tf.data.Count != 0)
            {
                Console.WriteLine("tf.data.count " + tf.data.Count);

                countWriteLine++;
                foreach (TransmitData tdr in tf.data)
                {
                    Console.WriteLine("*** RECEIVE " + countWriteLine + " " + source + ": " + tdr.type + " " + tdr.source + " " + tdr.destination);
                }

                TransmitData fileReceived = null;
                foreach (TransmitData td in tf.data)
                {
                    if (td.type == "getaasxFile" && td.destination == sourceName)
                    {
                        Console.WriteLine("Received AASX from " + td.source + " for " + td.destination);

                        var parsed3 = JObject.Parse(td.publish[0]);

                        string fileName = parsed3.SelectToken("fileName").Value <string>();
                        string fileData = parsed3.SelectToken("fileData").Value <string>();

                        var enc         = new System.Text.ASCIIEncoding();
                        var fileString4 = Jose.JWT.Decode(fileData, enc.GetBytes(secretString), JwsAlgorithm.HS256);
                        var parsed4     = JObject.Parse(fileString4);

                        string binaryBase64_4 = parsed4.SelectToken("file").Value <string>();
                        Byte[] fileBytes4     = Convert.FromBase64String(binaryBase64_4);

                        string downloadDir = Environment.GetEnvironmentVariable("USERPROFILE") + @"\" + "Downloads";
                        Console.WriteLine("Writing file: " + downloadDir + "/" + fileName);
                        File.WriteAllBytes(downloadDir + "/" + fileName, fileBytes4);

                        fileReceived = td;
                        break;
                    }
                }
                if (fileReceived != null)
                {
                    tf.data.Remove(fileReceived);
                }

                Console.WriteLine("tf.data.count " + tf.data.Count);

                if (parentDomain != "GLOBALROOT")
                {
                    foreach (TransmitData td in tf.data)
                    {
                        publishRequest.Add(td);
                    }
                }
                if (parentDomain == "GLOBALROOT")
                {
                    // copy publish request into response
                    for (int i = 0; i < publishResponse.Length; i++)
                    {
                        if (publishResponse[i] == null)
                        {
                            publishResponse[i] = tf.data;
                            if (childs.Count != 0)
                            {
                                publishResponseChilds[i] = new List <string> {
                                };
                                foreach (string value in childs)
                                {
                                    foreach (TransmitData td in tf.data)
                                    {
                                        if (td.destination == "" || td.destination == value)
                                        {
                                            if (!publishResponseChilds[i].Contains(value))
                                            {
                                                publishResponseChilds[i].Add(value);
                                            }
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }
                }
            }

            // Dump publishResponseChilds
            for (int i = 0; i < publishResponse.Length; i++)
            {
                if (publishResponse[i] != null)
                {
                    Console.Write("i " + i + " childs: ");
                    foreach (string c in publishResponseChilds[i])
                    {
                        Console.Write(c + " ");
                    }
                    Console.WriteLine();

                    foreach (TransmitData tdr in publishResponse[i])
                    {
                        Console.WriteLine("*** DUMP " + i + " " + source + ": " + tdr.type + " " + tdr.source + " " + tdr.destination);
                    }
                }
            }

            TransmitFrame response = new TransmitFrame();

            response.source = sourceName;

            for (int i = 0; i < publishResponse.Length; i++)
            {
                if (publishResponse[i] != null)
                {
                    if (publishResponseChilds[i] != null)
                    {
                        if (publishResponseChilds[i].Contains(source))
                        {
                            foreach (TransmitData td in publishResponse[i])
                            {
                                response.data.Add(td);
                            }
                            publishResponseChilds[i].Remove(source);
                            if (publishResponseChilds[i].Count == 0)
                            {
                                publishResponse[i] = null;
                            }
                        }
                    }
                }
            }

            string responseJson = "";

            if (response.data.Count != 0)
            {
                countWriteLine++;
                foreach (TransmitData tdr in response.data)
                {
                    Console.WriteLine("*** SEND " + response.data.Count + " " + countWriteLine + " " + source + ": " + tdr.type + " " + tdr.source + " " + tdr.destination);
                }
                responseJson = JsonConvert.SerializeObject(response, Formatting.Indented);
            }

            return(responseJson);
        }
Ejemplo n.º 8
0
        public static string executeTransmitFrames(TransmitFrame tf)
        {
            string source = tf.source;

            if (source != "" && tf.data.Count != 0)
            {
                foreach (TransmitData td in tf.data)
                {
                    if (td.type == "getaasxFile" && td.destination == sourceName)
                    {
                        var parsed3 = JObject.Parse(td.publish[0]);

                        string fileName = parsed3.SelectToken("fileName").Value <string>();
                        string fileData = parsed3.SelectToken("fileData").Value <string>();

                        var enc         = new System.Text.ASCIIEncoding();
                        var fileString4 = Jose.JWT.Decode(fileData, enc.GetBytes(secretString), JwsAlgorithm.HS256);
                        var parsed4     = JObject.Parse(fileString4);

                        string binaryBase64_4 = parsed4.SelectToken("file").Value <string>();
                        Byte[] fileBytes4     = Convert.FromBase64String(binaryBase64_4);

                        string downloadDir = Environment.GetEnvironmentVariable("USERPROFILE") + @"\" + "Downloads";
                        Console.WriteLine("Writing file: " + downloadDir + "/" + fileName);
                        File.WriteAllBytes(downloadDir + "/" + fileName, fileBytes4);

                        tf.data.Remove(td);
                    }
                    else
                    {
                        if (parentDomain != "GLOBALROOT")
                        {
                            publishRequest.Add(td);
                        }
                        if (parentDomain == "GLOBALROOT")
                        {
                            if (td.type == "directory")
                            {
                                aasDirectoryParameters adp = new aasDirectoryParameters();

                                try
                                {
                                    adp = Newtonsoft.Json.JsonConvert.DeserializeObject <aasDirectoryParameters>(td.publish[0]);
                                }
                                catch
                                {
                                }
                                aasDirectory.Add(adp);
                                tf.data.Remove(td);
                            }
                            // copy publish request into response
                            for (int i = 0; i < publishResponse.Length; i++)
                            {
                                if (publishResponse[i] == null)
                                {
                                    publishResponse[i] = tf.data;
                                    if (childs.Count != 0)
                                    {
                                        publishResponseChilds[i] = new List <string> {
                                        };
                                        foreach (string value in childs)
                                        {
                                            publishResponseChilds[i].Add(value);
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                    }
                }
            }

            TransmitFrame response = new TransmitFrame();

            response.source = sourceName;

            for (int i = 0; i < publishResponse.Length; i++)
            {
                if (publishResponse[i] != null)
                {
                    if (publishResponseChilds[i] != null)
                    {
                        if (publishResponseChilds[i].Contains(source))
                        {
                            foreach (TransmitData td in publishResponse[i])
                            {
                                response.data.Add(td);
                            }
                            publishResponseChilds[i].Remove(source);
                            if (publishResponseChilds[i].Count == 0)
                            {
                                publishResponse[i] = null;
                            }
                        }
                    }
                }
            }

            string responseJson = "";

            if (response.data.Count != 0)
            {
                responseJson = JsonConvert.SerializeObject(response, Formatting.Indented);
            }

            return(responseJson);
        }
Ejemplo n.º 9
0
            public static TransmitFrame Encode(Station stl, Connection.ConnectionParameterBuf cBuf, Station.CommandResponse cmdResp, Int32 pfBit)
            {
                //
                // Build the XID frame to send
                //

                TransmitFrame commandFrame = new TransmitFrame();

                Byte[] stlB = stl.GetStationAddresBuffer(cmdResp);
                Int32  ptr  = stlB.Length;
                Int32  t;
                Int32  c;
                Int32  paramPtr = 0;

                Byte[] tmpP = new Byte[30];

                commandFrame.ibuf        = new Byte[tmpP.Length + stlB.Length]; // overallocate buffer space to handle worst case.  We'll trim later
                commandFrame.frameType   = FrameTypes.XIDType;
                commandFrame.seqNumMode  = SequenceNumberMode.Mod8;
                commandFrame.cmdOctetPtr = stlB.Length;

                stlB.CopyTo(commandFrame.ibuf, 0);     // Load station address fields

                commandFrame.ibuf[ptr++] = (Byte)(((Int32)FrameTypes.XIDType) | (pfBit << 4));
                commandFrame.ibuf[ptr++] = (Byte)(FormatIdentifier.GeneralPurposeXIDInfo);
                commandFrame.ibuf[ptr++] = (Byte)(GroupIdentifier.ParameterNegotiation);
                //
                // Load parameters to negotiate
                //

                t = (Int32)ClassOfProcedures.BalancedABMHalfDup;
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.ClassOfProcedures);
                tmpP[paramPtr++] = (Byte)2;
                tmpP[paramPtr++] = (Byte)((t >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(t & 0x7f);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.HDLCOptionalParams);
                tmpP[paramPtr++] = (Byte)3;
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte0);
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte1);
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte2);

                //
                // The IFrame size specified here is in bits.  Check to see how many bytes we'll need to specify
                //
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.RXIFieldLen);
                c = cBuf.maxIFrame * 8;
                if (c >= 65536)
                {
                    //
                    // Need 4 bytes to specify the window size
                    //
                    tmpP[paramPtr++] = (Byte)4;
                    tmpP[paramPtr++] = (Byte)((c >> 24) & 0xff);
                    tmpP[paramPtr++] = (Byte)((c >> 16) & 0xff);
                }
                else
                {
                    //
                    // Need only 2 bytes
                    //
                    tmpP[paramPtr++] = (Byte)2;
                }
                tmpP[paramPtr++] = (Byte)((c >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(c & 0xff);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.RXWindowSize);
                tmpP[paramPtr++] = (Byte)1;
                tmpP[paramPtr++] = (Byte)(cBuf.maxWindowSize & 0xff);

                //
                // The Ack timer is specified in mSec.  Check to see how many bytes we'll need
                //
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.AckTimer);
                if (cBuf.ackTimer >= 65536)
                {
                    //
                    // Need 4 bytes to specify ack timer
                    //
                    tmpP[paramPtr++] = (Byte)4;
                    tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 24) & 0xff);
                    tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 16) & 0xff);
                }
                else
                {
                    //
                    // Need only 2 bytes
                    //
                    tmpP[paramPtr++] = (Byte)2;
                }
                tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(cBuf.ackTimer & 0xff);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.NumRetries);
                tmpP[paramPtr++] = (Byte)1;
                tmpP[paramPtr++] = (Byte)(cBuf.maxRetry & 0xff);

                tmpP = Support.PackByte(tmpP, 0, paramPtr);     // Pack it down

                //
                // Add parameter length field to buffer
                //

                commandFrame.ibuf[ptr++] = (Byte)((tmpP.Length >> 8) & 0xff);
                commandFrame.ibuf[ptr++] = (Byte)(tmpP.Length & 0xff);

                //
                // Add the parameters to the buffer
                //
                tmpP.CopyTo(commandFrame.ibuf, ptr);
                ptr += tmpP.Length;

                commandFrame.ibuf = Support.PackByte(commandFrame.ibuf, 0, ptr);  //Pack it down

                return(commandFrame);
            }
Ejemplo n.º 10
0
 public static void ClearPBit(ref TransmitFrame transmitFrame)
 {
     transmitFrame.ibuf[transmitFrame.cmdOctetPtr] &= 0xff - PF;
 }
Ejemplo n.º 11
0
        //  Routines to set and clear P bit in frame               (JNW Jan15 updated Jan17)

        public static void AddPBit(ref TransmitFrame transmitFrame)
        {
            transmitFrame.ibuf[transmitFrame.cmdOctetPtr] |= PF;
        }
Ejemplo n.º 12
0
        public static void AddSequence(ref TransmitFrame transmitFrame, Int32 nr)
        {
            Int32 tmpI = transmitFrame.ibuf[transmitFrame.cmdOctetPtr] & 0x1f;

            transmitFrame.ibuf[transmitFrame.cmdOctetPtr] = (Byte)((nr << 5) | tmpI);
        }