Run a Code in Omega remotely
-
Hello everyone,
I followed this tutorial (https://docs.onion.io/omega2-docs/cross-compiling.html) to make the cross compilation for omega Also, I followed transferring the files such as in example ( https://docs.onion.io/omega2-docs/transferring-files.html#transferring-files) and they worked. Thank you!But I have a question regarding after transferring the code and running it;
I have created a bash file (.sh) to install toolchain and compile a hello world example and transfer the files to make everything automatic.
What I need to do is, I want to run this hello world example directly in Omega without connecting from my device with SSH.Is there any way for me to do that?
Thank you and Kind Regards
-
@cagatay-Baser said in Run a Code in Omega remotely:
What I need to do is, I want to run this hello world example directly in Omega without connecting from my device with SSH.
Well if you want the Omega2 to execute your newly uploaded binary, you have to connect to it somehow to tell it that.
Or use cron job for automatic execution.
I guess what you want is to automate launching the binary? You can actually do that via SSH pretty well.
For example, with the
sshpass
tool, you can pass username & password (if you haven't set up pubkey authentication) and execute a command, like e.g.sshpass -p 'onioneer' ssh root@my-omega-ip "./myProgram"
-
İyi günler Çağatay,
With ssh: other than @Maximilian-Gerhardt's share, you can use paswordless ssh key pair.
http://community.onion.io/topic/2903/how-to-generate-a-pair-of-keys-on-omega-2/2
in this link you can create a pair of paswordless key and just typessh root@my-omega-ip "./myProgram"
from your computer.
without ssh:
-
You can use usbttl adapter on rx0, tx0 and geather the console of omega2 for whatever you want to do.
-
You can use
crontab -e
and use cron for an application. -
You can use
rc.local
orinit.d
that triger an application or script on boot time.
https://docs.onion.io/omega2-docs/running-a-command-on-boot.html- triggered application should in a loop, for example;
while read -r line < /dev/ttyS1; do echo -e "$line" done
this script wait a connection to gpio46,45 -> rx1, tx1 on Omega2 and runs forever.
#!/bin/sh /etc/rc.common # Copyright (C) 2017 Onion Corporation START=80 USE_PROCD=1 # PROCD_DEBUG=1 BIN="sh /root/bin/myProgram.sh" start_service() { # for i in /tmp/mounts/*; umount $i; done /root/bin/fsck_record_disk.sh procd_open_instance procd_set_param command $BIN procd_set_param respawn procd_set_param stdout 1 procd_set_param stderr 1 procd_set_param pidfile /var/run/service.pid procd_close_instance }
this init.d script start on boot time and respawn whenever it's crash.
- You can use any gpio pin for a push button and after the button pushed an application can be triggered.
Thats all on my mind.
Kolay gelsin.
P.S : If your program have
while
loop or something similar you should end your command with "&"ssh root@my-omega-ip "./myProgram &"
without "&" your ssh connection will be stuck until kill the myProgram from Omega2's side.
-