es_logic() requires pointer to valid thread_context, but the pointer was
only assigned properly when running echoserver as a background thread.
Now the pointer is assigned in both cases, that is for running in
background and foreground.
err_t err = ERR_OK;
uint8_t pindex;
int thread_nr;
err_t err = ERR_OK;
uint8_t pindex;
int thread_nr;
+ int command = ES_COMMAND_RUN_FOREGROUND;
unsigned int port_no = 0;
int i;
unsigned int port_no = 0;
int i;
/* Parse the "command line" arguments */
for (pindex = 1; param[pindex] != 0; pindex++) {
if (strncmp(param[pindex], "-c", 3) == 0) {
/* Parse the "command line" arguments */
for (pindex = 1; param[pindex] != 0; pindex++) {
if (strncmp(param[pindex], "-c", 3) == 0) {
+ if (command != ES_COMMAND_RUN_FOREGROUND) {
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
command = ES_COMMAND_KILL_ALL_THREADS;
} else if (strncmp(param[pindex], "-l", 3) == 0) {
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
command = ES_COMMAND_KILL_ALL_THREADS;
} else if (strncmp(param[pindex], "-l", 3) == 0) {
+ if (command != ES_COMMAND_RUN_FOREGROUND) {
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
command = ES_COMMAND_LIST_THREADS;
} else if (strncmp(param[pindex], "-t", 3) == 0) {
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
command = ES_COMMAND_LIST_THREADS;
} else if (strncmp(param[pindex], "-t", 3) == 0) {
+ if (command != ES_COMMAND_RUN_FOREGROUND) {
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
rpp_sci_printf("More than single command are used\n");
return FAILURE;
}
}
/* Port number is mandatory for interactive or background-thread mode */
}
/* Port number is mandatory for interactive or background-thread mode */
- if ((!command || command == ES_COMMAND_NEW_THREAD) && !port_no)
+ if (command == ES_COMMAND_RUN_FOREGROUND || command == ES_COMMAND_NEW_THREAD)
- rpp_sci_printf("Port number not set\n");
- return FAILURE;
- }
+ if (!port_no)
+ {
+ rpp_sci_printf("Port number not set\n");
+ return FAILURE;
+ }
- /* Execute the particular command */
- if (command == ES_COMMAND_NEW_THREAD) {
/* Is there any free preallocated thread handle? */
thread_nr = es_thread_handle_find_first_free();
if (thread_nr < 0) {
/* Is there any free preallocated thread handle? */
thread_nr = es_thread_handle_find_first_free();
if (thread_nr < 0) {
}
thread_context = &es_threads[thread_nr];
thread_context->port_no = port_no;
}
thread_context = &es_threads[thread_nr];
thread_context->port_no = port_no;
+ /* Execute the particular command */
+ if (command == ES_COMMAND_NEW_THREAD) {
unsigned int thread_nr_tmp;
thread_nr_tmp = (thread_nr % 100);
thread_name[2] = (thread_nr_tmp/10) + '0';
unsigned int thread_nr_tmp;
thread_nr_tmp = (thread_nr % 100);
thread_name[2] = (thread_nr_tmp/10) + '0';