FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Debian > Debian User

 
 
LinkBack Thread Tools
 
Old 04-26-2012, 04:31 PM
abdelkader belahcene
 
Default can write on serial port but not read

Hi,
please I want to read from serial port, I can write but not read, here is my program.* thanks for
help
regards
bela

#include <stdio.h> /* Standard input/output definitions */

#include <string.h> /* String function definitions */
#include <unistd.h> /* UNIX standard function definitions */
#include <fcntl.h> /* File control definitions */
#include <errno.h> /* Error number definitions */

#include <termios.h>
int main(){
* int fd, n; char rr[10];
* fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
* n = write(fd, "ATZ
", 4);
* if (n < 0)*** puts("write() of 4 bytes failed!
");

* else******** puts("4 bytes success!
");
* //* fcntl(fd, F_SETFL, 0);
* //* with the previous it waits ...* for ever
* //* with next no thing read : fails***
*** fcntl(fd, F_SETFL, FNDELAY);
* n = read(fd, rr,2 );

* if (n < 0)** puts("
read* 4 bytes failed!
");
* else*** printf("
Message read is* %s
", rr);
* close(fd);
}
 

Thread Tools




All times are GMT. The time now is 05:41 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org