KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
shell_acou.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2013 National Institute for Subatomic Physics Nikhef
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : shell_hydro.c
11  * Created : 21 jun. 2013
12  * Author : Christophe Hugon
13  */
14 
15 
16 #ifndef SHELL_ACOU_C_
17 #define SHELL_ACOU_C_
18 
19 #include "drv/wb/acou.h"
20 #include "util/convert.h"
21 #include <stdbool.h>
22 #include <string.h>
23 #include <stdio.h>
24 
25 const char cmd_acou_help[] = "acou test: call acou no args for more help";
26 
27 void acou_print_help(){
28  puts("\nacou on|off: switch on/off the module "
29  "\nacou sampling <n> (<n> from 0 to 255): set the sampling rate"
30  "\nacou resolution <n>: set the audio resolution (0=12 bit, 1=16 bit, 2=24 bit)"
31  "\nacou channel <n>: set the audio channel (0=both, 1=ch 1, 2=ch 2)");
32  return;
33 }
34 
35 bool cmd_acou_exec(int argc, const char *args[])
36 {
37 
38  if (argc == 0){
39  acou_print_help();
40  return true;
41  }
42 
43  if ((argc == 1) && (strcmp(args[0], "off") == 0))
44  {
45  acouOff ();
46  }
47  else if ((argc == 1) && (strcmp(args[0], "on") == 0))
48  {
49  acouOn ();
50  }
51  else if ((argc == 2) && (strcmp(args[0], "sampling") == 0))
52  {
53  uint8_t v;
54  if(cnvParseU(args[1], (uint32_t *)&v, (CnvParams) CNV_DEFAULT) == 0){
55  puts("\nFailed to read sampling number\n");
56  return false;
57  }
58  acouSetSampling(v);
59  }
60  else if ((argc == 2) && (strcmp(args[0], "resolution") == 0))
61  {
62  uint8_t v;
63  AcouRes val;
64  if(cnvParseU(args[1], (uint32_t *)&v, (CnvParams) CNV_DEFAULT) == 0){
65  puts("\nFailed to read resolution number\n");
66  return false;
67  }
68  val = v;
69  if((val != ACOU_RES_12BIT) && (val != ACOU_RES_16BIT) && (val != ACOU_RES_24BIT)){
70  puts("\nIncorrect resolution choice\n");
71  return false;
72  }
73  acouSetResolution(val);
74  }
75  else if ((argc == 2) && (strcmp(args[0], "channel") == 0))
76  {
77  uint8_t v;
78  AcouCh val;
79  if(cnvParseU(args[1], (uint32_t *)&v, (CnvParams) CNV_DEFAULT) == 0){
80  puts("\nFailed to read channel number\n");
81  return false;
82  }
83  val = v;
84  if((val != ACOU_CH_BOTH) && (val != ACOU_CH_1) && (val != ACOU_CH_2)){
85  puts("\nIncorrect channel choice\n");
86  return false;
87  }
88  acouSetChannel(val);
89  }
90  else
91  {
92  return false;
93  }
94 
95  return true;
96 }
97 
98 
99 #endif /* SHELL_ACOU_C_ */
AcouRes
enum for bit resolution
Definition: acou.h:48
AcouCh
enum for channels
Definition: acou.h:57
void acouOn()
Turns the hydrophone on.
Definition: acou.c:30
int cnvParseU(const char *input, uint32_t *output, CnvParams params)
Parse an unsigned integer.
Definition: convert.c:61
12 bits
Definition: acou.h:49
#define CNV_DEFAULT
Default conversion/formatting parameters (base 10).
Definition: convert.h:47
void acouSetSampling(uint8_t val)
Set the sampling interval.
Definition: acou.c:45
16 bits
Definition: acou.h:50
Both channels.
Definition: acou.h:58
void acouOff()
Truns the hydrohpone off.
Definition: acou.c:39
This structure provides information about formatting and parsing.
Definition: convert.h:37
Channel 2.
Definition: acou.h:60
void acouSetResolution(AcouRes val)
Set the bit resolution.
Definition: acou.c:51
void acouSetChannel(AcouCh val)
Set the channel configuration.
Definition: acou.c:57
This module implements parsing and formating of strings and integers.
Channel 1.
Definition: acou.h:59
Acoustic Driver.
32 bits
Definition: acou.h:51