Thanks for all the great advice folks!
Currently, I can control GPIO remotely on multiple devices with just a simple single shell command:
myShell.WriteLine "PIGPIO_ADDR=192.168.2.16 python ~/scripts/led.py"
This is surprisingly simple and requires only the installation of the pigpio daemon on the receiving RasPi(s) - also a very easy thing to do. It has the added benefit of being able to maintain the functional scripts on the central controlling computer (in my case, my Mac laptop). I was just hoping to be able to bypass the Python aspect and incorporate the gpiozero functions in Xojo directly.
I installed the Demo version of Einhugur’s Python Script plug-in and it seems like a viable way to go, but the code necessary to drive it rapidly become a negative return:
This is just a simple snippet to multiply two numbers! Sure, I realize it’s all necessary for what it’s doing. You have to setup the parameters of the function, pass the values, handle the results, and deal with errors, but my current solution is basically “Hey, Raspi at 192.168.2.16, do this: led.py”. I just have to learn Python, which ironically, I would have to do FAR more if I used Einhugur’s plug-in.
[code]Dim package as PythonModule
Dim func as PythonFunction
Dim params as PythonParameters
Dim result as PythonResult
Dim f as FolderItem
PythonScript.SetConsoleOutput(new ConsoleHandler(TextArea1))
#if TargetMacOS
f = App.ExecutableFile.Parent.Parent.Parent.Parent.Child(“PythonModules”)
#elseif TargetWin32 or TargetLinux
f = App.ExecutableFile.Parent.Child(“PythonModules”)
#endif
// Add search path where Python can find our module
PythonScript.AddSearchPath(f)
// We try to load the Python module
package = PythonScript.GetModule(“SomeSimpleTest”)
if package <> nil then
// We add a property called x to the module and set its value to 29
package.IntegerField(“x”) = 29
// See if we can find function called multiply in the module
func = package.GetFunction(“multiply”)
if func <> nil then
// Build some parameters to pass to the function
params = new PythonParameters(2)
params.IntegerValue(0) = 5
params.IntegerValue(1) =3
// run the function
result = func.Invoke(params)
if result <> nil then
MsgBox Str(result.IntegerValue)
else
if PythonScript.ErrorOccurred then
MsgBox PythonScript.GetError()
PythonScript.ClearError()
end if
end if
end if
else
MsgBox “Could not load module”
end if [/code]
@James Dooley : I’m hoping you’re right about being able to communicate directly with the client. That sounds promising. I just hope it’s not over my head. I’ll look into it further. You might be hearing from me again. :@)
@William Reynolds , @Tim Seyfarth , @Pedro Ivan Tellez Corella : While I know you’re right about using client-server scripts and TCPSocket, etc., with my limited experience, it seems that may be reinventing the wheel in this case, since gpiozero and pigpio have already been written, though I could be wrong.
@Wes Westhaver : Thanks for reminding me of WebIOPi. I’ll look into it again. Sadly, a while back, I looked into both WebIOPi and Cayenne but when I ran into some confusion and tried to contact them for help, I was completely ignored. That left a bad taste in my mouth. I chalked it up to them being new and still getting their feet settled and decided to revisit them later. Perhaps now’s the time.