|
|
| Author |
Message |
|
| flodis |
Posted: Tue May 05, 2009 9:42 pm |
|
|
|
User
Joined: 09 Jul 2008
Posts: 27
|
I have trouble decoding numbers send from erlang to my C++ port.
What exactly should I decode when sending the number from erlang, is it a long, unsigned long, double? I have tried all of them.
The code for decoding my message is:
Code: void set_mesh(ebyte* buf, int* index, ei_x_buff* reply)
{
char arg[MAXATOMLEN];
int type, size, arity;
unsigned long id;
char mesh[255];
/* The format should be {id, Id}, {mesh, Mesh} */
ei_decode_atom(buf, index, arg);
ei_decode_ulong(buf, index, &id);
ei_decode_atom(buf, index, arg);
//ei_get_type(buf, index, &type, &size);
ei_decode_string(buf, index, mesh);
fprintf(stderr, "set_mesh: id, %f\n", id);
//View::getSingleton()->setMesh(*id, mesh);
ei_x_encode_tuple_header(reply, 2);
ei_x_encode_atom(reply, "ok");
ei_x_encode_atom(reply, "set_mesh");
}
The result I get to stderr is:
set_mesh: id, -0.059527
The number I send to the port is 32.
I am doing alot of communication to and from the port with strings and atoms, and that is working fine. |
|
|
| Back to top |
|
| flodis |
Posted: Wed May 06, 2009 7:09 am |
|
|
|
User
Joined: 09 Jul 2008
Posts: 27
|
I figured out this one myself.
It seems like if I send 0 I get an ERL_SMALL_INTEGER_EXT while a 0.0 or similar will give me an ERL_FLOAT_EXT.
Now I only need to figure out what decode function I should use on them, the docs does not reveal so much. I guess I have to do trial and error. |
|
|
| Back to top |
|
|
|
All times are GMT
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|
|