Log in

View Full Version : Data Logging to cRIO using c++


raflood
17-11-2013, 14:32
We've been attempting to log binary data to the cRIO using C++. We are able to log to a file and upload it to the PC, but the file is getting corrupted. We are logging floating point numbers at a 200 Hz rate. Looking at the log file in a hex editor, we can see that several dozen floating point numbers will get logged just fine. Then we will see the first two bytes of a new float, and then the next float will appear in the file. We are logging doubles, so each float is 4 bytes long. In other words, two bytes of the four byte float is written, then the next full float is written. We are using ioLib to perform the data logging.

Has anyone had success logging data to directly to a cRIO file?

Aaron.Graeve
17-11-2013, 15:04
We have had experience logging to a file on the cRIO and then pulling the file off via FTP in C++ and Java. Just wondering, why did you chose to log the data into a binary file over a more-readable text file form?

connor.worley
17-11-2013, 15:48
Have you tried using the C standard library instead of ioLib?

Greg McKaskle
17-11-2013, 20:30
There is nothing wrong with your approach, so there must be something wrong with the implementation.

Review the code that writes the binary to ensure that it writes what you expect. Pay special attention to conditional code.

ftp the file three ways, once using binary mode, once using text mode, and once with automatic. Use file size or contents or diff to determine if the auto matched binary or text. My suspicion is that the file was corrupted during the transfer using text mode.

Review the code that parses the binary file, again paying close attention to any conditional code.

Greg McKaskle

raflood
21-11-2013, 22:40
We were unknowingly doing an ASCII FTP file transfer. Changing to a binary transfer fixed our problem. Thanks for all the suggestions.