Try compiling the code on the PC and testing that it can run there
without a segmentation fault.
Generally bugs with non-hardware specific code will show up on linux on
the PC. Therefore, you can test your code using valgrind; which I
thoroughly recommend.
Incidentally, shouldn't you be using ttyAM0 / ttyAM1?
And you definitely must remove ttyAM1/0 references from inittab; as
you'll end up with a console on something you're expecting to do i/o
with hardware over.
-bms
Damir Dzemidzic wrote:
>
>
> Donal, I suppose you are quite right I should return value even at the
> end of main(). But it was not the cause of the problem. The
> optimization is not cause either as Jim recommended to check. I had
> the optimization set to NULL. Jim, thanks for suggestion of using
> sleep(1) but did not gimme an insight either. So here is the strace
> output
>
>
> write(1, "Creating com port\n", 18Creating com port
> ) = 18
> write(1, "Created port OK\n", 16Created port OK
> ) = 16
> open("/dev/ttyS1", O_RDWR|O_NONBLOCK|O_NOCTTY) = 3
> fcntl64(3, F_SETFL, O_RDONLY) = 0
> rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
> rt_sigaction(SIGCHLD, NULL, {SIG_DFL}, 8) = 0
> rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
> nanosleep({1, 0}, {1, 0}) = 0
> write(1, "COM2 port has been sucessfully o"..., 74COM2 port has
> been sucessfully
> opened. Descriptor is: 3Opened com port OK
> ) = 74
> ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, {B115200 -opost -isig
> -icanon -echo ...}
> ) = 0
> ioctl(3, TCFLSH, 0) = 0
> ioctl(3, SNDCTL_TMR_START or TCSETS, {B115200 -opost -isig -icanon
> -echo ...}) =
> 0
> write(3, "Testing", 7) = 7
> close(3) = 0
> write(1, "Closed com port\n", 16Closed com port
> ) = 16
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++
>
> Looks not much to me.
>
> One thing left is that I have't commented out the getty process on
> ttyS1 in the /etc/inittab. Perhaps closing fd, may interfere with
> it. But actual terminal ttyS1 has no problems of working with user.
>
>
>
>
>
>
>
------------------------------------
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/
|