private Byte[] SerealizeProtocol(RequestProtocol request)
        {
            Byte[] b   = new Byte[13];
            int    cnt = 0;

            b[cnt++] = SIGN_BEGIN_PACKET;

            b[cnt++] = request.DeviceNumber;

            b[cnt++] = request.CMD;

            b[cnt++] = (Byte)(request.RegisterNumber & 0xFF);
            b[cnt++] = (Byte)((request.RegisterNumber >> 8) & 0xFF);

            b[cnt++] = (Byte)((request.DataToWrite) & 0xFF);
            b[cnt++] = (Byte)((request.DataToWrite >> 8) & 0xFF);
            b[cnt++] = (Byte)((request.DataToWrite >> 16) & 0xFF);
            b[cnt++] = (Byte)((request.DataToWrite >> 24) & 0xFF);

            b[cnt++] = (Byte)(request.RegistersToRead & 0xFF);
            b[cnt++] = (Byte)((request.RegistersToRead >> 8) & 0xFF);

            b[cnt++] = request.CRC8;
            b[cnt]   = SIGN_END_PACKET;

            return(b);
        }
        private RequestProtocol FillProtocol(ProtocolCommands cmd, UInt16 registerNumber, UInt16 registersToRead, UInt32 dataToWrite)
        {
            RequestProtocol protocol = new RequestProtocol();

            protocol.DeviceNumber    = m_DeviceNumber;
            protocol.CMD             = (Byte)cmd;
            protocol.RegisterNumber  = registerNumber;
            protocol.RegistersToRead = registersToRead;
            protocol.DataToWrite     = dataToWrite;
            CalcCrc8(ref protocol);

            return(protocol);
        }
 private void CalcCrc8(ref RequestProtocol protocol)
 {
     protocol.CRC8 = 0xAA;    // TODO пока заглушка
 }