OK,
I found some dumb mistakes in coding. I tested with Hyperterminal on
another computer and could see write command work. Read appeared to
work but required I hit the enter key when in Hyperterminal.
When connecting back to device the write command works but I hang
when attempting to read. I must have one of the c_cflag parameters
sent wrong.
Any help is appreciated
--- In "bonjelo2000" <> wrote:
>
>
> Hi,
>
> I am attempting to communicate with a device.
>
> I use the folowing write and read commands. The write appears to
work
> in that the device responds correctly to the appropriate command
sent.
> The read command always returns a -1.
>
> i=write(fd_com,cSendBuf,iSendLen);
>
> sleep(1);
>
> iReturnLen=read(fd_com,cRecBuf,6);
>
>
> int comm_init ()
> {
> struct termios termConf;
> bzero (&termConf, sizeof (struct termios));
>
> tcgetattr(fd_com, &termConf);
>
> termConf.c_cflag = B38400 | CREAD | CLOCAL;
> termConf.c_cflag |= PARENB;
> termConf.c_cflag &= ~PARODD;
> termConf.c_cflag &= ~CSIZE;
> termConf.c_cflag |= CS8;
> termConf.c_cflag |= CRTSCTS;
>
> fd_com = open(PORT, O_RDWR | O_NOCTTY | O_NDELAY);
> if (fd_com < 0)
> {
> return FAILURE;
> }
>
> tcsetattr(fd_com, TCSADRAIN, &termConf); // Set the new
options for
> the port...
>
> return SUCCESS;
> }
>
>
>
> -----------------------------------------------------
> So what are you trying to do?
>
> I don't understand what you mean by "read commands"?
>
> did you write a program to use COM2, or are you trying to use
> it as a login port?
>
------------------------------------
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/
|