- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that with the small c library enabled stdin,stdou and stderr are "preopened" files, so i can interact with them as files whithout opening them, can't find right now exactly where i saw this info.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Are you saying that, using normal c libraries you are able to read write but not able to read using small c libraries ?
- If simple console read write ->use alt_printf, alt_putstr, alt_putchar & alt_getchar. Refer table 34 gives you the comparison between libraries https://www.intel.com/content/altera-www/global/en_us/index/documentation/mwh1416947091611.html#mwh1416946791328__ID-356-000027c6 OR
- If Read, write to from FPGA peripherals? use IORD and IOWR functions.
Let me know if this has helped resolve the issue you are facing or if you need any further assistance.
Best Regards,
Anand
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, i am able to read incoming data (from the uart) with the full C library, using:
#include <stdio.h>
#include <stdlib.h>
FILE * fp;
char msg[255];
fp = fopen("/dev/uart_0","r");
if(fp)
{
fscanf(fp,"%s",msg);
}
I've tried using the alt library, but it fails with:
home/user/project_name/software/nios_project_name_bsp/HAL/src/alt_getchar.c:67: undefined reference to `getc'
//source snippet
int
alt_getchar(void)
{
#ifdef ALT_SEMIHOSTING
char c;
read(STDIN_FILENO,&c,1);
return c;
#else
#ifdef ALT_USE_DIRECT_DRIVERS
ALT_DRIVER_READ_EXTERNS(ALT_STDIN_DEV);
char c;
if (ALT_DRIVER_READ(ALT_STDIN_DEV, &c, 1, alt_fd_list[STDIN_FILENO].fd_flags) <= 0) {
return -1;
}
return c;
#else
return getchar();
#endif
#endif
}
It seems that the direct device drivers aren't available, and neither is getc.
is it some header missing or something similar?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It seems that with the small c library enabled stdin,stdou and stderr are "preopened" files, so i can interact with them as files whithout opening them, can't find right now exactly where i saw this info.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page