How much effort will it be to learn to deploy #rust on my #arduino vs learning enough C to get by?
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker Happy hacking!
-
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
Status update: I'm back to C++ because I was having issues with the Rust SPI and SD Card libraries...I've been avoiding learning C++ since about 2000CE...
-
Riley S. Faelanreplied to Yeshaya Lazarevich last edited by
@alter_kaker I have done some work with C++. If you have any questions, I might be able to answer or suggest useful googlewords.
Also, what kind of issues were these? Perhaps these could be fixed, as well.
-
Yeshaya Lazarevichreplied to Yeshaya Lazarevich last edited by
@riley
Right now I'm running into very irritating problems. I got my program to work in procedural code, and I tried to convert a small part to OO. Now it's compiling, but always crashes or hangs, each time at a different point in the program. I don't really know how to debug something like this. -
Yeshaya Lazarevichreplied to Riley S. Faelan last edited by
@riley
It was failing to read the SD card despite the fact that the hardware was correctly connected, and the configuration was the same as what I used in the regular Arduino.I could raise some tickets and I still might, but it's kind of a hassle.
-
Yeshaya Lazarevichreplied to Yeshaya Lazarevich last edited by
@riley
@project1enigma it never ends -
@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{};'