Freeing ttyS0 for loopback test - application hangs/blocks
I run Montavista 2.6.18 on ARM/TI.
I need to use external loopback on ttyS0, which is linux console by default. The application will test the whole serial track via loopback. It is started from initd (script in rc3.d) and getty start in iniittab is allowed as "once" only (not respawn). The reduced initialization code looks like: system("killall getty"); out = open("/dev/null", O_WRONLY); dup2(out, fileno(stdout)) fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NONBLOCK); tcgetattr(fd, &Opts); cfmakeraw(&Opts); Opts.c_cflag &= ~CRTSCTS; Opts.c_cflag |= CLOCAL | CREAD; tcsetattr(fd,TCSANOW,&Opts); Now, the questions/problems: 1. When the first line of the initialization code system("killall getty") is active, application hangs at this point (never exits system() call), if the loopback is closed. Otherwise it passes OK, the test starts, and even passes, when I close the loopback later. 2. Removing system() call allows the application to initialize and pass to the first write(fd,"Test text",10), which hangs. Again the same - starting with loopback opened and closing it later after makes everything working as required. Any hints/recommendations/help will be highly appreciated... |
remove these lines, they make no sense:
Code:
out = open("/dev/null", O_WRONLY); Also add error-checks to your code: Code:
const char *device= "/dev/ttyS0"; |
Thank you for reply.
Quote:
Quote:
But you are right - my test without getty at all shows that everything is working fine. So, the question now is why I cannot remain getty with "once" option and kill it from within the application! Quote:
|
(you don't have to stop every getty, only the one listening on /dev/ttyS0)
|
All times are GMT -5. The time now is 01:15 AM. |