Ejemplo n.º 1
0
        private void new_data2(MemoryElement mem, int addr, byte[] data)
        {
            if (mem.id == this.id)
            {
                if (addr == 0)
                {
                    bool done = false;

                    if (BitConverter.ToInt32(data.Take(4).ToArray(), 0) == 0xBC)
                    {
                        elements.Add("version", data[5]);
                        elements.Add("radio_channel", data[6]);
                        elements.Add("radio_speed", data[7]);
                        elements.Add("pitch_trim", BitConverter.ToSingle(data.Skip(7).Take(4).ToArray(), 0));
                        elements.Add("roll_trim", BitConverter.ToSingle(data.Skip(11).Take(4).ToArray(), 0));

                        if ((byte)elements["version"] == 0)
                        {
                            done = true;
                        }
                        else if ((byte)elements["version"] == 1)
                        {
                            this.datav0 = data;
                            //this.mem_handler.
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
 public void write_done(MemoryElement mem, int addr)
 {
     if (_write_finished_cb != null && mem.id == id)
     {
         _write_finished_cb(this, addr);
     }
 }
Ejemplo n.º 3
0
        public _ReadRequest(MemoryElement mem, int addr, int length, Crazyflie cf)
        {
            this.mem         = mem;
            this.addr        = addr;
            this._bytes_left = length;
            this.data        = new byte[0];
            this.cf          = cf;

            this._current_addr = addr;
        }
Ejemplo n.º 4
0
        public _WriteRequest(MemoryElement mem, int addr, byte[] data, Crazyflie cf)
        {
            this.mem         = mem;
            this.addr        = addr;
            this._bytes_left = data.Length;
            this._data       = data;
            this.data        = new byte[0];
            this.cf          = cf;

            this._current_addr = addr;

            this._addr_add = 0;
        }
Ejemplo n.º 5
0
        public bool read(MemoryElement memory, int addr, int length)
        {
            if (_read_requests.Keys.Contains(memory.id))
            {
                return(false);
            }

            var rreq = new _ReadRequest(memory, addr, length, cf);

            _read_requests.Add(memory.id, rreq);

            rreq.start();

            return(true);
        }
Ejemplo n.º 6
0
        public void _mem_update_done(MemoryElement mem)
        {
            if (_ow_mems_left_to_update.Keys.Contains(mem.id))
            {
                _ow_mems_left_to_update.Remove(mem.id);
            }

            if (_ow_mems_left_to_update.Count == 0)
            {
                if (_refresh_callback != null)
                {
                    _refresh_callback();
                    _refresh_callback = null;
                }
            }
        }
Ejemplo n.º 7
0
//         public OWElement ow_search(int pid, string name)
//         {
//             foreach (OWElement m in get_mems(MemoryElement.TYPE.TYPE_1W))
//             {
//                 if (m.pid == pid || m.name == name)
//                     return m;
//             }
//             return null;
//         }

        public bool write(MemoryElement memory, int addr, byte[] data, bool flush_queue = false)
        {
            var wreq = new _WriteRequest(memory, addr, data, cf);

            if (!_write_requests.Keys.Contains(memory.id))
            {
                _write_requests.Add(memory.id, new List <_WriteRequest>());
            }

            if (flush_queue)
            {
                _write_requests[memory.id] = _write_requests[memory.id].Take(1).ToList();
            }
            _write_requests[memory.id].Add(wreq);
            if (_write_requests[memory.id].Count == 1)
            {
                wreq.start();
            }

            return(true);
        }
Ejemplo n.º 8
0
 private void new_data2(MemoryElement mem, int addr, byte[] data)
 {
 }