| retrohackers.org https://www.retrohackers.org/ |
|
| Help regarding ContikiOS (2.2.x) input event handling https://www.retrohackers.org/viewtopic.php?f=5&t=441 |
Page 1 of 1 |
| Author: | lodger [ Thu Mar 12, 2009 12:18 pm ] |
| Post subject: | Help regarding ContikiOS (2.2.x) input event handling |
Hello everybody, I've been playing around with the ContikiOS (2.2.x) telnetd and shell code, writing an additional shell process that reads 5 lines of text (entered by the user who is connected to the system via telnet) and writes them to a REL file. The "post message" part works flawlessly, but the "read message" part that reads the data and displays it on the screen drives me crazy. The "read" process reads the data and even shows the correct records through the log_message() command. But it refuses to display any text through the shell_output_str() function. Also, the "read" process (unlike the "post" process) does not exit properly (dropping back to the Contiki shell process), causing the C64 to lock up. I've found out so far, that if I comment out the PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input) statement in my "read" code and reading a fixed record number from disk, it works correctly printing all the records through shell_output_str() on the telnet screen and not locking the process. Unfortunately, I need to wait for and process shell input, so the user can type in the number of the message he wants to display. Here's the code that drives me nuts. Any suggestions on how to get the PROCESS_WAIT_EVENT_UNTIL handled correctly (so that it doesn't lock up the process)? Code: PROCESS_THREAD(shell_bbreadmsg_process, ev, data)
{ struct shell_input *input; int uiMsgCount=0; int uiMsgNo=0; short usCount=0; input=data; bbsfile.ucDeviceNo = 8; usCount=0; PROCESS_BEGIN(); while (1) { if (usCount == 0) { strcpy(bbsfile.szFileName, BBS_MSGIDX0); ssReadRELFile(&bbsfile, &uiMsgCount, sizeof(uiMsgCount), 1); sprintf(buffer, "msg count: %u", uiMsgCount); shell_output_str(NULL, buffer, "\n"); shell_prompt("select message #"); PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); input=data; uiMsgNo = atoi(input->data1); /* uiMsgNo=1; */ strcpy(bbsfile.szFileName, BBS_MSGBASE0); ssReadRELFile(&bbsfile, &bbs_msg, sizeof(bbs_msg), uiMsgNo); } if (usCount<=4) { sprintf(buffer, "> %s\n", bbs_msg.szTextLine[usCount]); shell_output_str(NULL, buffer, "\n"); log_message(buffer, ""); } else { PROCESS_EXIT(); } usCount++; } PROCESS_END(); |
|
| Author: | asn [ Thu Mar 12, 2009 11:23 pm ] |
| Post subject: | Re: Help regarding ContikiOS (2.2.x) input event handling |
I think you need to specify the command (defined in the SHELL_COMMAND() macro) as the first parameter to shell_output_str() for it to work. |
|
| Author: | asn [ Thu Mar 12, 2009 11:25 pm ] |
| Post subject: | Re: Help regarding ContikiOS (2.2.x) input event handling |
Also, you need to make uiMsgCount, uiMsgNo, and usCount static or else their values will be trashed on every PROCESS_WAIT_EVENT(). |
|
| Page 1 of 1 | All times are UTC [ DST ] |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|