Rust on Particle: development discussion

That's perfect, just making sure were aware, didn't want you to be left out :smile:

I guess I should say, of those who have spoken up, that seems to be the consensus. Don't mean to speak for those have not.

It is still very nascent, it seems like most of the effort is in getting Cargo to work. But there is quite a lot to do and probably even more to discuss in order to work out the details. I'd say pick one of those issues that interests you and start looking into it, ask questions and start dialogue.

Personally, I've found This Week in Rust to be a good resource for getting up to speed on the state of rust as well as some projects that people are working on that can help you learn rust. Also, I've been watching this series on Youtube about building an N64 emulator in Rust, that's been really fun and super informative.

1 Like

Nice! Iā€™ll definitely check those out. Cargo is definitely one of my favourite aspects of the language and supporting frameworks, so Iā€™ll likely start there as well.

As for information, http://www.newrustacean.com has been pretty awesome for getting a conceptual overview of the language; Itā€™s just a bunch of podcasts by a guy (Chris Krycho) whoā€™s making them as he learns the language.

I think my biggest sticking point right now, is how to make effective use of Traitsā€¦ still havenā€™t had my eureka-moment with those.

1 Like

Yeah, I know what you mean lol

1 Like

Rust 1.7: http://blog.rust-lang.org/2016/03/02/Rust-1.7.html

Cool idea here! I've been itching to get into rust, but haven't found a good project yet. So please take my contribution here with a grain of salt-of-inexperience

Edit: I see the same principle was already suggested on the github issue:

Regarding Zach's ideas:

From my rust-research so far, the idiomatic way to do this seems to be to use lifetimes and ownership.
The entire "pinmode" hassle is conceptually orthogonal because it's global mutable state.

The rust-way as I understand it so far would have a "guard object" claim ownership of and wrap around the contended resource. My inspiration here is a variable wrapped by a Mutex lock.
The variable inside is only reachable via mutex.acquire(), and as long as that borrow'd result is in scope, other acquires are impossible.

We'd need marker Traits (similar to Send, Sized, Sync, etc) for DigitalInputPin, DigitalOutputPin, AnalogInputPin, PwmPin, etc.

Suggestion in pseudo code typed on a phone keyboard(sorry in advance for any typo's):

board.rs:

struct D7 {};
struct A0 {};

impl DigitalInputPin for D7;
Impl DigitalOutputPin for D7;
Impl AnalogOutputPin for A0;

MyProgram.rs

{
let outputPin = IO::digitalOut(board::D7);  // claims ownership of D7 marker struct, preventing repeated init
outputPin.setHigh(); // statically guaranteed to work, because setHigh method is only available on correct guard object
outputPin.setLow();

// compile error: D7 no longer owned here:
let failedAttempt = IO::digitalIn(D7);
// compile error: D7 doesn't impl AnalogInputPin
let anotherFailedAttempt = IO::analogOutputPulldown(D7);
} // output pin leaves scope, implicit release of D7
{
let secondTry = IO::digitalIn(board::D7);
let pinValue : bool = secondTry.read(); // maybe "pinvalue : IO:pinOutput" enumtype?
}

By only impl'ing the modes a given pin supports, you statically prevent setting a pin to the wrong pinmode, anything else would trigger type-errors on the function call to init the guard.

1 Like

Any news on the Rust front?

1 Like

The latest and greatest can be found here: https://github.com/japaric/photon

2 Likes

(Sorry to resurrect this old topic. It does seem like the best place to ask, however.)

Is Rust still a thing that Particle is supporting or plans to support? I want to learn Rust, and I need a project; my current efforts on Particle stuff at work is a great opportunity for this, and I donā€™t know if itā€™s still an option or not. The mainline firmware seems to keep maturing, and I donā€™t see anything on the Rust branch. Even the repo that @zach linked in above hasnā€™t been updated in 10 months.

Thanks.

Again, sorry for the resurrection.

I always planned to start working on this, but canā€™t find time for it :frowning2:

1 Like

reality comes for us all.

Same; I am not a proficient enough Rust engineer to be able to work on it meaningfully myself, but my hope is to be the sponsor of such a project. My attention has been drawn elsewhere for the last couple of months but I do plan to hop back on this at some point in the next couple of months.

5 Likes

The latest and greatest can be found here: GitHub - japaric-archived/photon: Binary blobs for building photon apps

I have restarted development of that repository but the getting started guide is now here. I made a new thread with more details about my recent work; check it out.

3 Likes

Any updates on Rust for Particle devices? The repo at github.com/japaric/photon is unmaintained ā€¦ so I guess thats not encouraging.

Rust is picking up steam in the embedded world. Hope to see it arrive on the coolest hardware around:) If some one with more Rust skills than me wants to spearhead the project I would be glad to assist.

@japaric Are you still interested in working on this? I am interested in resurrecting the project.

2022 Nowā€¦ any thoughts of getting back on this? I have embedded experience and particle.io experience. New to rust; however, if Adafruit can put python on an embedded device, we should be able to put rust on a particleā€¦

As far as I know there are no current plans for Rust on Particle but I would not rule it out in the future.