M micro Well-Known Member Licensed User Longtime User Jan 11, 2016 #1 Hi to all How i can use this command with shell? If i send this command echo 1 > /sys/class/gpio/gpio21/value Click to expand... or echo 0 > /sys/class/gpio/gpio21/value Click to expand... with a putty session while run my b4j program on raspberry p2 this work fine, but with shell by b4j code not work. Code: Dim js As Shell js.Initialize("", "echo", Array As String(">", "1", "/sys/class/gpio/gpio21/value")) js.Run(-1) or Code: Dim js As Shell js.Initialize("", "echo 1 >", Array As String("/sys/class/gpio/gpio21/value")) js.Run(-1) How i format this command with shell? Thi commad as example work Code: Dim js As Shell js.Initialize("", "aplay", Array As String(File.DirApp & "/Audio/" & clip)) js.Run(-1) Thanks
Hi to all How i can use this command with shell? If i send this command echo 1 > /sys/class/gpio/gpio21/value Click to expand... or echo 0 > /sys/class/gpio/gpio21/value Click to expand... with a putty session while run my b4j program on raspberry p2 this work fine, but with shell by b4j code not work. Code: Dim js As Shell js.Initialize("", "echo", Array As String(">", "1", "/sys/class/gpio/gpio21/value")) js.Run(-1) or Code: Dim js As Shell js.Initialize("", "echo 1 >", Array As String("/sys/class/gpio/gpio21/value")) js.Run(-1) How i format this command with shell? Thi commad as example work Code: Dim js As Shell js.Initialize("", "aplay", Array As String(File.DirApp & "/Audio/" & clip)) js.Run(-1) Thanks
R Roycefer Well-Known Member Licensed User Longtime User Jan 11, 2016 #2 In your first code snippet, the arguments are in the wrong order in the "Array As String" part. I'm not sure this will solve your problem, but it surely isn't helping. If this doesn't fix it, you should see if jShell is running in a .jar that has the same or higher access level as your putty session. Also, is there any particular reason why you're trying to use jShell to access the GPIO rather than the jPi4J library? Surely the latter will be a lot easier. Upvote 0
In your first code snippet, the arguments are in the wrong order in the "Array As String" part. I'm not sure this will solve your problem, but it surely isn't helping. If this doesn't fix it, you should see if jShell is running in a .jar that has the same or higher access level as your putty session. Also, is there any particular reason why you're trying to use jShell to access the GPIO rather than the jPi4J library? Surely the latter will be a lot easier.
M micro Well-Known Member Licensed User Longtime User Jan 12, 2016 #3 I tried with jPi4J but does not work, maybe because my application is UI? Now i testing this only in debug mode. Upvote 0
I tried with jPi4J but does not work, maybe because my application is UI? Now i testing this only in debug mode.
Erel B4X founder Staff member Licensed User Longtime User Jan 12, 2016 #4 You should use jPi4J library. Upvote 0
rwblinn Well-Known Member Licensed User Longtime User Jan 12, 2016 #5 Hi, a simple example, using the jPi4J Library and tested on a RPi via the B4J-Bridge, to switch a pin state via app commandline argument. Although a B4J Non-UI app, it is a proper way of testing the jPi4J library and of course the RPi wiring. Code: #Region Project Attributes #CommandLineArgs: on #MergeLibraries: true #End Region Sub Process_Globals Private controller As GpioController Private Pin1 As GpioPinDigitalOutput Private PinState As Boolean = False End Sub Sub AppStart (Args() As String) Try controller.Initialize Catch Log("Controller Initialize Error:" & CRLF & LastException.Message) Return End Try If Args(0).ToLowerCase = "on" Then PinState = True Else PinState = False End If Pin1.Initialize(1, PinState) Log("Pin1 state changed to " & PinState) ExitApplication End Sub Upvote 0
Hi, a simple example, using the jPi4J Library and tested on a RPi via the B4J-Bridge, to switch a pin state via app commandline argument. Although a B4J Non-UI app, it is a proper way of testing the jPi4J library and of course the RPi wiring. Code: #Region Project Attributes #CommandLineArgs: on #MergeLibraries: true #End Region Sub Process_Globals Private controller As GpioController Private Pin1 As GpioPinDigitalOutput Private PinState As Boolean = False End Sub Sub AppStart (Args() As String) Try controller.Initialize Catch Log("Controller Initialize Error:" & CRLF & LastException.Message) Return End Try If Args(0).ToLowerCase = "on" Then PinState = True Else PinState = False End If Pin1.Initialize(1, PinState) Log("Pin1 state changed to " & PinState) ExitApplication End Sub
M micro Well-Known Member Licensed User Longtime User Jan 13, 2016 #6 Ok Tanks to all, it works both ways. It's my fault for bad assignment pin number (21 is 29). Upvote 0