NOP0 / rustmatic

PLC programming in Rust!
Apache License 2.0
35 stars 2 forks source link

Gpio example #41

Closed NOP0 closed 3 years ago

NOP0 commented 4 years ago

FWIW we're able to read a GPIO on a Raspberry PI 2B in real life. Writing is not done/tested yet, I have to get some more hardware. This is a branch of #29 , I'm not sure if you prefer to merge that first?

Michael-F-Bryan commented 4 years ago

This is a branch of #29, I'm not sure if you prefer to merge that first?

I just did a rebase and merge of #29 so this branch should be able to make progress. Do you think it's worth testing on real hardware before merging? Or could we hit merge without it?

NOP0 commented 4 years ago

Do you think it's worth testing on real hardware before merging? Or could we hit merge without it?

Started working on gpio output, but just realized that outputs are not implemented in ProcessImage Ooops :laughing:

I'll need to implement that first.

NOP0 commented 4 years ago

@Michael-F-Bryan Ok, did some more on this...The gpio-example now logs TRUE∕FALSE when I put voltage on the input pin, and I can measure a toggling voltage on the output pin. Do you have access to a Raspberry PI, should we double-check this?

NOP0 commented 4 years ago

I've read a bit on how the embedded guys do this stuff; https://rust-embedded.github.io/book/static-guarantees/design-contracts.html

Their approach might be better, thinking of redoing this like in the link. Thoughts?

I have looked a bit at the embedded-hal traits also, and for gpio I believe we can be "conformant" without any hassle. I'm on my phone, so no code to show for though.

NOP0 commented 4 years ago

@Michael-F-Bryan Rewrote process image to use proper types instead of "DoubleWord" and so on.

What do you think of c0f1bdc ? Is it ok to match on adress, or should this be more generic, so that any type which implements PiAccess could update the process image? I'm not sure how I would do that though :smile: