-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Real-time LF sampling #2173
Real-time LF sampling #2173
Conversation
1280000 samples -> 10.24s for 125kHz 8bit sampling Allocate graph related memory on heap
Use longer timeout in WaitForRawDataTimeout() to handle CMD_WTX Fix a wrong type Apply changes to other similar part Remove unused instructions
You are welcome to add an entry to the CHANGELOG.md as well |
@henrygab @iceman1001 Could you please review this PR? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed all files EXCEPT client/src/comms.c
.
Note that I'm just a random user ... so any comments from Iceman can totally overrule my own. I only noticed a couple bugs (even if one was repeated) ... which is amazing for the size of this PR.
At a minimum, checking for and handling failed memory allocations is critical. The rest of my comments are just fit and finish.
Well done!
@@ -42,7 +42,7 @@ int GetNrzClock(const char *str, bool verbose); | |||
int GetFskClock(const char *str, bool verbose); | |||
bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge); | |||
|
|||
#define MAX_GRAPH_TRACE_LEN (40000 * 8) | |||
#define MAX_GRAPH_TRACE_LEN (40000 * 32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case others wondered:
The maximum graph trace length being hard-coded at compile time appears to be relied on by at least some code in this system.
See, for example, getFromGraphBuf()
, which presumes the buffer's size.
Is this therefore also the limit for obtaining longer traces? (i.e., does this limit long traces on clients?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this is the only limit for obtaining longer traces in the code. I got stack overflows when just increasing this number. And that's why I made commit 8b6a274 to allocate related arrays on the heap.
Check if memory allocation fails Fix memory leak Initialize struct in declaration Add/Fix some notes Remove unlikely() in favor of readability Remove a hard-coded magic number
Gentle reminder that we use calloc instead. Some external libs still uses malloc which we don't want to fiddle with. |
I replaced declarations like this Plus, all of the memory allocated by |
I found that using calloc has helped us on different platforms, so yes, that is the prefered way. |
ca771e0
to
706c2d0
Compare
Suggested by @iceman1001 Mainly for 8b6a274 Replaced the malloc() in getSamplesFromBufEx() Added memory allocation result check for getSamplesFromBufEx(), lf_read_internal(), and lf_sniff()
706c2d0
to
e82fb8b
Compare
I've replaced them |
Since I travelling, I will not be able to look at this PR until I get back. |
No problem, have a good time! |
Got time to play little with this PR today. looking good, it has some nice potential. The demodulation code I get some freezes, indicating there are some memory issues still. but I like it. scrolling in the plot window is confusing when its this large.. |
But the real-time stuffs has speed requirements. It's not always working, especially for the wireless connections.
You mean it's in |
I would say it should be automatic.. Hold on with changing demodulation functions. Otherwise this PR will be become too large. |
OK. Is there anything I need to do for improving this PR?
Sounds reasonable |
Check for memory leaks. |
Any steps to reproduce the memory leak bugs? |
do different lf / data operations? |
I got a segmentation fault when running |
9c21f12
to
45df618
Compare
alright,
|
Or... |
The lf search only uses the old one too...
|
I'm not sure what I should do now... |
One of these days, we should refactor Making sure we don't do multiple reads |
Lets merge, I have some suggestions for improvements as stated above. |
Thank you @iceman1001 and @henrygab for reviewing this PR and #2167 |
#2167 with clear commit history and some minor improvements
Known limitations:
bits_per_sample = 8
is supported now.When LF image is not loaded into the FPGA, the first 14 bytes could be the response of CMD_WTX rather than real samples.(Fixed in Fix corrupted data caused by CMD_WTX #2193)