write() публичный Метод

public write ( byte data, int size, WriteFinishedFunc finished_func ) : void
data byte
size int
finished_func WriteFinishedFunc
Результат void
Пример #1
0
        public virtual void processResponse(string error, bool success)
        {
            // copied over from Xamla
            var msg = new Messages.std_msgs.String(error);

            msg.Serialized = msg.Serialize();
            byte[] buf;
            if (success)
            {
                buf    = new byte[msg.Serialized.Length + 1 + 4];
                buf[0] = (byte)(success ? 0x01 : 0x00);
                msg.Serialized.CopyTo(buf, 5);
                Array.Copy(BitConverter.GetBytes(msg.Serialized.Length), 0, buf, 1, 4);
            }
            else
            {
                buf    = new byte[1 + 4];
                buf[0] = (byte)(success ? 0x01 : 0x00);
                Array.Copy(BitConverter.GetBytes(0), 0, buf, 1, 4);
            }
            connection.write(buf, buf.Length, onResponseWritten, true);             // Eric has immediate as true, Xamla doesn't, but this seems to work for now
//            String msg = new String(error);
//            msg.Serialized = msg.Serialize();
//            byte[] buf = new byte[msg.Serialized.Length + 1];
//            buf[0] = (byte) (success ? 0x01 : 0x00);
//            msg.Serialized.CopyTo(buf, 1);
//            connection.write(buf, buf.Length, onResponseWritten, true);
        }
Пример #2
0
        public virtual void processResponse(string error, bool success)
        {
            String msg = new String(error);

            msg.Serialize();
            byte[] buf = new byte[msg.Serialized.Length + 1];
            buf[0] = (byte)(success ? 0x01 : 0x00);
            msg.Serialized.CopyTo(buf, 1);
            connection.write(buf, (uint)buf.Length, onResponseWritten, true);
        }
Пример #3
0
        private void startMessageWrite(bool immediate_write)
        {
            MessageAndSerializerFunc holder = null;

            if (writing_message || !header_written)
            {
                return;
            }
            lock (outbox)
            {
                if (outbox.Count > 0)
                {
                    writing_message = true;
                    holder          = outbox.Dequeue();
                }
                if (outbox.Count < max_queue)
                {
                    queue_full = false;
                }
            }
            if (holder != null)
            {
                if (holder.msg.Serialized == null)
                {
                    holder.msg.Serialized = holder.serfunc();
                }
                stats.messages_sent++;
                //EDB.WriteLine("Message backlog = " + (triedtosend - stats.messages_sent));
                stats.bytes_sent        += holder.msg.Serialized.Length;
                stats.message_data_sent += holder.msg.Serialized.Length;
                connection.write(holder.msg.Serialized, holder.msg.Serialized.Length, onMessageWritten, immediate_write);
            }
        }
        private void startMessageWrite(bool immediate_write)
        {
            IRosMessage m = null;

            lock (outbox_mutex)
            {
                if (writing_message || !header_written)
                {
                    return;
                }
                if (outbox.Count > 0)
                {
                    writing_message = true;
                    m = outbox.Dequeue();
                }
            }
            if (m != null)
            {
                byte[] M = m.Serialize();
                stats.messages_sent++;
                //EDB.WriteLine("Message backlog = " + (triedtosend - stats.messages_sent));
                stats.bytes_sent        += M.Length;
                stats.message_data_sent += M.Length;
                connection.write(M, (uint)M.Length, onMessageWritten, immediate_write);
            }
        }
Пример #5
0
        private void processNextCall()
        {
            bool empty = false;

            lock (call_queue_mutex)
            {
                if (current_call != null)
                {
                    return;
                }
                if (call_queue.Count > 0)
                {
                    current_call = call_queue.Dequeue();
                }
                else
                {
                    empty = true;
                }
            }
            if (empty)
            {
                //if (persistent)
                //    connection.drop(Connection.DropReason.Destructing);
            }
            else
            {
                IRosMessage request;
                lock (call_queue_mutex)
                {
                    request = current_call.req;
                }
                request.Serialize();
                connection.write(request.Serialized, (uint)request.Serialized.Length, onRequestWritten);
            }
        }
Пример #6
0
        private void processNextCall()
        {
            bool empty = false;

            lock (call_queue_mutex)
            {
                if (current_call != null)
                {
                    return;
                }
                if (call_queue.Count > 0)
                {
                    current_call = call_queue.Dequeue();
                }
                else
                {
                    empty = true;
                }
            }
            if (empty)
            {
                if (!persistent)
                {
                    connection.drop(Connection.DropReason.Destructing);
                }
            }
            else
            {
                IRosMessage request;
                lock (call_queue_mutex)
                {
                    request = current_call.req;
                }

                request.Serialized = request.Serialize();
                byte[] tosend = new byte[request.Serialized.Length + 4];
                Array.Copy(BitConverter.GetBytes(request.Serialized.Length), tosend, 4);
                Array.Copy(request.Serialized, 0, tosend, 4, request.Serialized.Length);
                connection.write(tosend, tosend.Length, onRequestWritten);
            }
        }