exedor: Try packet sizes of 36 and 43, they might help you see where your bug is
When using that stty hack I find it better having open(...) before system("stty ..."). It's always been reliable for me but even so I wouldn't use it in production code or code for profiling.