How much effort will it be to learn to deploy #rust on my #arduino vs learning enough C to get by?
-
@alter_kaker @riley Break down the changes to very small ones. a) plain C code but compiled in C++ mode (this might already be a relevant change). b) the other steps. Really break them down. Then git bisect them.
-
@project1enigma
Hmm. Yeah, this already works in c-like c++ code. I'll try to make the changes smaller. Thank you. I hope it'll be worth it
@riley -
@alter_kaker @riley Small iterations is always my fave. At least where there are fast enough turnarounds. Behatzlacha!
-
@project1enigma
Yes. I made a small change but I reduced it even further. Instead of writing and reading from two byte arrays, I encapsulated them in a Buffer class. Total less than 50 lines... Still crashes right at the beginning. Would you be willing to look if anything jumps out at you? This is my very first C++ class... -
@alter_kaker @riley Where do buf_a/buf_b point to?
-
@project1enigma
haha I just fixed it, they were not pointing to anywhere... Updated to initialize in the header file as arrays. @riley -
@alter_kaker @riley That's probably what you need, arrays.
-
@project1enigma
It works now, so clearly you're right . I got confused by how arrays get initialized. Does this impact ctor considerations?
@riley -
@alter_kaker @riley Unless you depend on certain initial values of the buffer, you could still omit the ctor (use the compiler defined default).
-
@alter_kaker @riley That would leave the buffers uninitialized. But the storage is allocated. That's okay as long as the first access of each cell in the arrays is a write (e.g. by File::read)
-
@alter_kaker @riley If you'd want to make sure zero initialization... As long as the only Buffer is a global variable, usually it'll be zero initialized anyway.
-
@alter_kaker @riley For local variables you have a few ways. Add {} to the field declaration ('u_int8_t foo[SIZE] {};'). Then for every ctor the compiler will zero init foo unless the specific ctor has a different member initializer.
-
@alter_kaker @riley Or write a ctor that zero initializes. Or don't declare a ctor but when declaring an instance of Buffer, add those {} 'Buffer foo{};'
-
@alter_kaker @riley Yes it's complicated
-
@alter_kaker @riley I've been into that mess posing as a programming language for so many years
-
@alter_kaker @riley Oh random thing. That #define thing. You need them much less with modern c++. "constexpr std::size_t BUFSIZE = 512;". Observes variable scoping instead of being mechanically replaced everywhere. Can still be used as array bounds.
-
@project1enigma
I have no idea what compiler this is using.
@riley -
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker Do you have something like a logic probe or another Arduino to see whether the traffic between the Arduino and the SD card makes sense?
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker I seem to have missed it, and the webpage expired.
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker
constexpr
has been around for quite a while. Unless you're specifically doing retrocomputing, your compiler has a fairly high likelihood of supporting it. You can give it a try, and if the compiler balks, work around it.