B4J Question How to check if Rasberry Pi GPIO Controller is present?

corwin42

Expert
Licensed User
Longtime User
Hi,

I am currently working on a project which should finally run on a raspberry pi and it uses the jPi4J library (GPIO).

For testing I want to run the application on a normal windows pc. How can I check, if the app is running on the pi so I can run the GPIO code only if running on the pi?

Catching the exception when initializing the gpio-controller does not work:

B4X:
Sub Process_Globals
    Private mController As GpioController
    Private IsGpioControllerInitialized As Boolean = False
End Sub

Private Sub InitializeGpioController
    If Not(IsGpioControllerInitialized) Then
        Try
            mController.Initialize
            IsGpioControllerInitialized = True
        Catch
            Log(LastException)
            Log("GPIO Controller not initialized")
        End Try
    End If
End Sub

I get the following error:
 

corwin42

Expert
Licensed User
Longtime User
Thanks for your answer.

Conditional compilation is what I use now.

Getting the operation system was another solution I have thought about.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…