Code portability

Post Reply
joe232
Posts: 10
Joined: Mon Feb 11, 2019 10:51 am
languages_spoken: english
ODROIDs: null
Has thanked: 0
Been thanked: 0
Contact:

Code portability

Unread post by joe232 » Sun Mar 24, 2019 5:34 pm

I have a question in regards to small open computers such as the Raspberry Pi , Odroid, BeagleBone etc.

Say if I connected an external device to it, for example a laser sensor, if I was writing a code up for the laser sensor using only one language, if I ported my code from lets just say from a Raspberry Pi to an Odroid, would it just straight up work and be compatible?

User avatar
mad_ady
Posts: 5837
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 71 times
Been thanked: 41 times
Contact:

Re: Code portability

Unread post by mad_ady » Sun Mar 24, 2019 7:06 pm

Depends how you communicate with your sensor. USB should work directly, GPIO needs you to adjust pin numbers based on the platform.

joe232
Posts: 10
Joined: Mon Feb 11, 2019 10:51 am
languages_spoken: english
ODROIDs: null
Has thanked: 0
Been thanked: 0
Contact:

Re: Code portability

Unread post by joe232 » Sun Mar 24, 2019 8:52 pm

@mad_ady Is that all I have to do, to ajust the GPIO pins, that is all, right? I don't have to change the code for the sensor? Even if I used a language such as C or Rust?

User avatar
mad_ady
Posts: 5837
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 71 times
Been thanked: 41 times
Contact:

Re: Code portability

Unread post by mad_ady » Sun Mar 24, 2019 9:12 pm

If you're using wiringPi, you need to make sure you're running the correct wiring pi for that platform. WiringPi abstracts access to gpio pins/interrupts so you won't need to change your app.

joe232
Posts: 10
Joined: Mon Feb 11, 2019 10:51 am
languages_spoken: english
ODROIDs: null
Has thanked: 0
Been thanked: 0
Contact:

Re: Code portability

Unread post by joe232 » Sun Mar 24, 2019 9:52 pm

Is wiringPi also available for Rust?

User avatar
mad_ady
Posts: 5837
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 71 times
Been thanked: 41 times
Contact:

Re: Code portability

Unread post by mad_ady » Sun Mar 24, 2019 10:42 pm

No, it has bindings for C and python,

joe232
Posts: 10
Joined: Mon Feb 11, 2019 10:51 am
languages_spoken: english
ODROIDs: null
Has thanked: 0
Been thanked: 0
Contact:

Re: Code portability

Unread post by joe232 » Mon Mar 25, 2019 5:39 am

What is available for Rust then?

User avatar
mad_ady
Posts: 5837
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Has thanked: 71 times
Been thanked: 41 times
Contact:

Re: Code portability

Unread post by mad_ady » Mon Mar 25, 2019 6:30 am

You can always access gpios via sysfs which is available for any programming language, but there is nothing rust specific available.

elatllat
Posts: 1267
Joined: Tue Sep 01, 2015 8:54 am
languages_spoken: english
ODROIDs: XU4, N1
Has thanked: 1 time
Been thanked: 6 times
Contact:

Re: Code portability

Unread post by elatllat » Wed Mar 27, 2019 2:28 am


Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 0 guests