public Dictionary <byte, short> SetGyroRegisters(Dictionary <byte, short> registers)
        {
            Dictionary <byte, short> dictionary = new Dictionary <byte, short>();

            foreach (var reg in registers)
            {
                GyroRegisterList list = new GyroRegisterList();
                list.RegisterList.Add(new GyroRegisterData()
                {
                    Register = reg.Key, Value = reg.Value
                });
                var result = _client.GetGyroRegisters(list);
                dictionary.Add(reg.Key, (short)result.RegisterList[0].Value);
            }



            return(dictionary);
        }
        public Dictionary <byte, short> GetGyroRegisters(List <byte> registers)
        {
            GyroRegisterList list = new GyroRegisterList();

            foreach (var reg in registers)
            {
                list.RegisterList.Add(new GyroRegisterData()
                {
                    Register = reg
                });
            }

            var result = _client.GetGyroRegisters(list);

            Dictionary <byte, short> dictionary = new Dictionary <byte, short>();

            foreach (var data in result.RegisterList)
            {
                dictionary.Add((byte)data.Register, (short)data.Value);
            }

            return(dictionary);
        }
        /// <summary>
        /// Cycles through the list of registers, returning registers successfully read with their values
        /// </summary>
        /// <param name="request"></param>
        /// <param name="context"></param>
        /// <returns></returns>
        public override Task <GyroRegisterList> GetGyroRegisters(GyroRegisterList request, ServerCallContext context)
        {
            var response = new GyroRegisterList();

            foreach (var register in request.RegisterList)
            {
                try
                {
                    response.RegisterList.Add(new GyroRegisterData()
                    {
                        Register = register.Register,
                        Value    = _dataService.GetGyroRegister((byte)register.Register)
                    });
                }
                catch (Exception ex)
                {
                    _logger.LogError($"Cannot read register {register.Register}.");
                    _logger.LogError(ex.Message);
                    _logger.LogError(ex.StackTrace);
                }
            }

            return(Task.FromResult(response));
        }