--- In "weide72" <> wrote:
>
> I am trying to communicate with a device that measures voltage,
> amps, etc. via COM2 on the TS-7260. The device needs a 4-byte array
> sent to it and responds with a 3-byte array containing the requested
> information. I am pretty sure that I have intialized all the
> settings for COM2 correctly. I guess I'm not sure what the correct
> way to send the 4-byte array is or if I need to do anything more to
> set up COM2 besides in code. Can anyone help? My code is as
> follows:
>
[snipped]
>
> fd = open("/dev/ttyAM1", O_RDWR | O_NOCTTY | O_NDELAY | O_NONBLOCK);
[snipped]
> n = write(fd,send,4);
>
> n = read(fd,buf,3);
At first glance I would think it is not getting a read because you
haven't finished transmitting the write data by the time you are
making the read call. You have the I/O set to non-blocking so this is
entirely possible.
Either remove O_NDELAY and O_NONBLOCK or insert a sleep(1); between
the write and the read call.
Amardeep
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|