From: Payton B. <pl...@gm...> - 2011-04-06 03:34:19
|
On Mon, Apr 4, 2011 at 2:48 PM, Nicolas Tsiftes <nv...@si...> wrote: > Payton Byrd wrote 2011-04-04 03:55: > > Hello! > > My name's Payton and I'm a retroputing addict. > > I also happen to be a programmer and so mixing the two has led me to > starting some development with Contiki. Right now my focus is on learning > the ins-and-outs of text-based processing and am currently porting a simple > input-output game to using the telnet-server example. I've created a > process for the game and can get the game to output data using > shell_output_str. My conundrum today is how do I get input from the user? > I've looked at shell_input, but I cannot figure out where to get results > from it. Is there a good example that I should be looking at? > > Thanks! > > > Hello Payton, > > One example that uses the shell's input method is > apps/shell/shell-coffee.c. After typing the "format" command, the command > asks the user to answer whether to proceed or not. telnetd calls > shell_input, and the data is posted to the shell command process as an event > called "shell_event_input". > > Nicolas > Nicolas, Thank you for the reply. I found the code in shell-coffee.c that reads the input from the client. However, this has raised some concerns and questions for me that I may not be using the correct code. The method I found to read from the client is this: PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); d = data; if(d->len1 > 0) { strcpy(input, d->data1); } The concern I have is that the PROCESS_WAIT_EVENT_UNTIL macro will not compile unless it is placed inside of a method that was declared with the PROCESS_THREAD macro. I want to be able to read input from some deeply nested logic and don't see how I'll be able to expose the appropriate variable in the PROCESS_WAIT_EVENT_UNTIL macro all the way through the call stack. The problem I'm having is that I can read from the client fine one time, but after that trying to send data back to the client with shell_default_output no longer works and then when the loop returns back to the PROCESS_WAIT_EVENT_UNTIL macro to read more data the server starts sending gobs of data that eventually cause the telnet client to abort because of a buffer overflow, and sometimes the server will actually just drop to the ready prompt (my target is the Commodore 64). As before, any help would be greatly appreciated. |