![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Versão do protegemed que calcula o tempo em ms da fuga, calcula o numero de onverflow (valores muito baixo) e underflow (valores muito altos). Além disso, calcula um valor médio a partir dos valores capturados e não apenas pela fft.
Dependencies: EthernetInterface mbed-rtos mbed
Codes/TelnetCommands/telnet_getparam.cpp@0:c64e1194230b, 2014-07-09 (annotated)
- Committer:
- rebonatto
- Date:
- Wed Jul 09 21:16:23 2014 +0000
- Revision:
- 0:c64e1194230b
Vers?o do Protegemed com calculo de tempo de fuga, overflow, underflow e novo valor m?dio (manual).
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rebonatto | 0:c64e1194230b | 1 | #include "TelnetServer.h" |
rebonatto | 0:c64e1194230b | 2 | |
rebonatto | 0:c64e1194230b | 3 | #include "Settings.h" |
rebonatto | 0:c64e1194230b | 4 | |
rebonatto | 0:c64e1194230b | 5 | char *wrong_args_msg_get = "Wrong number of arguments.\r\n\r\nUsage: getparam <parameter name>\r\n"; |
rebonatto | 0:c64e1194230b | 6 | char *param_not_found_msg_get = "Parameter not found.\r\n\r\n"; |
rebonatto | 0:c64e1194230b | 7 | |
rebonatto | 0:c64e1194230b | 8 | |
rebonatto | 0:c64e1194230b | 9 | int TelnetServer::GetParamCommand(TCPSocketConnection *conn,char** argv,int argc) |
rebonatto | 0:c64e1194230b | 10 | { |
rebonatto | 0:c64e1194230b | 11 | |
rebonatto | 0:c64e1194230b | 12 | if(argc != 2) |
rebonatto | 0:c64e1194230b | 13 | { |
rebonatto | 0:c64e1194230b | 14 | conn->send(wrong_args_msg_get,strlen(wrong_args_msg_get)); |
rebonatto | 0:c64e1194230b | 15 | return 0; |
rebonatto | 0:c64e1194230b | 16 | } |
rebonatto | 0:c64e1194230b | 17 | |
rebonatto | 0:c64e1194230b | 18 | printf("Getting parameter\n"); |
rebonatto | 0:c64e1194230b | 19 | |
rebonatto | 0:c64e1194230b | 20 | if(!strcmp(argv[1],"ipserver")) |
rebonatto | 0:c64e1194230b | 21 | { |
rebonatto | 0:c64e1194230b | 22 | conn->send("\r\nipserver=",strlen("\r\nipserver=")); |
rebonatto | 0:c64e1194230b | 23 | conn->send(Settings::get_ServerUrl(),strlen(Settings::get_ServerUrl())); |
rebonatto | 0:c64e1194230b | 24 | conn->send("\r\n",strlen("\r\n")); |
rebonatto | 0:c64e1194230b | 25 | return 0; |
rebonatto | 0:c64e1194230b | 26 | } |
rebonatto | 0:c64e1194230b | 27 | |
rebonatto | 0:c64e1194230b | 28 | if(!strcmp(argv[1],"module")) |
rebonatto | 0:c64e1194230b | 29 | { |
rebonatto | 0:c64e1194230b | 30 | char b[12]; |
rebonatto | 0:c64e1194230b | 31 | conn->send("\r\nmodule=",strlen("\r\nmodule=")); |
rebonatto | 0:c64e1194230b | 32 | sprintf(b,"%d\r\n",Settings::get_ModuleNumber()); |
rebonatto | 0:c64e1194230b | 33 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 34 | return 0; |
rebonatto | 0:c64e1194230b | 35 | } |
rebonatto | 0:c64e1194230b | 36 | |
rebonatto | 0:c64e1194230b | 37 | int i; |
rebonatto | 0:c64e1194230b | 38 | for(i=0;i<Settings::get_MaxOutlets();i++) |
rebonatto | 0:c64e1194230b | 39 | { |
rebonatto | 0:c64e1194230b | 40 | char b[12]; |
rebonatto | 0:c64e1194230b | 41 | sprintf(b,"outlet%d",i); |
rebonatto | 0:c64e1194230b | 42 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 43 | { |
rebonatto | 0:c64e1194230b | 44 | sprintf(b,"\r\noutlet%d=%d\r\n",i,Settings::get_Outlet(i)); |
rebonatto | 0:c64e1194230b | 45 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 46 | return 0; |
rebonatto | 0:c64e1194230b | 47 | } |
rebonatto | 0:c64e1194230b | 48 | } |
rebonatto | 0:c64e1194230b | 49 | for(i=0;i<Settings::get_MaxChannels();i++) |
rebonatto | 0:c64e1194230b | 50 | { |
rebonatto | 0:c64e1194230b | 51 | char b[12]; |
rebonatto | 0:c64e1194230b | 52 | sprintf(b,"gain%d",i); |
rebonatto | 0:c64e1194230b | 53 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 54 | { |
rebonatto | 0:c64e1194230b | 55 | sprintf(b,"\r\ngain%d=%f\r\n",i,Settings::get_Gain(i)); |
rebonatto | 0:c64e1194230b | 56 | printf("Getting gain\n"); |
rebonatto | 0:c64e1194230b | 57 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 58 | return 0; |
rebonatto | 0:c64e1194230b | 59 | } |
rebonatto | 0:c64e1194230b | 60 | |
rebonatto | 0:c64e1194230b | 61 | sprintf(b,"offset%d",i); |
rebonatto | 0:c64e1194230b | 62 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 63 | { |
rebonatto | 0:c64e1194230b | 64 | sprintf(b,"\r\noffset%d=%d\r\n",i,Settings::get_Offset(i)); |
rebonatto | 0:c64e1194230b | 65 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 66 | return 0; |
rebonatto | 0:c64e1194230b | 67 | } |
rebonatto | 0:c64e1194230b | 68 | |
rebonatto | 0:c64e1194230b | 69 | sprintf(b,"limit%d",i); |
rebonatto | 0:c64e1194230b | 70 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 71 | { |
rebonatto | 0:c64e1194230b | 72 | sprintf(b,"\r\nlimit%d=%f\r\n",i,Settings::get_Limit(i)); |
rebonatto | 0:c64e1194230b | 73 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 74 | return 0; |
rebonatto | 0:c64e1194230b | 75 | } |
rebonatto | 0:c64e1194230b | 76 | |
rebonatto | 0:c64e1194230b | 77 | sprintf(b,"outlet_number%d",i); |
rebonatto | 0:c64e1194230b | 78 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 79 | { |
rebonatto | 0:c64e1194230b | 80 | sprintf(b,"\r\noutlet_number%d=%d\r\n",i,Settings::get_OutletNumber(i)); |
rebonatto | 0:c64e1194230b | 81 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 82 | return 0; |
rebonatto | 0:c64e1194230b | 83 | } |
rebonatto | 0:c64e1194230b | 84 | |
rebonatto | 0:c64e1194230b | 85 | sprintf(b,"purpose%d",i); |
rebonatto | 0:c64e1194230b | 86 | if(!strcmp(argv[1],b)) |
rebonatto | 0:c64e1194230b | 87 | { |
rebonatto | 0:c64e1194230b | 88 | sprintf(b,"\r\npurpose%d=%c\r\n",i,Settings::get_Purpose(i)); |
rebonatto | 0:c64e1194230b | 89 | conn->send(b,strlen(b)); |
rebonatto | 0:c64e1194230b | 90 | return 0; |
rebonatto | 0:c64e1194230b | 91 | } |
rebonatto | 0:c64e1194230b | 92 | } |
rebonatto | 0:c64e1194230b | 93 | |
rebonatto | 0:c64e1194230b | 94 | conn->send(param_not_found_msg_get,strlen(param_not_found_msg_get)); |
rebonatto | 0:c64e1194230b | 95 | return 0; |
rebonatto | 0:c64e1194230b | 96 | |
rebonatto | 0:c64e1194230b | 97 | } |