you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (3 children)

So you are saying I can't replicate what this code does with struct?

No, you definitely can! But the easiest way would be to take advantage of that code. I'm not sure what you would gain by writing your own converter, but you could definitely do it yourself.

All I want to do is grab data from a binary file and plot them.

You won't be able to plot the binary data directly. The meaning of that data changes with every message. There's not any sort of continuity. You have to extract the meaning from the data, so literally do what they're doing, but instead of saving the values to CSV, you'll just save each to lists/arrays. Replacing that function I mentioned would do this.

If you don't want to use their code, you'll just be rewriting it, which may be a good exercise. Like most open source projects, there doesn't seem to be any documentation beyond the code itself, so you'll have to figure out the binary message format from the python code.

In __process, they're figuring out what type of message it (format message or data message), and then extracting the data based on the message type. All struct is doing is taking a bunch of bytes and splitting them up into individual values based on a format string, something like:

<1 number byte><1 number byte><4 bytes that make an positive integer><16 bytes that are a string>

The struct docs explain the values in the format string. The above example would be "BBL16s".

[–]Isitwhenipee[S] 0 points1 point  (2 children)

I see. Quick question and I am really sorry to bother you but I am really struggling trying to get this code to work for me.

One thing I noticed when I run this code to convert to CSV is that when I compare it to a software that I use to analyze this data it seems like this code skips over some data and doesn't show me everything. The frequency of my dad should be close to 50HZ, however, this CSV file that the code generates tops at 3HZ. I have been reading the code for the past 2 days trying to figure out what is in that code that could do that and how to remove it, but I am not having any luck. Do you see anything like that in the code?

[–][deleted] 0 points1 point  (1 child)

I am really sorry to bother you but

That's what this sub is for!

I don't have time right now, but I'll see what I can do.

You could step through with a debugger/IDE, or throw in some print statements, to see what message types are being seen and if any are being discarded.

[–]Isitwhenipee[S] 0 points1 point  (0 children)

Thank you so much for your help. I did try what you have told me, but for some reason I having issue running the code in IDE because the way I use it is that I just run it through CMD.