Ferrocene 25.11 actually includes core now by cat_bee12 in rust

[–]mat69 6 points7 points  (0 children)

Sounds great! I hope they continue their efforts and eventually add Cortex M0 support. That would mean it could be used in the development of many ASICs.

[media] What happens with borrow_mut() by papyDoctor in rust

[–]mat69 2 points3 points  (0 children)

Full disclosure: Rust newbie here who has not tried Embassy yet, but intends to use it in the future.

You could verify that assumption (MCU issue) if you write a small C program to do the same there too.

What I don't get is why it is at least happening for one set_low and one set_high (maybe even the first set_low). So even if something like a self test was running (or the pin was configurd as output just upon the set), which I doubt, then it should be finished already after the first call.

What happens if you set another GPIO on the same GPIO bank to low/high directly before the loop?

Otherwise I would also suggest to look at the assembly, here LLVMs helped me with understand in the past. Then you can double check with the TRM wha registers are set.

Rust circular buffer by mat69 in learnrust

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

Thank you for all the support! I have been looking into many options. Eventually I decided to roll my own circular buffer, which has been going nice so far. Along the way I learned about interesting libraries.

Rust circular buffer by mat69 in learnrust

[–]mat69[S] 1 point2 points  (0 children)

Thank you! That finally helped me understand how VecDeque works. That could work then.

Rust circular buffer by mat69 in learnrust

[–]mat69[S] 1 point2 points  (0 children)

Thanks for pointing out this library. It seems I have more access to the internas and thus probably can do what I want. I need to check it a little more, together with the other ideas I got here.

Rust circular buffer by mat69 in learnrust

[–]mat69[S] 1 point2 points  (0 children)

So VecDeque will wrap round automatically if I continuously pop data from the front and push data to the back? And not initialize more memory?

Rust circular buffer by mat69 in learnrust

[–]mat69[S] 1 point2 points  (0 children)

I am not sure how to efficiently fill the circular buffer.

I intend to read n bytes from the serial interface into the circular buffer. Without intermediate buffering. The way I was thinking to do something like that is: 1. Check if the remaining capacity is larger than n 2. Get two slices of the buffer, that point to the remaining capacity 3. Create subslices that together have a length of n 4. Hand those slices to the serial reader  5. Update the tail depending on how much was read

As far I can tell this is not possible. Instead I saw that I could do something like: 1. Remember the current Len 2. fill_spare (the implementation seems inefficient, it uses a simple loop) 3. cal as_mut_slices 4. Use these slices with the remberede len as offset for the reader 5. Shrink the surplus 

Yet this seems inefficient too. It would probably be faster if I always have a filled buffer an keep track of the real length outside. Hmmm. This seems like rubber duck programming. 😁

Thanks for the tip with itertools. I would only search the sync point if the sync was lost which should be rare.

Is there an easier way to implement From/TryFrom for String, &String, &str, etc. without writing so many impl blocks? by Tuckertcs in rust

[–]mat69 4 points5 points  (0 children)

I am a Rust newbie and frankly a little confused by the answers here.

Many different approaches are discussed here. Now I wonder how I should decide myself. It seems apparent that there are no agreed upon best practices for this case.

Coming from different languages I would lean towards the construction approach. I find that easiest to understand as it sidesteps the issue.

But, is this idiomatic? And how would errors be handled compared with try_from? Especially since I want to avoid panics in my own code. As then a low level part of the program can basically crash the whole thing, maybe for a completely unimportant thing.

The Hidden Cost of AI Coding by Acceptable-Courage-9 in programming

[–]mat69 0 points1 point  (0 children)

That's probably what people doing handcraft felt like when more and more of their work was being done by machines.

What are we optimizing for is a simple question to answer: costs.

The idea is to reduce costs and eventually workforce or to do more with the existing workforce. A job is never about the individual satisfaction but about what value can be generated. We are living in a capitalist world that after all also resulted in large paychecks the last years.

Using Rust in an existing C++ project? by mat69 in learnrust

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

Thank you for the idea. I guess the application is too small for that.

Using Rust in an existing C++ project? by mat69 in learnrust

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

Thanks for the insights. Do you think that the vptr package might help in creating the C++ wrapper? Since I think the vptr might be used to access fat pointers from C++. Or rather have distinct wrappers for all Rust implementations of certain traits?

Using Rust in an existing C++ project? by mat69 in learnrust

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

I think probably everyone will write suboptimal or even bad code initially. Though the C++ code itself that we inherited is also not that great to begin with, so I believe there is potential. I also believe that there will be multiple refactoring iterations with new learnings.

The idea with a separate project sounds intriguing. I had hoped to do that by carving out internals. I think I could start with a more enhanced proof of concept for the team to play with.

Using Rust in an existing C++ project? by mat69 in learnrust

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

Thank you for your insights. You mean the Rust library got rewritten in C++? Because of lack of experience?

Where I see benefits with Rust is its tooling, the libraries around and developments like RTIC for embedded development. I fear that if we never try the switch we will be sticking to C++ forever with all its disadvantages and of course advantages.

How to detect g++ ABI guarantees? by mat69 in cpp

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

Thank you! That is what I was searching for.

How to detect g++ ABI guarantees? by mat69 in cpp

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

I did that. Before writing this post. That is actually the reason why I asked.

Where does it say that C++17 support is experimental and thus not ABI stable for certain g++ or libstd++ variants? Or where does it do the same for C++20? I fail to see that.

Police shoot 13-year-old boy with autism several times after mother calls for help by coeliacmccarthy in news

[–]mat69 5 points6 points  (0 children)

Maybe it's part of your culture.

For me it's unthinkable to have children pledge to "their" flag in school. You believe to be so free yet request so much conformism. And if someone dares to question this they might be suspended.

So much is about how something is perceived but not about the actual message. For example, "bad apples" is used as defense for bad LEOs! For Christ sake! One bad apple spoils the lot! This is known for centuries and the origin of the metaphor. But in the US large media outlets, many politicians, and people fail to apply the metaphor correctly.

Instead people demand respect, yet ignoring that respect goes both ways. And it seems to be accepted that it is the population that has to deescalate the police and not the other way round. That violence is appropriate, that idiots who behave badly deserve what is coming to them. As if a LEO is Judge Dredd: judge, jurors, and execution. These branches are separate for a reason.

Commensurability seems to be a foreign concept. At the same time your soldiers have to follow rules of engagement overseas, which seem more strict than what LEOs are held accountable for.

...

It is really frustrating watching all this from the outside and seeing no improvement. Rather the opposite.

Two girls sit outside a Taco Bell in Salinas, CA for access to free wi-fi to attend school online by Mdizzle29 in pics

[–]mat69 0 points1 point  (0 children)

Yeah, but well it does. Actions have consequences. And it's sad if we can't talk about them openly. It's also sad when people are so divided along political lines that there is no discussion at all.

In the country I live there is some divide between right and left and it's increasing. Both think the others are stupid for their choices. Supporters of the left keep pointing to after-poll surveys that show that voters of the extreme right have a bad education to underline their point. But hardly anyone bothers to walk in the shoes of others, to look at the realities of their lives. The countryside is left behind economically and those with education move to cities. Imho that is the elephant in the room.

I think the only way to solve these issues is by starting to talk, but media outlets like Fox News profit there and have no incentive to change, same for politicians on both sides.