Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EthernetInterface mbed-rtos mbed
telnet_getparam.cpp
00001 #include "TelnetServer.h" 00002 00003 #include "Settings.h" 00004 00005 char *wrong_args_msg_get = "Wrong number of arguments.\r\n\r\nUsage: getparam <parameter name>\r\n"; 00006 char *param_not_found_msg_get = "Parameter not found.\r\n\r\n"; 00007 00008 00009 int TelnetServer::GetParamCommand(TCPSocketConnection *conn,char** argv,int argc) 00010 { 00011 00012 if(argc != 2) 00013 { 00014 conn->send(wrong_args_msg_get,strlen(wrong_args_msg_get)); 00015 return 0; 00016 } 00017 00018 printf("Getting parameter\n"); 00019 00020 if(!strcmp(argv[1],"ipserver")) 00021 { 00022 conn->send("\r\nipserver=",strlen("\r\nipserver=")); 00023 conn->send(Settings::get_ServerUrl(),strlen(Settings::get_ServerUrl())); 00024 conn->send("\r\n",strlen("\r\n")); 00025 return 0; 00026 } 00027 00028 if(!strcmp(argv[1],"module")) 00029 { 00030 char b[12]; 00031 conn->send("\r\nmodule=",strlen("\r\nmodule=")); 00032 sprintf(b,"%d\r\n",Settings::get_ModuleNumber()); 00033 conn->send(b,strlen(b)); 00034 return 0; 00035 } 00036 00037 int i; 00038 for(i=0;i<Settings::get_MaxOutlets();i++) 00039 { 00040 char b[12]; 00041 sprintf(b,"outlet%d",i); 00042 if(!strcmp(argv[1],b)) 00043 { 00044 sprintf(b,"\r\noutlet%d=%d\r\n",i,Settings::get_Outlet(i)); 00045 conn->send(b,strlen(b)); 00046 return 0; 00047 } 00048 } 00049 for(i=0;i<Settings::get_MaxChannels();i++) 00050 { 00051 char b[12]; 00052 sprintf(b,"gain%d",i); 00053 if(!strcmp(argv[1],b)) 00054 { 00055 sprintf(b,"\r\ngain%d=%f\r\n",i,Settings::get_Gain(i)); 00056 printf("Getting gain\n"); 00057 conn->send(b,strlen(b)); 00058 return 0; 00059 } 00060 00061 sprintf(b,"offset%d",i); 00062 if(!strcmp(argv[1],b)) 00063 { 00064 sprintf(b,"\r\noffset%d=%d\r\n",i,Settings::get_Offset(i)); 00065 conn->send(b,strlen(b)); 00066 return 0; 00067 } 00068 00069 sprintf(b,"limit%d",i); 00070 if(!strcmp(argv[1],b)) 00071 { 00072 sprintf(b,"\r\nlimit%d=%f\r\n",i,Settings::get_Limit(i)); 00073 conn->send(b,strlen(b)); 00074 return 0; 00075 } 00076 00077 sprintf(b,"outlet_number%d",i); 00078 if(!strcmp(argv[1],b)) 00079 { 00080 sprintf(b,"\r\noutlet_number%d=%d\r\n",i,Settings::get_OutletNumber(i)); 00081 conn->send(b,strlen(b)); 00082 return 0; 00083 } 00084 00085 sprintf(b,"purpose%d",i); 00086 if(!strcmp(argv[1],b)) 00087 { 00088 sprintf(b,"\r\npurpose%d=%c\r\n",i,Settings::get_Purpose(i)); 00089 conn->send(b,strlen(b)); 00090 return 0; 00091 } 00092 } 00093 00094 conn->send(param_not_found_msg_get,strlen(param_not_found_msg_get)); 00095 return 0; 00096 00097 }
Generated on Fri Jul 22 2022 19:25:55 by
