protegemed, aquisição via A/D simples utilizando interrupção do timer

Dependencies:   EthernetInterface NTPClient mbed-rtos mbed

Fork of ptgm_semDMA by Marcelo Rebonatto

Committer:
viniciushl
Date:
Wed Jan 13 18:53:25 2016 +0000
Revision:
1:8129536051df
Parent:
0:fac116e94d44
Alterada captura para aquisi??o simples do A/D utilizando interrup??o do timer;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rebonatto 0:fac116e94d44 1 #include "TelnetServer.h"
rebonatto 0:fac116e94d44 2
rebonatto 0:fac116e94d44 3 #include "Settings.h"
rebonatto 0:fac116e94d44 4
rebonatto 0:fac116e94d44 5 char *wrong_args_msg_get = "Wrong number of arguments.\r\n\r\nUsage: getparam <parameter name>\r\n";
rebonatto 0:fac116e94d44 6 char *param_not_found_msg_get = "Parameter not found.\r\n\r\n";
rebonatto 0:fac116e94d44 7
rebonatto 0:fac116e94d44 8 int TelnetServer::GetParamCommand(TCPSocketConnection *conn,char** argv,int argc)
rebonatto 0:fac116e94d44 9 {
rebonatto 0:fac116e94d44 10
rebonatto 0:fac116e94d44 11 if(argc != 2)
rebonatto 0:fac116e94d44 12 {
rebonatto 0:fac116e94d44 13 conn->send(wrong_args_msg_get,strlen(wrong_args_msg_get));
rebonatto 0:fac116e94d44 14 return 0;
rebonatto 0:fac116e94d44 15 }
rebonatto 0:fac116e94d44 16
rebonatto 0:fac116e94d44 17 printf("Getting parameter %s\n", argv[1]);
rebonatto 0:fac116e94d44 18
rebonatto 0:fac116e94d44 19 if(!strcmp(argv[1],"Ipserver"))
rebonatto 0:fac116e94d44 20 {
rebonatto 0:fac116e94d44 21 conn->send("\r\nIpserver=",strlen("\r\nIpserver="));
rebonatto 0:fac116e94d44 22 conn->send(Settings::get_ServerUrl(),strlen(Settings::get_ServerUrl()));
rebonatto 0:fac116e94d44 23 conn->send("\r\n",strlen("\r\n"));
rebonatto 0:fac116e94d44 24 return 0;
rebonatto 0:fac116e94d44 25 }
rebonatto 0:fac116e94d44 26
rebonatto 0:fac116e94d44 27 if(!strcmp(argv[1],"Ipaddress"))
rebonatto 0:fac116e94d44 28 {
rebonatto 0:fac116e94d44 29 conn->send("\r\nIpaddress=",strlen("\r\nIpaddress="));
rebonatto 0:fac116e94d44 30 conn->send(Settings::get_IpAddress(),strlen(Settings::get_IpAddress()));
rebonatto 0:fac116e94d44 31 conn->send("\r\n",strlen("\r\n"));
rebonatto 0:fac116e94d44 32 return 0;
rebonatto 0:fac116e94d44 33 }
rebonatto 0:fac116e94d44 34
rebonatto 0:fac116e94d44 35 if(!strcmp(argv[1],"module"))
rebonatto 0:fac116e94d44 36 {
rebonatto 0:fac116e94d44 37 char b[12];
rebonatto 0:fac116e94d44 38 conn->send("\r\nmodule=",strlen("\r\nmodule="));
rebonatto 0:fac116e94d44 39 sprintf(b,"%d\r\n",Settings::get_ModuleNumber());
rebonatto 0:fac116e94d44 40 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 41 return 0;
rebonatto 0:fac116e94d44 42 }
rebonatto 0:fac116e94d44 43
rebonatto 0:fac116e94d44 44 /* Pega os numeros das tomadas [0..2]*/
rebonatto 0:fac116e94d44 45 int i;
rebonatto 0:fac116e94d44 46 for(i=0;i<NUMBER_OF_OUTLETS;i++)
rebonatto 0:fac116e94d44 47 {
rebonatto 0:fac116e94d44 48 char b[12];
rebonatto 0:fac116e94d44 49 sprintf(b,"outlet%d",i);
rebonatto 0:fac116e94d44 50 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 51 {
rebonatto 0:fac116e94d44 52 sprintf(b,"\r\noutlet%d=%d\r\n",i,Settings::get_Outlet(i));
rebonatto 0:fac116e94d44 53 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 54 return 0;
rebonatto 0:fac116e94d44 55 }
rebonatto 0:fac116e94d44 56 }
rebonatto 0:fac116e94d44 57 /* pega os dados dos canais [0..5] */
rebonatto 0:fac116e94d44 58 for(i=0;i<NUMBER_OF_CHANNELS;i++)
rebonatto 0:fac116e94d44 59 {
rebonatto 0:fac116e94d44 60 char b[12];
rebonatto 0:fac116e94d44 61 sprintf(b,"gain%d",i);
rebonatto 0:fac116e94d44 62 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 63 {
rebonatto 0:fac116e94d44 64 sprintf(b,"\r\ngain%d=%f\r\n",i,Settings::get_Gain(i));
rebonatto 0:fac116e94d44 65 printf("Getting gain\n");
rebonatto 0:fac116e94d44 66 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 67 return 0;
rebonatto 0:fac116e94d44 68 }
rebonatto 0:fac116e94d44 69
rebonatto 0:fac116e94d44 70 sprintf(b,"offset%d",i);
rebonatto 0:fac116e94d44 71 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 72 {
rebonatto 0:fac116e94d44 73 sprintf(b,"\r\noffset%d=%d\r\n",i,Settings::get_Offset(i));
rebonatto 0:fac116e94d44 74 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 75 return 0;
rebonatto 0:fac116e94d44 76 }
rebonatto 0:fac116e94d44 77
rebonatto 0:fac116e94d44 78 sprintf(b,"limit%d",i);
rebonatto 0:fac116e94d44 79 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 80 {
rebonatto 0:fac116e94d44 81 sprintf(b,"\r\nlimit%d=%f\r\n",i,Settings::get_Limit(i));
rebonatto 0:fac116e94d44 82 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 83 return 0;
rebonatto 0:fac116e94d44 84 }
rebonatto 0:fac116e94d44 85
rebonatto 0:fac116e94d44 86 sprintf(b,"outlet_number%d",i);
rebonatto 0:fac116e94d44 87 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 88 {
rebonatto 0:fac116e94d44 89 sprintf(b,"\r\noutlet_number%d=%d\r\n",i,Settings::get_OutletNumber(i));
rebonatto 0:fac116e94d44 90 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 91 return 0;
rebonatto 0:fac116e94d44 92 }
rebonatto 0:fac116e94d44 93
rebonatto 0:fac116e94d44 94 sprintf(b,"purpose%d",i);
rebonatto 0:fac116e94d44 95 if(!strcmp(argv[1],b))
rebonatto 0:fac116e94d44 96 {
rebonatto 0:fac116e94d44 97 sprintf(b,"\r\npurpose%d=%c\r\n",i,Settings::get_Purpose(i));
rebonatto 0:fac116e94d44 98 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 99 return 0;
rebonatto 0:fac116e94d44 100 }
rebonatto 0:fac116e94d44 101 }
rebonatto 0:fac116e94d44 102
rebonatto 0:fac116e94d44 103 /*
rebonatto 0:fac116e94d44 104 if(!strcmp(argv[1],"Samples"))
rebonatto 0:fac116e94d44 105 {
rebonatto 0:fac116e94d44 106 char b[12];
rebonatto 0:fac116e94d44 107 conn->send("\r\nSamples=",strlen("\r\nSamples="));
rebonatto 0:fac116e94d44 108 sprintf(b,"%d\r\n",NUMBER_OF_SAMPLES);
rebonatto 0:fac116e94d44 109 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 110 return 0;
rebonatto 0:fac116e94d44 111 }
rebonatto 0:fac116e94d44 112 */
rebonatto 0:fac116e94d44 113 if(!strcmp(argv[1],"EventLimit"))
rebonatto 0:fac116e94d44 114 {
rebonatto 0:fac116e94d44 115 char b[12];
rebonatto 0:fac116e94d44 116 conn->send("\r\nEventLimit=",strlen("\r\nEventLimit="));
rebonatto 0:fac116e94d44 117 sprintf(b,"%d\r\n",Settings::get_EventLimit());
rebonatto 0:fac116e94d44 118 conn->send(b,strlen(b));
rebonatto 0:fac116e94d44 119 return 0;
rebonatto 0:fac116e94d44 120 }
rebonatto 0:fac116e94d44 121
rebonatto 0:fac116e94d44 122 conn->send(param_not_found_msg_get,strlen(param_not_found_msg_get));
rebonatto 0:fac116e94d44 123 return 0;
rebonatto 0:fac116e94d44 124
rebonatto 0:fac116e94d44 125 }