Exemple #1
0
        public _radio_ack send_packet(byte[] dataOut)
        {
            _radio_ack ackIn = null;
            int        transferred;

            writer.Write(dataOut, 1000, out transferred);
            if (transferred == dataOut.Length)
            {
                byte[] data = new byte[64];
                reader.Read(data, 1000, out transferred);
                if (transferred > 0)
                {
                    ackIn = new _radio_ack();
                    if (data[0] != 0)
                    {
                        ackIn.ack      = (data[0] & 0x01) != 0;
                        ackIn.powerDet = (data[0] & 0x02) != 0;
                        ackIn.retry    = data[0] >> 4;
                        ackIn.data     = data.Take(transferred).Skip(1).ToArray();
                    }
                    else
                    {
                        ackIn.retry = this.arc;
                    }
                }
            }
            return(ackIn);
        }
Exemple #2
0
        public int scan_channels(int start, int stop, byte[] packet, out int[] output)
        {
            int count  = stop - start + 1;
            int result = 0;

            int[] hit = new int[count];
            for (int i = start; i <= stop; i++)
            {
                this.set_channel(i);
                _radio_ack status = this.send_packet(packet);
                if (status.ack)
                {
                    hit[result] = i;
                    result++;
                }
            }
            int[] realhit = new int[result];
            for (int i = 0; i < result; i++)
            {
                realhit[i] = hit[i];
            }
            output = realhit;
            return(result);
        }