ts-7000
[Top] [All Lists]

Re: [ts-7000] Problem write on rs-485 TS7800

To:
Subject: Re: [ts-7000] Problem write on rs-485 TS7800
From: Mika Westerberg <>
Date: Wed, 19 May 2010 11:38:05 +0300
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/

<Prev in Thread] Current Thread [Next in Thread>
Admin

Disclaimer: Neither Andrew Taylor nor the University of NSW School of Computer and Engineering take any responsibility for the contents of this archive. It is purely a compilation of material sent by many people to the birding-aus mailing list. It has not been checked for accuracy nor its content verified in any way. If you wish to get material removed from the archive or have other queries about the archive e-mail Andrew Taylor at this address: andrewt@cse.unsw.EDU.AU