Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am trying to build a robot. I have written a C++ code that recognizes user's voice commands and does some actions (showing an image/video, or saying an answer to that command). So, I used Ubuntu-server 16.04, with openbox window manager to do this, and my program runs on it successfully.

But my question is: How can I do it automatically? I mean, at now, I must going to terminal after booting my board(I use an ARM-based board), then go where my program is "cd /home/m/ " then execute it by "./my-program". But I liked this happened automatically! I mean my program become running automatically after boot.

Also I like when user turns on my robot, it shows my Logo, then shows a default image from my C++ code, then recognizes the user voice and does a related action to it and this will repeat like a loop again(default image, user's command recognition, does action, default image, user's command recognition,does action, and again...).

I chose Linux-server because I didn't like to have desktop or any other common applications. I only like my OS runs my program at startup and user has no any ability to interact with the robot, else the voice commands!

I don't know how can I configure my Linux to doing this?

What I have tried:

I searched for it and found that it called Kiosk Linux. But every tutorials are talking about web browser kiosks. and I think many of them are out dated(didn't work for me). I do not like my Linux runs firefox at startup, I like it runs my C++ code!

Also I am newbie in Linux and don't know much about it and need a straightforward tutorial!
Posted
Updated 3-Nov-17 4:40am

 
Share this answer
 
Comments
Member 13376650 3-Nov-17 14:01pm    
So I should use which one? Systemd, Shels, Graphical?
The simplest method is adding the command(s) to /etc/rc.local (file/location depends on the distribution but Ubuntu uses that; create it if it does not exist). Then you probably want to run your program in background mode using the shell's & operator (space separated at the end of the line):
/path_to_app [options] &

If the application uses X11, you can tell X11 to start your application. See for example Xsession - Debian Wiki[^] and CustomXSession - Ubuntu Wiki[^] . Again use the shell's & operator.

If the application does not use X11 (e.g. when it writes directly to the frame buffer), it can be also started as service using a run level script. This is the common method for window less systems in kiosk mode but requires writing a run-level script and confuring that (depends on the method used by the Linux distribution).

These are the methods that come to my mind but there are more.


Showing an image when idle should be handled by the application. It may also show your logo when started.

If you want to show your logo when the system is powered up, you have to change the boot splash image. That depends on the used system and distribution and is an advanced task because it must be done as early as possible in the boot process and requires the SPI display to be ready.

Alternatively you can check if you can use Plymouth - Ubuntu Wiki[^] (it might be tricky because you must have your SPI display already up and running).

Quote:
Also I am newbie in Linux and don't know much about it and need a straightforward tutorial!
We all started once with no or little knowledge. But you usually have to understand what you are doing instead of just coyping from a tutorial and should at least know the very basics about the shell and (for your project) the boot and startup process. This applies especially to your system which is not a standard desktop, server, or often used (like the Raspberry Pi) so that many sources (like tutorials) can't be used without modification.
 
Share this answer
 
Comments
Member 13376650 3-Nov-17 14:41pm    
I have a C code that has an executable named "img" and is a gtk3 code shows an image. I added this line to my "etc/rc.local" : "/home/m/img &" but it didn't work after boot!
Jochen Arndt 5-Nov-17 3:52am    
Does your app require X11 and is that started?
Member 13376650 5-Nov-17 6:23am    
Yes, my app shows an image by GTK library, also I have added "startx" in my rc.local before.
Member 13376650 9-Nov-17 14:24pm    
I tried the Ubuntu custum Xsession till step 8 with with this ~/.xinitrc file:

#!/usr/bin/env bash
/home/m/img &
exec openbox-session


But my LCD didn't work after reboot!
Jochen Arndt 10-Nov-17 2:49am    
You have to load the LCD driver module.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900