Hello,
It appears like xillydemo.v is exactly the code that arrives with the bundle. Please, when that is the case, say so. No point reading it through if it's just the same plain loopback.
As for the C++ code, I see two serious issues:
(1) You don't check the return value of neither read() or write() calls. Please refer to section 3.2 and 3.3 of the Xillybus host application programming guide for Linux (
http://xillybus.com/downloads/doc/xilly ... _linux.pdf), and possibly compare with the sample streamread.c and streamwrite.c programs. read() and write() may handle less data than requested, and reflect that in the return value. This is standard UNIX coding practice. The reason to the picture jumping is most likely a partial read or write which your code failed to handle.
(2) You read() and write() in the same thread. That's a recipe for problems. People who do this often complain that the program hangs for no apparent reason. The reason is related to the partial read() and write() possible in UNIX causing an unbalance between reads and writes. Anyhow, since it appears like you're heading towards a coprocessing application, I suggest looking at section 6.6 in the Guide mentioned above. It's likely to save you some trouble ahead.
So -- consider a fork() for running reads and writes in separate processes, and following UNIX I/O practices to make sure data isn't lost.
Regards,
Eli