KM3NeT CLB  2.0
KM3NeT CLB v2 Embedded Software
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
shell_acdc.c
1 /*
2  * KM3NeT CLB v2 Firmware
3  * ----------------------
4  *
5  * Copyright 2015 KM3NeT Collaboration
6  *
7  * All Rights Reserved.
8  *
9  *
10  * File : shell_acdc.c
11  * Created : 26 mar. 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/acdc.h>
22 
23 
24 #include <errorcode.h>
25 #include <kernel/err.h>
26 
27 static const CnvParams _int = CNV_DEFAULT;
28 
29 #define NFRAMES_ACDC 30
30 
31 const char cmd_acdc_help[] = "ACDC - Read";
32 
33 
34 
35 bool cmd_acdc_exec(int argc, const char *args[])
36 {
37 
38  int ntot=1;
39  int rcev = 0;
40  int i;
41  AcdcFrame fvect[NFRAMES_ACDC];
42 
43  if (argc < 1 || ((argc == 1) && (strcmp(args[0],"help") == 0))) {
44  printf("usage: acdc read [n] -- read last n packets ; 1 if n is omitted; n < %d\n",NFRAMES_ACDC);
45 
46  }
47  else if(argc >= 1 && strcmp(args[0],"read") == 0){
48  if(argc > 2)return false;
49  else if(argc == 2){
50  if (cnvParseI(args[1], &ntot, _int) <= 0) {
51  return false;
52  }
53  if(ntot > NFRAMES_ACDC)return false;
54  }
55  acdcEnable(true);
56  rcev = acdcGetNFrames(fvect , ntot);
57  acdcEnable(false);
58  acdcClearBuffer();
59  printf("Received = %d frames\n\n",rcev);
60  for(i=0;i<rcev;i++){
61  printf("[%d] T=%d C degrees - V=%d V - I=%d mA\n",i+1,
62  fvect[i].temp * TSCALE + TOFF,
63  fvect[i].volt * VSCALE + VOFF,
64  fvect[i].current * ISCALE + IOFF);
65  }
66 
67 
68 
69  }
70 
71 
72  return true;
73 
74 }
75 
76 
int cnvParseI(const char *input, int32_t *output, CnvParams params)
Parse a signed integer.
Definition: convert.c:90
void acdcEnable(bool ena)
enables the ACDC rx
Definition: acdc.c:58
#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.
ACDC Uart driver (.
Definition: acdc.h:37
This module implements parsing and formating of strings and integers.