示例#1
0
        //
        // Build an octet buffer holding the callsign destination, source, and relay stations
        //
        public Byte[] GetStationAddresBuffer(CommandResponse cmdRsp)
        {
            Int32 i   = 14;
            Int32 ptr = 0;

            if (relayStation1.stationIDString.Length > 0)
            {
                i += 7;
                if (relayStation2.stationIDString.Length > 0)
                {
                    i += 7;
                }
            }

            Byte[] oBuf = new Byte[i];

            destinationStation.stationBytes.CopyTo(oBuf, ptr);
            ptr           += 7;
            oBuf[ptr - 1] &= 0x7e;      // remove current command/response/ext bits


            if (cmdRsp.Equals(CommandResponse.DoCommand))
            {
                oBuf[ptr - 1] |= 0x80;      // Set Command bit
            }

            sourceStation.stationBytes.CopyTo(oBuf, ptr);
            ptr += 7;
            if (cmdRsp.Equals(CommandResponse.DoResponse))
            {
                oBuf[ptr - 1] |= 0x80;      // Set Response bit
            }

            if (relayStation1.stationIDString.Length > 0)
            {
                //
                // Load any relay addresses into the header
                //
                relayStation1.stationBytes.CopyTo(oBuf, ptr);
                ptr += 7;

                if (relayStation2.stationIDString.Length > 0)
                {
                    relayStation2.stationBytes.CopyTo(oBuf, ptr);
                    ptr += 7;
                }
            }

            oBuf[ptr - 1] |= 0x01;      // Set Ext bit
            return(oBuf);
        }