scanf , getchar, gets, read are not working in libtests\termios and my application
Joel Sherrill
joel.sherrill at OARcorp.com
Thu Apr 19 13:09:04 UTC 2012
On 04/18/2012 10:28 PM, Joel Sherrill wrote:
> Then something is wrong with the input side of the console device driver. You have the source. :)
Well shouldn't answer from phone after a margarita. Making note
to self on that one. Sorry for the tone.
This should be fixed on the git head and 4.10 branch. Vic Hoover
submitted a fairly significant rewrite of the console driver for the
mvme162.
--joel
> There are consultants on the list who can help but having the hardware is a big help itself.
>
> --joel
>
> AJAI KUMAR MEDHAVI<akmedhavi at rrcat.gov.in> wrote:
>
>> Hi
>>
>>
>> I have ported RTEMS-4.10.2 on M68k processor based MVME162 CPU Board using
>> MinGW on Windows XP.
>>
>> I have developed Anaglog / Digtial IO Boards Drivers and Prototype
>> application for testing ADC/DAC device drivers. In this protypte
>> application I have used printf, scanf and getchar.
>>
>>
>> On running my application, scanf getchar are not working. I have enabled
>> following drivers in my application :
>>
>>
>> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
>> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
>> #define CONFIGURE_FILESYSTEM_DEVFS
>> #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
>> #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
>>
>> and included following
>>
>> #include<bsp.h>
>> #include<rtems/bspIo.h>
>> #include<string.h>
>> #include<stdio.h>
>> #include<stdlib.h>
>> #include<errno.h>
>> #include<assert.h>
>> #include<stdarg.h>
>> #include<ctype.h>
>> #include<rtems.h>
>> #include<rtems/error.h>
>> #include<rtems/bspIo.h>
>> #include<rtems/libio.h>
>>
>>
>> #define CONFIGURE_INIT
>> #include<rtems/confdefs.h>
>>
>>
>> Then I tried to run following sample applications provided by RTEMS :
>>
>> 1. Testsuites\libtests\termios
>> 2. Testsuites\smaples\fileio
>>
>>
>> I found the same problem : scanf, fgets not working while printf is working.
>>
>>
>> Then I made a following new test application and tried to test it :
>> ____________________________________________________________________
>> #include<bsp.h> /* for device driver prototypes */
>>
>> #include<rtems/bspIo.h>
>> #include<string.h>
>> #include<stdio.h>
>> #include<stdlib.h>
>> #include<errno.h>
>> #include<assert.h>
>> #include<stdarg.h>
>> #include<ctype.h>
>> #include<rtems.h>
>> #include<rtems/error.h>
>> #include<rtems/bspIo.h>
>> #include<rtems/libio.h>
>>
>> #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
>> #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
>> #define CONFIGURE_FILESYSTEM_DEVFS
>> #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
>>
>> #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
>> #define CONFIGURE_MAXIMUM_TASKS 1
>> #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
>>
>> #define CONFIGURE_INIT
>> #include<rtems/confdefs.h>
>>
>> rtems_task Init( rtems_task_argument ignored )
>> {
>> int ch, ch1, chno;
>> char buf[5], val[3];
>> int nbChar;
>> printf( "WELCOME TO ACCELERATOR CONTROLS .... RTEMS KERNEL ON
>> MVME162-522A \n" );
>> memset(buf, 0, sizeof(buf));
>> printf("enter a string\n");
>> nbChar = read(0, buf, sizeof(buf));
>> printf("string read = %s\n", buf);
>>
>>
>> printf("Press any key to continue 111"); fflush(stdout);
>> ch=getchark();
>> while(!isalpha(ch))
>> ch=getchark();
>> printf("ch : %d",ch); fflush(stdout);
>>
>> printf("\nEnter Channel Number [ 1 TO 32 ] :"); fflush(stdout);
>> scanf("%s",val);
>> chno=(int)strtol((const char *)val,(char**)NULL,10);
>> printf("\nWrite Relay chan no :%d",chno); fflush(stdout);
>>
>> printf("Press any key to continue 222"); fflush(stdout);
>> ch1=getchar();
>> printf("ch : %d",ch1);
>>
>>
>> printf("Please enter your choice(1,2,3,4 or 5) -> "); fflush(stdout);
>> scanf("%d",&ch1);
>> printf("choice : %d",ch1); fflush(stdout);
>>
>> exit( 0 );
>> }
>>
>> ---------------------------------------------------------------------------
>>
>> TEST RESULT :
>> none of scanf, getchar, getchark and read working and application hangs.
>>
>>
>> May someone execute the above program with clock enabled to check
>> if it also fail on their plateform?
>>
>>
>>
>> I am not able to figure out why scanf, gethar etc are not working. Here I
>> have several queries and doubts :
>>
>> 1. Is there any problem /bug with Keyboard driver or console driver
>>
>> 2. Is “scanf / getchar /gets / read” etc has restricted inclusions
>> controlled by some #define or makefile or configure file.
>>
>> 3. Any chance of problem with Initial task stack size.
>>
>> 4. I have USB based keyboard, not PS2 keyboard. However I have tested it
>> with PS2 keyboard also with same result.
>>
>>
>>
>>
>> Any tips / suggestions
>>
>>
>> Can someone help me out?
>>
>>
>> One more thing, how to enable “prinf/puts” for debugging in any part of
>> code/device driver, before starting of Init task.
>>
>>
>>
>> Best Regards
>>
>>
>>
>>
>> AJAI KUMAR MEDHAVI
>> SCIENTIFIC OFFICER
>> RAJA RAMMANNA CENTRE FOR ADVANCED TECHNOLGY
>> DEPARTMENT OF ATOMIC ENERGY, GOV. OF INDIA,
>> PO : CAT, INDORE-452013, INDIA
>> PH. 91-731-2488052
>> Email : akmedhavi at rrcat.gov.in , akmedhavi at rediffmail.com
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> rtems-users mailing list
>> rtems-users at rtems.org
>> http://www.rtems.org/mailman/listinfo/rtems-users
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
--
Joel Sherrill, Ph.D. Director of Research& Development
joel.sherrill at OARcorp.com On-Line Applications Research
Ask me about RTEMS: a free RTOS Huntsville AL 35805
Support Available (256) 722-9985
More information about the users
mailing list