Author Topic: How do I get to Device data in a C++ DCE device? [solved]  (Read 1584 times)

ajward

  • Regular Poster
  • **
  • Posts: 21
    • View Profile
How do I get to Device data in a C++ DCE device? [solved]
« on: January 23, 2009, 01:33:52 am »
Hi,

Sorry if there's a simple answer in an obvious place for this, but I couldn't find it!

I have a USB DCE device (it's the Dusky Control USB Sky device), and I have it working (Hurrah!).

...but the implementation only works with one device, because I can't translate the box_num/device_num identification system used by the Dusky software to what I need.

The solution seems to be to parse the /dev/bus/usb/nnn/mmm string that LinuxMCE generates against the Device Data/Block Device parameter when it auto-detects the device.

I've found that data in the database, but I can't work out how to get retrieve it given only the DeviceID. I could use sqlCpp and query it directly, but surely there's a utility method for doing this?

I suspect it might have something to do with ::GetConfig() and the DATA_ configuration parameters, but I can't work out the calls to make from the code.

Can anyone find it in their hearts to help me out with a simple example, please?

TIA
Andy W.
« Last Edit: February 28, 2009, 06:19:04 pm by ajward »

darrenmason

  • Addicted
  • *
  • Posts: 529
    • View Profile
Re: How do I get to Device data in a C++ DCE device?
« Reply #1 on: January 23, 2009, 04:36:51 am »
Andy,

If "Block Device" is device data defined (and populated) in your Device Template or any of the Device Template's in the inheritance heirarchy then you will have an auto generated accessor method.

This will be defined in the generated header file in Gen_Devices. eg: if your device  template is XXX then look in Gen_Devices/XXXBase.h

I 'think' this is what you are asking.

HTH
Darren

hari

  • Administrator
  • LinuxMCE God
  • *****
  • Posts: 2421
    • View Profile
    • ago control
Re: How do I get to Device data in a C++ DCE device?
« Reply #2 on: January 23, 2009, 09:43:33 am »
you can also talk to the info plugin to get/set device data for other devices, e.g.:

Code: [Select]
CMD_Set_Device_Data cmd_Set_Device_Data(m_dwPK_Device, 4, PKDevice, sCapabilities.c_str(), DEVICEDATA_Capabilities_CONST);               
SendCommand(cmd_Set_Device_Data);

br, Hari
rock your home - http://www.agocontrol.com home automation

ajward

  • Regular Poster
  • **
  • Posts: 21
    • View Profile
Re: How do I get to Device data in a C++ DCE device?
« Reply #3 on: January 26, 2009, 02:27:46 pm »
Thanks guys, that's just what I need.

I'll give that a try!

Cheers,
Andy Ward.

ajward

  • Regular Poster
  • **
  • Posts: 21
    • View Profile
Re: How do I get to Device data in a C++ DCE device? [Solved]
« Reply #4 on: February 13, 2009, 06:08:09 pm »
Thanks guys, with that bit of guidance, works a treat.

What I was missing was that just because a device reports a Block_Device parameter in the device tree, doesn't mean you can get to that parameter via an access method. The access method is only present if you add the parameter Block_Device against the device template.

Obvious now I know  :).