Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++

char driver

Altera_Forum
Honored Contributor II
866 Views

Is it not possible to have two successive writes/reads for a device opened in "r+" mode without closing and reopening the device? I have written char driver for this device which has a number of registers to be read and written. Are successive writes possible in some other fopen mode ("w+" etc?). Or this should be taken care of in the driver? Or is it a virtue of char mode drivers? 

 

Thanks! 

Pankaj
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
176 Views

$ man fopen: 

The fopen function opens the file whose name is the string pointed to by path and associates a stream with it. 

 

For device files, you need to use: 

 

int handle = open(/dev/mtd/5, O_RDWR); /* ... */ close(handle);
0 Kudos
Reply