From: David K. <da...@em...> - 2011-04-08 19:59:28
|
Maybe something similar to PSOCK_GENERATOR_SEND is what you are looking for, a subroutine that returns to the main idle loop until it’s job is done, then returns to the calling protothread? See examples in /apps/webserver/httpd-cgi.c, and the way the calls are handled in /core/psock.c From: Payton Byrd Sent: Friday, April 08, 2011 3:15 PM To: Contiki developer mailing list Subject: Re: [Contiki-developers] Introduction and initial question Just curious if anyone has any insight into what's going on here. Can someone point to a comprehensive example of doing this the right way? On Tue, Apr 5, 2011 at 10:33 PM, Payton Byrd <pl...@gm...> wrote: 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. -- Payton Byrd <http://www.paytonbyrd.com> <http://it.toolbox.com/blogs/paytonbyrd> -------------------------------------------------------------------------------- ------------------------------------------------------------------------------ Xperia(TM) PLAY It's a major breakthrough. An authentic gaming smartphone on the nation's most reliable network. And it wants your games. http://p.sf.net/sfu/verizon-sfdev -------------------------------------------------------------------------------- _______________________________________________ Contiki-developers mailing list Con...@li... https://lists.sourceforge.net/lists/listinfo/contiki-developers |