Could try adding \x0D to end of string being sent back.
On Thu, Feb 5, 2009 at 1:38 PM, bonjelo2000 <> wrote:
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 ts-7000%40yahoogroups.com, "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?
>
__._,_.___
__,_._,___
|