Esempio n. 1
0
        //DoneWithCrutch
        public static BodyFormat ReceiveFullBody(SerialPort serialPort, int length, int timeout = 1000)
        {
            byte[] rawData = new byte[HeaderFormat.getHeaderFormatSize() + length + 4];
            serialPort.WriteTimeout = timeout;
            Utils.ReadData(serialPort, rawData, HeaderFormat.getHeaderFormatSize() + length + 4);
            Debug.WriteLine($"Data header received");
            //Crutch
            headerByteArrayCrutch = rawData.Take(HeaderFormat.getHeaderFormatSize()).ToArray();
            byte[]     bodyTmp     = rawData.Skip(HeaderFormat.getHeaderFormatSize()).Take(length + 4).ToArray();
            BodyFormat dataWithCrc = new BodyFormat(bodyTmp);

            //Crutch
            return(dataWithCrc);
        }