Hello all, I have a problem with the function write(fd,data,sizeof(data));
I use a rs-485 to get value of a PT100 temperature sensor.
I put a 0 to bit 15 on register 0xE800000C to get rs-485 ON
the PT100 needs a command to return temperature, so I need to send some char,
like "TAI".
I try this : fprintf(stderr,"%c",write(fd, 'T', 1));
fprintf(stderr,"%c",write(fd, 'A', 1));
fprintf(stderr,"%c",write(fd, 'I', 1));
But it doesnt work, I dont have a "TAI" print to my screen, I have "???"
I guess its not the good way.
init :
if ((fd = open(devname, O_NOCTTY | O_RDWR)) == -1) {
perror("Can't open serial line");
exit(1);
}
FD_ZERO(&readfd);
FD_ZERO(&exceptfd);
signal(SIGINT, catch_int);
tcgetattr(fd, &oldsetting);
memcpy(&newsetting, &oldsetting, sizeof(newsetting));
cfmakeraw(&newsetting);
cfsetspeed(&newsetting, speed);
}
tcsetattr(fd, TCSANOW, &newsetting);
numfds = (fd > STDIN_FILENO? fd : STDIN_FILENO) + 1;
while (1) {
timeout.tv_sec = 1;
timeout.tv_usec = 0;
//FD_SET(STDIN_FILENO, &readfd);
FD_SET(fd, &readfd);
//FD_SET(STDIN_FILENO, &exceptfd);
FD_SET(fd, &exceptfd);
select(numfds, &readfd, NULL, &exceptfd, &timeout);
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|