views:

79

answers:

2

I am using Erlang for driving robot.

I am reading sensor values in C program and want to send these sensor values(multiple sensor values) to Erlang program where I can perform computation and control robot. In progam given in Erlang book we can send multiple argument but we get back only one argument as result. for sending X and Y to C program:

Port ! {self(), {command, [50,X,Y]}}

In result:

{Port,{data, Data}} ->

we got only one argument Data(buff[0]).

Is there any way to receive multiple argument in Erlang program like buff[0], buff[1], buff[2]..and so on. please suggest me some way of achieving this...

A: 

Check out your C file and send back a binary for example,

what kind of driver are you using?

Alexandre Abreu
i have tried using both C port and Port driver(linked in driver).
Dinesh
+3  A: 

Just constuct and return a tuple of 3 and then return the binary of that and patternmatch it straight in the answer. You can construct tuples and lists by using the ei modules. See http://www.erlang.org/doc/apps/erl_interface/index.html (module ei) for how to do that and look at http://www.erlang.org/doc/apps/erl_interface/users_guide.html for the user guide.

Mazen Harake
Thanks I will try this...
Dinesh