Here are a few things...

The function signature for Process messages is
int Khepera::ProcessMessage(QueuePointer & resp_queue, player_msghdr * hdr, void * data)

You have a QueuePointer * so the method will not be called. Also in your publish for the response_ack you need to include the queue you are respongind two as your second argument.


On 23/11/2007, Gorka Azcune <gazcune@fatronik.com> wrote:
Hi all,

I insist on the problems I issued last time. The point is that someone wrote his/her problems in my thread, which didn't have anything to do with the ones I explained, and it seems my problems got lost somewhere. I've been trying new things since then in order to get a flavour of what's happening but I get nothing. Here I rewrite the mail I sent last time so you can understand my problem.

I'm trying to write a driver which implements an opaque interface. I also
have a driver implementing a power interface, which sends some requests to
the first opaque driver and publishes the data received to the player
server. My problem is that when I run both drivers and try to get some data
using a PowerProxy on the client side, all the messages received after
request are empty. The player server logs this message each time a request
is done:

warning : Unhandled message for driver device=16777343:6665:opaque:0
type=request subtype=1 len=4

I use the CVS version of player, so as I can see in the documentation,
requests to opaque interfaces are supported. Here you have some of the code
I wrote and I think might be useful. This is the request I do in the main
loop of my batterydriver (which implements the power interface):

Message* msg = (Message*)malloc(sizeof(player_opaque_data_t));
printf("BatteryDriver: Sending request to candriver\n");
player_opaque_data_t data;
msg = this->can_dev->Request(this->InQueue,PLAYER_MSGTYPE_REQ,
PLAYER_OPAQUE_REQ,(void*)&data, sizeof(player_opaque_data_t),
NULL, true);

I always get that msg == NULL. Here you have the other driver, the one which
implements an opaque interfaze. I only put the ProcessMessage method, since
the main loop calls only to ProcessMessages and pthread_testcancel:

int CanDriver::ProcessMessage(QueuePointer* resp_queue,
player_msghdr * hdr,
void * data)

printf("CanDriver: A message arrived\n");

if(Message::MatchMessage(hdr, PLAYER_MSGTYPE_REQ,
printf("CanDriver: Request received\n");
this->mData.data_count = sizeof(BatteryCharge);
this->bc = reinterpret_cast<BatteryCharge*>(mData.data);
this->bc->driverTag = 0;
this->bc->structTag = 0;
this->bc->batteryVoltage = 24.9;

reinterpret_cast<void*>(&mData), sizeof(player_opaque_data_t),
printf("Data served\n");

return 0;
printf("CanDriver: Unknown message arrived\n");
return -1;


The annoying thing here is that the first printf doesn't write on the
screen, from what we know that we don't even enter the ProcessMessage
method. I would bet I have no subscription problems between these two
drivers so I cannot get the point. Here you have the constructor, SetUp() and ShutDown() methods just in case:

BatteryDriver::BatteryDriver(ConfigFile* cf, int section)
: Driver(cf, section, false, PLAYER_MSGQUEUE_DEFAULT_MAXLEN,

if(cf->ReadDeviceAddr(&this->can_addr, section, "requires",
printf("Will subscribe to opaque:%d\n", this->can_addr.index);

// Read the data updating period
this->period = cf->ReadInt(section, "period", 10);
std::cout << "The data updating period is " << this->period << " seconds"
<< std::endl;


int BatteryDriver::Setup()
puts("Battery driver initialising");

// Retrieve the handle to the can device.
if(!(this->can_dev = deviceTable->GetDevice(this->can_addr)))
PLAYER_ERROR("unable to locate suitable can device");

// Subscribe my message queue to the can device.
if(this->can_dev->Subscribe(this->InQueue) != 0)
PLAYER_ERROR("unable to subscribe to can device");

puts("Battery driver ready");

// Start the device thread; spawns a new thread and executes


int BatteryDriver::Shutdown()
puts("Shutting Battery driver down");

// Stop and join the driver thread

// Unsubscribe from can

puts("Battery driver has been shutdown");


Sorry for all the code written, but I think it's necessary. I also did some tests publishing opaque structs as DATA_TYPE messages and try to get them in my battery driver, but it didn't work either. Could anybody suggest something? I really cannot get the point of what's going on here. Thanks a lot in advance and excuse me again for my insistence.

Bets regards,



This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
Playerstage-users mailing list

This email is intended for the addressee only and may contain privileged and/or confidential information