I have just copied my code onto a new sd card (I'm using a Raspberry Pi 5), the code was working beautifully on my old sd card. The rust version on the old sd card is 1.86, the rust version on the new sd card is 1.87. My code is exactly the same, just copied across, and I've tried rebuilding. The problem is on this line:
let _ = spi.as_mut().expect("Result::Err").transfer(&mut readdata, &senddata);
Compiler responds with "Io(Os can't find file) ", referring to the ("Result::Err"). The Raspberry Pi Os on both SD cards is precisely the same (Bookworm) and I've done the sudo update and upgrade. Anyone know a workaround/ is it possible to downgrade the rust version on my new sd card from 1.87 to 1.86? I have 3 different programs I've copied across to the new sd card and I'm experiencing exacly the same Result::Err issue with all 3 programs.
Which crate are you using?
Hi Bjorn, Here are the crates I'm using, but I think the problem is down to the rust version, as I'm using exactly the same crates/code on both sd cards.
Crates:
use egui_plot::{AxisHints, Line, PlotBounds, PlotItem, PlotPoint, PlotPoints, Text};
//use egui_plot;
use std::thread;
use std::sync::mpsc;
use rppal::spi::{Bus, Mode, SlaveSelect, Spi};
use std::time::Duration;
use egui::{
Color32,
FontFamily::Proportional,
FontId, Ui,
TextStyle::{Body, Button, Heading, Monospace, Name, Small},
};
Hi again Bjorn, I've just changed the rust version so it's the same as the version on the old sd card (1.86 using rustup install 1.86 then rustup default 1.86) and the problem is still there! So it looks like it could be an rppal crate (which is used for SPI interface) issue, will investigate later and let you know the outcome. I'll look at what version of the rppal crate is being used, it could be that in the rebuild process, a later version than that on the old sd has downloaded.
I believe the problem is that the SPI device isn't enabled on the newer SD card. You need to use the raspi-config tool to enable it if using a fresh OS installation. It's under the "Interface Options" section. You can also verify if the SPI devices are enabled by running ls -la /dev/spidev0.*
Thank you so much! I'm kicking myself as I should have realised that! My code started working immediately I implemented your advice on that. i have to say though that the Rust compiler makes me highly frustrated - it doesn't pinpoint the cause of errors it doesn't like and after you've sorted errors it highlights, on re-compiling, it flags up a whole new set of errors! Also some crates are fiddly - as an example, egui-plot doesn't implement the Sync ans Send traits which means you can't use it with threads, and you can't implement the traits manually, so it's very limited. Best wishes and many thanks, Paul.
Hi Bjorn it turns out the problem was that I hadn't enabled the SPI interface on the Raspberry PI5! Thanks again.