Ejemplo n.º 1
0
        public string WriteSerialdata(byte[] data, int getbytes)
        {
            lock (m_oLockBootloaderWait)
            {
                if (CurrentBootloaderStep == BootloaderController.BootLoaderStep.Waiting)
                {
                    CurrentBootloaderStep = BootloaderController.BootLoaderStep.ProcessingRequest;
                    Thread.Sleep(500);
                    m_oBootloaderConnection.FlushIncomingBytes();
                    foreach (var output in data)
                    {
                        m_oBootloaderConnection.SPout(output);
                    }

                    byte[] numArray1 = new byte[1];
                    byte[] inArray   = new byte[getbytes];
                    for (var index = 0; index < getbytes; ++index)
                    {
                        byte[] numArray2 = m_oBootloaderConnection.ReadBytes(1);
                        if (index != 0 || numArray2[0] != 13)
                        {
                            inArray[index] = numArray2[0];
                        }
                        else
                        {
                            --index;
                        }
                    }
                    if (m_oBootloaderConnection.ReadBytes(1)[0] != 13)
                    {
                        return("FAIL");
                    }

                    BroadcastServer.BroadcastMessage(new SpoolerMessage(MessageType.RawData, MySerialNumber, Convert.ToBase64String(inArray)).Serialize());
                }
                CurrentBootloaderStep = BootloaderController.BootLoaderStep.Waiting;
            }
            return("OK");
        }