@@ -101,12 +101,14 @@ void main_usage(int exitcode, char *str, char *dev)
101101 " -l, --logfile=<logfile> log output to <logfile>\n"
102102 " -o, --listenonly Do not modify local terminal, do not send input\n"
103103 " from stdin\n"
104- " -a, --answerback=<str> specify the answerback string sent as response to\n"
104+ " -a, --answerback=<str> specify the answerback string sent as response to\n"
105105 " an ENQ (ASCII 0x05) Character\n"
106+ " -e, --escape-char=<chr> escape charater to use with Ctrl (%c)\n"
106107 " -v, --version print version string\n"
107108 " -h, --help This help\n" ,
108109 DEFAULT_DEVICE , DEFAULT_BAUDRATE ,
109- DEFAULT_CAN_INTERFACE , DEFAULT_CAN_ID , DEFAULT_CAN_ID );
110+ DEFAULT_CAN_INTERFACE , DEFAULT_CAN_ID , DEFAULT_CAN_ID ,
111+ DEFAULT_ESCAPE_CHAR );
110112 fprintf (stderr , "Exitcode %d - %s %s\n\n" , exitcode , str , dev );
111113 exit (exitcode );
112114}
@@ -115,6 +117,7 @@ int opt_force = 0;
115117unsigned long current_speed = DEFAULT_BAUDRATE ;
116118int current_flow = FLOW_NONE ;
117119int listenonly = 0 ;
120+ char escape_char = DEFAULT_ESCAPE_CHAR ;
118121
119122int main (int argc , char * argv [])
120123{
@@ -141,7 +144,7 @@ int main(int argc, char *argv[])
141144 { },
142145 };
143146
144- while ((opt = getopt_long (argc , argv , "hp:s:t:c:dfl:oi:a:v" , long_options , NULL )) != -1 ) {
147+ while ((opt = getopt_long (argc , argv , "hp:s:t:c:dfl:oi:a:e: v" , long_options , NULL )) != -1 ) {
145148 switch (opt ) {
146149 case '?' :
147150 main_usage (1 , "" , "" );
@@ -182,6 +185,13 @@ int main(int argc, char *argv[])
182185 case 'a' :
183186 answerback = optarg ;
184187 break ;
188+ case 'e' :
189+ if (strlen (optarg ) != 1 ) {
190+ fprintf (stderr , "Option -e requires a single character argument.\n" );
191+ exit (EXIT_FAILURE );
192+ }
193+ escape_char = * optarg ;
194+ break ;
185195 }
186196 }
187197
@@ -229,7 +239,7 @@ int main(int argc, char *argv[])
229239 ios -> set_flow (ios , current_flow );
230240
231241 if (!listenonly ) {
232- printf ("Escape character: Ctrl-\\\n" );
242+ printf ("Escape character: Ctrl-%c\n" , escape_char );
233243 printf ("Type the escape character to get to the prompt.\n" );
234244
235245 /* Now deal with the local terminal side */
0 commit comments