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++

HELP!!

Altera_Forum
Honored Contributor II
900 Views

This is my program: 

# include <stdio.h># include <sys/types.h># include <fcntl.h> 

 

int main() 

int p_button=NULL; 

unsigned int x=0; 

p_button=open("/dev/ttyS0",O_RDWR); 

if(p_button<0) 

printf("\nopen uart device ERROE!\n"); 

return 0; 

for(x=200;x<256;x++) 

write(p_button,&x,1); 

printf("write rs232 end!\n"); 

read(p_button,&x,1); 

printf("read rs232 end!\n"); 

if(x==0) {close(p_button);return 0;} 

close(p_button); 

 

These are the problems: 

Severity Description Resource In Folder Location Creation Time 

1 initialization makes integer from pointer without a cast test.c hello line 7 May 23, 2006 9:56:29 AM 

1 implicit declaration of function `write&#39; test.c hello line 17 May 23, 2006 9:56:29 AM 

1 implicit declaration of function `read&#39; test.c hello line 19 May 23, 2006 9:56:29 AM 

1 implicit declaration of function `close&#39; test.c hello line 21 May 23, 2006 9:56:29 AM 

 

They are warning ! 

 

 

But,it always die in "read",Why?? 

 

another problem :when I download program(*.exe) in the target though FTP, the problem can&#39;t run. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif  

 

Thanks!!
0 Kudos
3 Replies
Altera_Forum
Honored Contributor II
228 Views

hi, 

 

I think the problem is with a missing include library; 

 

because when it says : "implicite declaration of function read()" 

 

it means that the compiler can&#39;t find definition of the function. 

 

so u must : 

 

1) be shure that all required libraries are included 

2) specify the whole path for types.h in :# include <sys/types.h> 

 

best regards http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/biggrin.gif
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

 

--- Quote Start ---  

originally posted by sdhnain@May 23 2006, 11:05 PM 

hi, 

 

i think the problem is with a missing include library; 

 

because when it says : "implicite declaration of function read()" 

 

it means that the compiler can&#39;t find definition of the function. 

 

so u must : 

 

1) be shure that all required libraries are included 

2) specify the whole path for types.h in :# include <sys/types.h> 

 

best regards  http://forum.niosforum.com/work2/style_emoticons/<#emo_dir#>/biggrin.gif  

<div align='right'><{post_snapback}> (index.php?act=findpost&pid=15532) 

--- quote end ---  

 

--- Quote End ---  

 

 

First,thanks! 

there are very much lib about serial port,so I don&#39;t know use which lib ? 

what can i do?
0 Kudos
Altera_Forum
Honored Contributor II
228 Views

You can do a man on whatever function you have in question: 

 

man read 

 

Try it on LINUX or try it on google. 

 

Results: 

# include <unistd.h> 

 

ssize_t read(int fd, void *buf, size_t count); 

 

And a whole pile more of information about the read function.
0 Kudos
Reply