Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.

Non-blocking fgets

Altera_Forum
Honored Contributor II
1,172 Views

Hi, 

 

I'm interfacing MAX10 fpga development kit with matlab. The matlab sends command to the .c file which in turns request data from the fpga development kit. I'm able to acquire data continuously but want to do a modification in my code that when matlab send a "STOP" command, the .c file should suspend the data acquisition process from the board. I'm using fgets but as it's a non-blocking function, hence I'm getting stuck in the loop as fgets is waiting for a command. How can I avoid this ? Can anyone please help me resolve this issue ?  

 

Thanks,
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
308 Views

Perhaps you could think about using the getchar() function instead. 

This way you could manage yourself incomming characters one-by-one.
Altera_Forum
Honored Contributor II
308 Views

Hi, 

 

Could you please be more elaborate on this ?  

I'm using fcntl(_serialPort, F_SETFL, fcntl(_serialPort, F_GETFL, 0) | O_NONBLOCK); to make the fgets Non-blocking but still it doesn't work. 

 

Thanks,
Reply