On Wed, May 19, 2010 at 08:20:55AM -0000, rodriguezromain62 wrote:
> 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));
If you are using standard write(2) syscall, above does bad things. See:
ssize_t write(int fd, const void *buf, size_t count);
second parameter is pointer to buffer, you are writing numeric value of char
there.
And also write does return number of bytes written (or -1 on case of error).
Regards,
MW
------------------------------------
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/
|