cancel
Showing results for 
Search instead for 
Did you mean: 

CLI Example for Sensor Box Pro

Smithson
Associate III

The sensor box pro is a neat device.  If I use the CLI Example program and the USB cable, I can get 8000 data points per second, if I use a traditional C# program I get 8 data points per second.  

The CLI yields dat files, which can be read with a simple C# program, although why you would mix 6 and 4 data groups is beyond my skill set to understand, but it is easier to use than Python and MEMS Set.   And it is easier to do the byte data in C#.  (It took less time to write this program than I spent trying to get Python to work.)

CLI Example makes me type enter to start.  I have many ST.COM accelerometers all over the world and I am not going to type enter to start, but the main.cpp and main.h and the cmake lists file will not compile in CMAKE or Visual Studio.  So I cannot fix the challenging feature. 

Could we get VS SLNX file and the C++ code for this program as part of the SLNX so it is easy to take out the enter statement and break the output up into data sets that can be analyzed in near real time, like 8 seconds on a bridge in a snow storm in the middle of the night, whilst I am sound asleep 1000 miles away.  

 

This will read your dat files. there is some junk in there as it took me a while to work out the byte structure as the documentation shows a nice picture, but it is without numbers.  

 

I need to improve the routine to break up the bytes, but that is ok as long as the accelerometer is flat. 

One looks for say 8 seconds of record, time for a truck to pass over the bridge, do a FFT preferably in Intel Fortran but who cares and the record the data. After a year you have 3 million records and we then have a good idea about the bridge.  

I would upload a picture to show some output, but it will not let me.  

Thanks.  

<< Cannot include code as message cannot exceed 30000 characters. >>  

The file type (.cs) is not supported. Valid file types are: ai, avi, mp4, bmp, csv, doc, cpd, docx, flv, gif, gz, tar.gz, har, ico, jpg, jpeg, log, mov, mpg, mpeg, mp3, odt, odp, ods, pdf, png, pps, ppt, pptx, rar, rm, tif, tiff, txt, xlr, xls, xlsx, xml, wmv, wav, z, 7z, ioc, hex, c, cc, cpp, h, hpp, tar, xz, dts, s, zip.

One is left to wonder.  Ah, I compress to zip.  

 

29 REPLIES 29

Screenshot 2026-03-15 111414.png

It is fully duplicate data, so now I need to check your log file for errors.  Thanks. 

Screenshot 2026-03-15 113803.png

The duplicates are at 0.01 second intervals except when they are not.  When they are not they are at 149 and 2.  

I like the two numbers 2 and 149 because they are both prime and 76 and 77 are not.  

The acquisition files between the sd card and the USB cable are not in the same order for the same settings.

Thank   you to whoever made Sunday night after a day shopping with a daughter for a prom dress challenging.  

Screenshot 2026-03-15 201927.png

It is just annoying.  They are not even reversed it is just random.  

 

SimonePradolini
ST Employee

Hello @Smithson 

You did so many tests. I'm happy to hear that you’re finding a promising solution, but I need some clarifications to fully support you.

Can you confirm me which firmware is running on the SensorTile.box PRO? Are you referring to FP-SNS-DATALOG2 v3.2.0? Have you already checked the User Manual and Quick Start Guide?

Are you aware about STDATALOG-PYSDK v1.3.0? It's the Python SDK natively supporting the DATALOG2 ecosystem. It includes ready-to-use scripts that you’re free to run and modify to fit your use cases.

 

When received those confirmations, I would come to you with further question to understand the specific bugs/issues you’re addressing.

 

Best regards,

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Dear Simone:

I am running the firmware that pops up after you install the 1.0.0., I think it is called 1.3.0 or some such.  

Screenshot 2026-03-16 200010.png

No experimental engineer who has 8 seconds cycle time for a warning on a bridge issue is going to use Python.  

I prefer Fortran - Intel which the great grand child of Microsoft Fortran.  But using it takes longer. 

But I use C# here and now as I have for all of the ST.COM Accelerometers.  You have a lot of software in C#. 

It is not difficult to write in C#.

The hardest part was to find that the sample rate for the 4 byte elements is 2304 on USB cables and about 15000 to SD cards.  Now I have that worked out, the remaining issue is the double copied elements.  That is a bit longer. 

I want to deploy these to remote locations, so a copy of the CLI Example that does not need the enter to start line would be great.  Decompiling a C++ program like CLI Example is a pain.  

It is a nice little device, I have a bit to learn, but here is the C# code so far.  Once it is running I will put it on git hub. 

I do not understand the time signal bytes, it does not translate into a meaningful number, neither a date or a timespan.  

Thanks for the reply. 

 

John

 

 

 

Code.  It has some directories hard coded, that will change, but not for a while. 

 

I was looking at the hex code for the data files.  It turns out the 2304 decimal offset for the 4 byte code is just HEX 900.   Now that somewhat explains 2304, which is a weird choice.  

Are these codes spelt out somewhere?  I am still perplexed by the duplicate entries.  

 

Hello  

I'm sorry, but we won't include new code examples developed in other programming languages a part from C and Python. You are free to dig into the Python SDK, start from the provided examples, learn about the DATALOG2 features and then develop your application on your own. 

The screenshot you shared shows fw_version 3.2.0. It is the latest, most updated one.

 


 wrote:

[...]

The hardest part was to find that the sample rate for the 4 byte elements is 2304 on USB cables and about 15000 to SD cards.  Now I have that worked out, the remaining issue is the double copied elements.  That is a bit longer. 

[...]

I do not understand the time signal bytes, it does not translate into a meaningful number, neither a date or a timespan.  


I'm sorry, but I'm not understanding the point. User Manual chapter 2.6 contains a complete description of all json metadata and data protocol used. 

Timestamp is a double value (8 bytes) calculated in seconds. Please, refer to 2.6.4 for the detailed explanation.

Sensors sample rates are described in the json metadata as enumerative values. Please, refer to 2.6.5 and 2.6.6 for the detailed explanation.

 

The cli_example you are referring to is for evaluation purposes only. It showcases how to setup and start the firmware from an host via USB. It is not an optimized and tested-on-field application, not granted. Any customization, improvement or specific development is on customer side.

 

I understand you need support to solve the described issue and am sorry if the ST Community has not yet brought you the hoped solution. However, from what you have shared so far, I can't further comment on issues not related to DATALOG2 FW with other than official Python SDK or cli_example. It seems the issue is very specific to your project. Finding a solution to it would require deeper investigation and testing which I am not able to provide via the community. If you need specific support you can also submit your request directly to the Online Support Team: https://ols.st.com/s/ or have a look to the ST Partner Program

 

Best regards,

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Dear Simone:

Thank you for your answer.  I will print out the manual.  

Include new code examples developed in other programming languages a part from C 

The CLI example is all I need but it will not compile with your make file.  How do I get a version that will compile?

 

Thanks

John  

Hello @Smithson 

could you test with the attached CMakeLists.txt file? It substitutes the original one placed in Utilities/cli_example folder.

If it works also on your side, I'll push the file on GitHub so to make the patch publicly available. Then, the fix will be officially included in the next maintenance release of FP-SNS-DATALOG2.

 

Best regards,

Simone

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Dear Simone:

Thank you for your help. 

I tested for 7 hours.  It is now 9:16 pm and I am no further ahead.

I am using a Dell running Windows 11 and three versions of Visual Studio, 2022, 2026 and Insider.

I have used cmake to make the SLNX file for the 2026 and Insider.  Many times in different locations. 

Screenshot 2026-03-25 211407.png

This is from the end of the day running your CLI Example that is compiled already. Note the bytes.  

I pressed esc and got 

Screenshot 2026-03-25 211331.png

Notice the zero file size, it is always recommended that you flush files as you write to the file.  

___________________________________________________________________________________

183
 

Consider writing to a file. This is an expensive operation. If in your code you write one byte at a time, then each write of a byte is going to be very costly. So a common way to improve performance is to store the data that you are writing in a temporary buffer. Only when there is a lot of data is the buffer written to the file. By postponing the writes, and writing a large block in one go, performance is improved.

---------------------------------------------------------------------------------------------------------------------------------------------

Performance as suggested by this author is not improved if nothing comes out.  

Screenshot 2026-03-25 211202.png

The DLetc files come with an interesting start date, The older files do not. 

Screenshot 2026-03-25 210724.png

This is the SLNX file. The cmake does not create a solution that finds all of the log.h and 377 other errors once I fix that error.  I have traced all of your paths etc, but having an error that INT is undefined, is challenging.  

I appreciate all of the work that has gone into this, but have you created a Windows 11 Visual Studio Solution, if so can I have it?  

If I want automode, 100 second records forever, which json file does that go in.  I have printed out the manual, read it cover to cover, played with the phone app and CLI example.  And I am really none the wiser.  

Thanks again

John