Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Topic: Run Rust on Raspberry Pi #37

Open
EloiStree opened this issue Dec 4, 2024 · 5 comments
Open

Topic: Run Rust on Raspberry Pi #37

EloiStree opened this issue Dec 4, 2024 · 5 comments

Comments

@EloiStree
Copy link
Owner

EloiStree commented Dec 4, 2024

I love Rust but don’t have time for it.

On the other hand, I need to create code that turns a Raspberry Pi into a mini-server and input hub.

So, the question that comes to mind is:
How hard is it to run Rust on a Raspberry Pi, and does it make sense?

This could make sense in the context of https://raspberry-hosting.com/en.

Some useful resources:

image
https://youtu.be/MMzCfzCUNyo

@EloiStree
Copy link
Owner Author

EloiStree commented Dec 5, 2024

sudo apt-get install git -y
sudo apt install python3 -y
sudo apt install python3-pip -y

cd ~/Desktop
nano HelloWorld.py
print("Hello, World!")
python3 HelloWorld.py

@EloiStree
Copy link
Owner Author

image

@EloiStree
Copy link
Owner Author

import socket
import netifaces

def get_ip_addresses():
    ip_addresses = []
    for interface in netifaces.interfaces():
        addresses = netifaces.ifaddresses(interface)
        if netifaces.AF_INET in addresses:
            for address in addresses[netifaces.AF_INET]:
                ip_addresses.append(address['addr'])
    return ip_addresses

def listen_udp(port):
    sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    sock.bind(('', port))
    print(f"Listening for UDP messages on port {port}...")
    while True:
        data, addr = sock.recvfrom(1024)
        print(f"Received message from {addr}: {data.decode()}")

if __name__ == "__main__":
    print("IP addresses of the computer:")
    for ip in get_ip_addresses():
        print(ip)
    
    listen_udp(7000)

@EloiStree
Copy link
Owner Author

EloiStree commented Dec 5, 2024

For Rust

sudo apt install python3-pip

sudo apt update && sudo apt upgrade -y
curl https://sh.rustup.rs -sSf | sh
rustup install nightly-2020-10-14-aarch64-unknown-linux-gnu
source "$HOME/.cargo/env"
rustc -V



``

https://phoenixnap.com/kb/install-rust-ubuntu

https://users.rust-lang.org/t/error-installing-nightly-aarch64-unknown-linux-gnu-toolchain-how-to-install-older-version-of-nightly-aarch64-unknown-linux-gnu/51888/4
rustup toolchain install nightly-aarch64-unknown-linux-gnu
rustup default stable
cargo build --release --target=aarch64-unknown-linux-gnu

@EloiStree
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant