Forum Discussion
file io with NIOS II
- 5 years ago
Hi, Dong Wook
You are right.
However, there is another way, ie using a character-mode device like UART.
Below example is to write characters to a UART called uart1. You can find the device name (/dev/uart1) in the system.h
#include <stdio.h>
#include <string.h>
int main (void)
{
char* msg = "hello world";
FILE* fp;
fp = fopen ("/dev/uart1", "w");
if (fp!=NULL) { fprintf(fp, "%s",msg); fclose (fp);}
return 0;
}
Thanks.
Eric
Hi, Dong Wook
Can you try to enable the altera_hostfs in your BSP Editor under Software Packages tab (to enable HAL file system) ?
There is mount point which within the HAL file system. For example, if you name the mount point /mnt/host and the project directory on you host computer is /sofware/project1, in a HAL-based program, the following code opens the file /sofware/project1/datafile.dat.:
fopen(“/mnt/host/datafile.dat”, “r”);
Thanks.
Eric