KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
shell_edfa.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2015 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : shell_edfa.c
11  * Created : 18 feb. 2015
12  * Author : Riccardo Travaglini
13  */
14 
15 #include <stdbool.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 
19 #include <util/convert.h>
20 
21 #include <drv/uart/edfa-eau.h>
22 
23 #include "kernel/scheduler.h"
24 #include <errorcode.h>
25 #include <kernel/err.h>
26 
27 
28 
29 
30 static const CnvParams _hex = CNV_DEFAULT_HEX;
31 static const CnvParams _int = CNV_DEFAULT;
32 
33 const char cmd_edfa_help[] = "EDFA - Configure and Read";
34 
35 
36 
37 
38 bool cmd_edfa_exec(int argc, const char *args[])
39 {
40 
41  bool emi,start;
42  char *returnedString;
43  int iret;
44 
45  if (argc < 1 || ((argc == 1) && (strcmp(args[0],"help") == 0))) {
46  puts("usage: edfa status -- read status");
47  puts("edfa emi on|off -- emission val: on ,off ");
48  puts("edfa read <arg>");
49  puts(" <arg> can be:");
50  puts(" op -- read composite output power");
51  puts(" ip -- read composite input power");
52  puts(" pdcu -- read pump diodes current");
53  puts(" temp -- read case temperature");
54  puts(" powsp -- read composite power setpoint for APC mode");
55  puts(" maxop -- read maximum composite output power for APC mode");
56 #ifndef _EDFA_NOAGC
57  puts(" sp -- read gain setpoint for AGC mode");
58  puts(" gain -- read actual gain ");
59  puts(" maxgain -- read maximum gain for AGC ");
60  puts(" mingain -- read minimum gain for AGC");
61 #endif
62  puts(" maxtemp -- read maximum temperature");
63  puts(" maxpdcu -- read pump diodes current");
64  puts("edfa info -- part number, fw rev, manufact. day, SN");
65  puts("edfa apc - Makes APC (Power Stabilization) mode the device control mode");
66 #ifndef _EDFA_NOAGC
67  puts("edfa agc - Makes AGC (Gain Stabilization) mode the device control mode");
68 #endif
69  puts("edfa set op <int> -- set composite output power for APC; <val> = value in dBm");
70  puts("edfa set optest -- set composite output power for APC; <val> = value in dBm");
71 #ifndef _EDFA_NOAGC
72  puts("edfa set gain <value> -- set output gain for AGC; <val> = value in dB");
73 #endif
74 
75  }
76  else if(argc == 1 && strcmp(args[0],"status") == 0){
77  edfaReadStatus(&emi,&start);
78  printf("emi = %d - startup = %d\n",emi?1:0,start?1:0);
79  }
80  else if(argc == 2 && strcmp(args[0],"emi") == 0){
81  if( strcmp(args[1],"on")== 0 )edfaEmOn();
82  else if( strcmp(args[1],"off")== 0 )edfaEmOff();
83  else return false;
84  }
85  else if(argc == 2 && strcmp(args[0],"read") == 0){
86  if( strcmp(args[1],"op")== 0 ){
87 // edfaReadCompOutPw(&returnedString);
88 // printf("Composite Output Power = %s dBm\n",returnedString);
89 // edfaOutputPower(&fp);
90 // printf("Output Power = %d.%d dBm\n",fp.integer, fp.mantissa);
91  printf("Output Power = %d mdBm\n",edfaOutputPower());
92  }
93  else if( strcmp(args[1],"ip")== 0 ){
94 // edfaReadCompInPw(&returnedString);
95 // printf("Input Power = %s dBm\n",returnedString);
96 
97  printf("Input Power = %d mdBm\n",edfaInputPower());
98  }
99  else if( strcmp(args[1],"pdcur")== 0 ){
100 // edfaReadPumpDiodeCur(&returnedString);
101 // printf("Ddiode current = %s mA\n",returnedString);
102 
103  printf("Diode current = %d uA\n",edfaPumpCur());
104  }
105  else if( strcmp(args[1],"temp")== 0 ){
106 // edfaReadTemp(&returnedString);
107 // printf("Temp = %s C\n",returnedString);
108 
109  printf("Temp = %d mC\n",edfaTemp());
110  }
111  else if( strcmp(args[1],"powsp")== 0 ){
112 // edfaReadCompPwSet(&returnedString);
113 // printf("Power in APC = %s dBm\n",returnedString);
114 
115  printf("Power in APC = %d mdBm\n",edfaReadSetpoint());
116  }
117  else if( strcmp(args[1],"maxop")== 0 ){
118  edfaReadMaxCompOutPw(&returnedString);
119  printf("Max Out Pow APC = %s dBm\n",returnedString);
120  }
121 #ifndef _EDFA_NOAGC
122  else if( strcmp(args[1],"gsp")== 0 ){
123  edfaReadGainSet(&returnedString);
124  printf("Gain set AGC = %s dB\n",returnedString);
125  }
126  else if( strcmp(args[1],"gain")== 0 ){
127  edfaReadActGain(&returnedString);
128  printf("Actual Gain = %s dB\n",returnedString);
129  }
130  else if( strcmp(args[1],"maxgain")== 0 ){
131  edfaReadMaxGain(&returnedString);
132  printf("Max Gain AGC = %s dB\n",returnedString);
133  }
134  else if( strcmp(args[1],"mingain")== 0 ){
135  edfaReadMinGain(&returnedString);
136  printf("Min Gain AGC = %s dB\n",returnedString);
137  }
138 #endif
139  else if( strcmp(args[1],"maxtemp")== 0 ){
140  edfaReadMaxTemp(&returnedString);
141  printf("Max temp = %s C\n",returnedString);
142  }
143  else if( strcmp(args[1],"maxpdcu")== 0 ){
144  edfaReadMaxPumpDiodeCur(&returnedString);
145  printf("Max diodes cur = %s mA\n",returnedString);
146  }
147  else return false;
148  }
149  else if(argc == 1 && strcmp(args[0],"info") == 0){
150  edfaReadPart(&returnedString);
151  printf("Part #: %s\n",returnedString);
152  edfaReadFwVer(&returnedString);
153  printf("FW: %s\n",returnedString);
154  edfaReadDate(&returnedString);
155  printf("Man.: %s\n",returnedString);
156  edfaReadSerial(&returnedString);
157  printf("SN: %s\n",returnedString);
158  }
159  else if(argc == 1 && strcmp(args[0],"apc") == 0){
160  edfaSetAPCMode(&returnedString);
161  printf("%s\n",returnedString);
162  }
163 #ifndef _EDFA_NOAGC
164  else if(argc == 1 && strcmp(args[0],"agc") == 0){
165  edfaSetAGCMode(&returnedString);
166  printf("%s\n",returnedString);
167  }
168 #endif
169  else if(argc == 3 && strcmp(args[0],"set") == 0){
170  if( strcmp(args[1],"op")== 0 ){
171  edfaSetCompOutPw(args[2],&returnedString);
172  printf("%s\n",returnedString);
173  }
174 
175 #ifndef _EDFA_NOAGC
176  else if( strcmp(args[1],"gain")== 0 ){
177  edfaSetGainSet(args[2],&returnedString);
178  printf("%s\n",returnedString);
179  }
180 #endif
181 
182  else return false;
183  }
184 #ifdef EDFASIM
185  else if(argc == 2 && strcmp(args[0],"set") == 0){
186  if( strcmp(args[1],"optest")== 0 ){
187  edfaWriteSetpoint(4.532,&returnedString);
188  printf("%s\n",returnedString);
189  }
190  }
191 #endif
192 
193  else return false;
194 
195  return true;
196 
197 }
198 
199 
Simple task scheduler for tasks.
#define CNV_DEFAULT
Default conversion/formatting parameters (base 10).
Definition: convert.h:47
Manages the global system error.
This structure provides information about formatting and parsing.
Definition: convert.h:37
This module is responsible for distributing error codes.
EDFA-EAU (30-C3-20-C) Uart driver.
This module implements parsing and formating of strings and integers.