- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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' test.c hello line 17 May 23, 2006 9:56:29 AM 1 implicit declaration of function `read' test.c hello line 19 May 23, 2006 9:56:29 AM 1 implicit declaration of function `close' 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't run. http://forum.niosforum.com/work2/style_emoticons/<#EMO_DIR#>/blink.gif Thanks!!Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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'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- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
--- 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'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't know use which lib ? what can i do?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page