Hello,
this is my first post, so, introductions may be useful.
I’m working with QNX since 2002. I’ve writed some resource managers, created and implemented a system architecure for robotics.
Well… this last days, I’m having some problems with retrieving data from void *data pointers.
I want to discuss the best way for implementing different types of data wich the resource manager may receive.
What am I doing?
I have some structures like :
[code]struct header_t {
int a;
int b;
};
struct data_t {
int c;
int d;
};
typedef struct {
struct headerT *hea;
struct data_t *data;
} buf_t;[/code]
From a client program (sender) I do something like
[code]
…
buf_t *buf;
buf->hea = &header;
buf->data = &data;
write(RESMGR. buf, (sizeof(struct header_t) + sizeof(struct data_t));[/code]
From Resource Manager I want to do something like :
1 - read the header information :
resmgr_msgread(ctp, &buf->header, sizeof(buf->header), sizeof(msg->i))
2 - Check the header information
3 - read the info.
resmgr_msgread(ctp, &buf->info, sizeof(buf->info), (sizeof(msg->i) + sizeof(buf->header));
4 - Check de info
5 - do something…
6 - end
I want to discuss the ways to do this. You got a message, then you must first see wich message is this (reading the header) and then, put the information received in the right structure (based on header information).
Now, i planned to do 2 resmgr_msgread, the first one with only the header information and then, the second read for the data.
I’m getting weird pointer problems, the client sends the full information and the resource manager receives it, but the header contains useless information like if the pointer is pointing to the wrong place.
But, if the client sends ONLY the header information, the information is ok but with no data after the header…
Thanx to all
Leandro Colen
GEAR - Grupo de Estudos em Automacao e Robotica
Study group for automation and robotics.
PUC-MG - Brazil