Is your serial com port running a console ?? Check /etc/inittab
Le 17.01.2011 18:44, tommessum a écrit :
> Thanks for the quick reply!
>
> Tried that, but it crashed the program :-(
>
> This is because tcdrain() blocks until all output written to the port has
> been transmitted. Since none is, the program just sits there forever. :-(
>
> Could the problem be hardware related? i.e. As I understand, COM2 has
> something to do with RS485. Could there be some hardware signal blocking the
> transmission?
>
>
>
> --- In "Kris"<> wrote:
>>
>> #include<termios.h>
>>
>> int tcdrain(int fildes);
>>
>> That will force the flush of the buffer, this is normal linux behavior.
>>
>> -Kris Bahnsen
>> Technologic Systems
>>
>>
>>
>> --- In "tommessum"<tommessum@> wrote:
>>>
>>> In a nutshell I have: at the start:
>>>
>>> fd = open("/dev/ttyS1", O_RDWR | O_NOCTTY); (1) (2)
>>>
>>> followed by:
>>>
>>> tcgetattr(fd,&oldtio);
>>> newtio.c_cflag = B115200 | CRTSCTS | CS8 | CLOCAL | CREAD ;
>>> newtio.c_iflag = 0;
>>> newtio.c_oflag = 0;
>>> newtio.c_lflag = 0;
>>> newtio.c_cc[VMIN] = 1;
>>> newtio.c_cc[VTIME] = 0;
>>> tcsetattr(fd, TCSANOW,&newtio);
>>>
>>> then later on, to write some data:
>>> write(fd,"hello\r\n",7); (3)
>>>
>>>
>>>
>>> The problem is that data doesn't get sent to the UART until the program is
>>> terminated. The "write" must be buffering the output data obviously. But I
>>> can't figure a way of forcing a flush after the "write".
>>>
>>> There must be some simple obvious explanation, but I can't figure out why!
>>> Any ideas?
>>>
>>> Thanks!
>>>
>>>
>>> NB:
>>>
>>> (1) Also have tried including "O_NDELAY O_NONBLOCK"
>>>
>>> (2) Also have tried including "fcntl(fd, F_SETFL, O_NONBLOCK)"
>>>
>>> (3) Also tried adding fsync(fd), fflush(NULL) after write()
>>>
>
>
>
> ------------------------------------
>
> Yahoo! Groups Links
>
>
>
>
------------------------------------
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/
|