Exemple #1
0
        public RegReadResponse readRegs(RegReadRequest r)
        {
            RegReadResponse resp = new RegReadResponse();

            resp.values = this.dsp.readRegRequest(r);
            return(resp);
        }
Exemple #2
0
 public uint[] readRegRequest(RegReadRequest regs)
 {
     uint[] results = new uint[regs.addresses.Length];
     for (int ii = 0; ii < regs.addresses.Length; ii++)
     {
         results[ii] = readReg(regs.addresses[ii]);
     }
     return(results);
 }
Exemple #3
0
        private dynamic readRegs()
        {
            log.info("Got request for reading DSP registers");
            try {
                string          body       = this.getJsonBody();
                StringReader    memeReader = new StringReader(body);
                JsonTextReader  memer      = new JsonTextReader(memeReader);
                JsonSerializer  serializer = new JsonSerializer();
                RegReadRequest  r          = serializer.Deserialize <RegReadRequest>(memer);
                RegReadResponse resp       = controller.readRegs(r);

                if (r.desc == String.Empty)
                {
                    log.info($"Got register read request with no description");
                }
                else
                {
                    log.info($"Got register read request with description: {r.desc}");
                }

                log.info($"Reading registers:");
                log.info(r.ToString());

                log.info($"Returning values:");
                log.info(resp.ToString());
                string output = JsonConvert.SerializeObject(resp);
                var    hurr   = Encoding.UTF8.GetBytes(output);

                return(new Response
                {
                    ContentType = "application/json",
                    Contents = s => s.Write(hurr, 0, hurr.Length)
                });
            }
            catch (Exception e) {
                log.err("read regs malformed request");
                Console.WriteLine(e);
                return(500);
            }
            log.ok("Registers read successful");
            return(200);
        }