Author Topic: Start custom made DCE (cpp) device at boot.  (Read 4050 times)

mihajzm

  • Regular Poster
  • **
  • Posts: 43
    • View Profile
Start custom made DCE (cpp) device at boot.
« on: April 02, 2009, 09:07:28 pm »
Hi,
after some instruction http://forum.linuxmce.org/index.php?topic=7706.0 I finally successfully compiled bunch of my custom made DCE devices. I can start them from command line and all is working, I can see data from my sensors (mostly AVR microcontrollers with PHY or AVR+RS485) on orbiter, switch relays etc. Now I copied the binaries to /usr/pluto/bin and hopped that after reboot they are executed with some sort of startup script. But nothing happens  :'(
What must I setup or hack that these devices are automatically started at boot?

What I have also done:
created New Software package (Advanced->Software->Packages->Create new package) for each device pointing to binary in /usr/pluto/bin
In Device Templates , added each package to right template.

thanks in advance.


colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #1 on: April 02, 2009, 11:05:41 pm »
Well if you have created a binary that acts as a DCE device, packaged it, and defined a Device Template that uses that package to install the device, then you have done everything except actually add the device! In other words, you are prepared the system to make your DCE devices available, should someone want to use them - ie the Device Template is there - but you haven't actually told LMCE to create an actual Device instance from the Device Template.


There are 2 ways you can do this - automatically using pnp, or manually through the admin site in the devices tree. Ideally, set up the pnp system - you can see the pnp stuff towards the bottom of the Device Template. You need to pick something that you can use to identify the device with. So for Ethernet you can choose the MAC address range that the manufacturer has been allocated, USB you can use the product/vendor ID, etc... The rest of the template definition will define where the device gets created and the package to install when it does. pnp

Otherwise, you can just go to the correct parent object in the Devices Tree, and use the Create Device (I think) link. Then choose your template. This will create the device. You will then need to reload the router. At this point, assuming that the device works and the template indicates that it implements DCE, the system will launch the device on each reload.

mihajzm

  • Regular Poster
  • **
  • Posts: 43
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #2 on: April 03, 2009, 07:05:09 pm »
What do you mean with "packaged it"? Do I need to do full reboot, or quick reload router?

As I have written, I have created a device from my template (it get number 85). Then when I run my dce device in shell  as "my_program -d 85", it's working. I can see temperature from my sensor in FloorPlan on Orbiter.

But either after reboot or quick reload, it's not started.

I think I should see something like this in Running Processes
Code: [Select]
/bin/bash /usr/pluto/bin/Spawn_Device.sh 85 localhost my_program

I am missing something?



colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #3 on: April 03, 2009, 10:28:37 pm »
Don't start the device manually. After a reboot, in the device properties, does it say Registered: Yes or Registered: No? Also, is the Disabled tick box ticked? And in the Device Template is the Implements DCE tick box ticked?

mihajzm

  • Regular Poster
  • **
  • Posts: 43
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #4 on: April 04, 2009, 12:11:31 am »
the Template for my Temperature sensor is as follows:
Implements DCE is checked.
Device Category Environment - Climate Device
This device is controlled via Device:Climate Plug-in  Category: Climate Plug-ins
Package points to package that I have created (I have looked on other packages how to configure it)

in Device:
Status :
Disabled is not checked
Registered: NO

after reboot no change to Registered.

where to search for startup log?

colinjones

  • Alumni
  • LinuxMCE God
  • *
  • Posts: 3003
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #5 on: April 04, 2009, 01:22:17 am »
OK, well either LMCE is attempting to start the device and failing, or it is not even attempting to start the device. If the latter, then I'm not sure what other requirements there are for LMCE to start DCE devices. There probably are some, but I don't know the architecture that well, you would have to tap into one of the core devs like Thom. Best to jump onto the IRC channel.

If the former, then there should be some logging somewhere. Did you implement the logging output function in your devices? If so, then you should find a log in /var/log/pluto/##_blahblah where ## is the device number. Can't remember which piece of code is responsible for identifying and starting/spawning new devices... perhaps AppServer/LaunchManager? Either way the logs for it are in the same directory. You should look through the likely logs just after a reload, and at the end you should see your other devices starting. That may give you a clue...

mihajzm

  • Regular Poster
  • **
  • Posts: 43
    • View Profile
Re: Start custom made DCE (cpp) device at boot.
« Reply #6 on: April 04, 2009, 10:53:01 am »
I searched in the logs, but there is no mention about starting my device. In LaunchManager.log and also pluto.log there are lines "Starting device ..." , but no such line for my device ID. I tried manual to start it with "Spawn_Device.sh 85 localhost my_program" , after that in log appears
"Starting device #85 ..", also log file for my device is created "85_my_program.log". It seems that launch manager even not attempt to start my device, may be some problem in configuration of template or related package. I jump to IRC and try to discuss it there.

Thank you.