I'm writing a program, in C++ with the Eclipse IDE, that's going to eventually need to run when the Intel Edison turns on, and I've been trying to figure out how to set that up now. I've been looking through questions, and I see that I need to create a service that executes my program, and make sure that it's located in /lib/systemd/system. I don't know how to actually make the service file though. I also see a lot of questions talking about Node.js, but nothing that involves c++.
That's what I think the service file is suppose to look like, but I'm not even sure about that. Myprogram is the file that get's created when I run the program in Eclipse. How do I make this service file and put it in the appropriate directory? I tried using the PuTTy terminal and the vi command, but didn't know what to do after running that command.
Which image are you using on your board? Could you run the command uname –a on the Terminal Console and let us know the outcome? I would like to replicate your environment to test this.
Also, are you transferring the code through a SD card? Why don't you use the executable that the board loads from the Eclipse?
Are you able to run the executable on the board?
I'm using the Linux Edison 3.10.17-poky-edison image. No it's all running from eclipse, but I changed the absolute path in eclipse to that location instead of the tmp folder. I was setting it up so that I could have a script that started running the program from that location. I'm not 100% about your last question. I know it runs when I press run on eclipse but I don't know how to run it just from the board.
I was able to create a service with a C++ code from Eclipse.
I am using the 3.5 release, you can check this by running the command uname –a on the Terminal Console, the latest image should has as output:
Linux jarvis35 3.10.98-poky-edison+ # 1 SMP PREEMPT Mon Jun 6 14:32:08 PDT 2016 i686 GNU/Linux, and the Eclipse Luna SR2 (4.4.2) version.
I used the C/C++ Project > On board LED blink C++ example and used the name code as Project Name
As you know, once you connect the board and run the script, you can see the executable in /tmp. In my case I saw the file code in /tmp. What I did was to cp the file in /home/root
Then, I created a service named code.service in /lib/systemd/system with the following content:
After this, you need to run the commands:
systemctl daemon-reload systemctl start code.service systemctl enable code.service reboot
Try with this steps and let me know the outcome, I hope it works for you too.