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

Exception if non root user uses the library #428

Merged
merged 3 commits into from
May 17, 2018
Merged

Conversation

akatran
Copy link
Contributor

@akatran akatran commented Apr 20, 2018

The library will throw and error if user has not effective root access.

The error could be handled from above layers like another library or main program!

@akatran
Copy link
Contributor Author

akatran commented Apr 20, 2018

In my case I use the following code to handle the exception. My environment is a Raspberry Pi.

try {
    gw.begin(nodeID, 0x4c, RF24_1MBPS);
  }
  catch (int e){
    fprintf(stderr, "Root access required!\n") ;
    exit(e);
  }

The library is compatible with Arduino.
Actually the function geteuid() will not be included by the linker.
I have tested with Arduino Nano.

@akatran
Copy link
Contributor Author

akatran commented Apr 20, 2018

This is the second attempt to address #424.

@TMRh20
Copy link
Member

TMRh20 commented Apr 21, 2018 via email

@akatran
Copy link
Contributor Author

akatran commented Apr 21, 2018

I thought not to put this in bcm driver in order to be easy updating the driver.

If you make changes to the bcm library before you put it into the repo then it is fine to add one more but if not then you will have to apply this everytime!

If the late is not a problem then I will apply it into the bcm driver.

May I propose to put it into the spi.cpp? That way you can easily update the bcm driver and will be used only for Raspberry Pi.

@TMRh20
Copy link
Member

TMRh20 commented Apr 21, 2018 via email

@akatran
Copy link
Contributor Author

akatran commented Apr 21, 2018

Per @TMRh20 comment I'll move the exception into SPI.cpp!

@akatran
Copy link
Contributor Author

akatran commented Apr 21, 2018

OK, it is ready!

@Avamander Avamander requested a review from TMRh20 May 15, 2018 10:05
@Avamander Avamander merged commit 76e2a7b into nRF24:master May 17, 2018
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

Successfully merging this pull request may close these issues.

3 participants