rcp:cast/4 example?

andy allen <>
Tue Mar 27 18:02:57 CEST 2001

Hi, all.

I'm looking for advice on a simple example of rpc:cast/4.


I am trying to get the following code to execute:

call_ch_nodes_to_get_data(DataToPassWithCall) ->
    ?SYS_DBG(int_if, "mlgAmsCpt:call_ch_nodes_to_Get_data(~w)~n",

    ChNodes = get_ch_nodes(),
    ?SYS_DBG(int_if, "Found the following nodes: ~w ~n", [ChNodes]),

    Module = mlgCpt,
    Function = trace_cast,

    [ChNode | Rest] = ChNodes, % Temporary hack for one node
    ?SYS_DBG(int_if, "Will cast to the node ~w, module ~w, function
                      ~w with the parameters ~w ~n",
             [ChNode, Module, Function, [DataToPassWithCall]]),

    X = rpc:cast(ChNode, Module, Function, [DataToPassWithCall]),
    ?SYS_DBG(int_if, "Result of cast: ~w ~n", [X]),



SYS_DBG {mlgAmsCpt,680,int_if}, <0.20019.3> 27-Mar-2001 15:13:37.022072:
-- mlgAmsCpt:call_ch_nodes_to_Get_data ({{switch_dev_id, 1}, {channel, 

ChNodes = get_ch_nodes(), SYS_DBG {mlgAmsCpt,691,int_if}, <0.20019.3> 
27-Mar-2001 15:13:37.046248:
-- Found the following nodes: ['']

SYS_DBG {mlgAmsCpt,697,int_if}, <0.20019.3> 27-Mar-2001  15:13:37.048843:
-- Will cast to the node '', module mlgCpt, function trace_call 
with the parameters [{{switch_dev_id,1},{channel,all}}]

SYS_DBG {mlgAmsCpt,701,int_if}, <0.20019.3> 27-Mar-2001  15:13:37.052683:
-- Result of cast: true


To make certain that the function I am casting to works, I can call it with 
the following line from an Erlang shell:

mlgCpt:trace_call({{switch_dev_id, 1}, {channel, all}}).

It executes past a "SYS_DBG" statement, then crashes. But when I cast to it, 
it should at least execute the "SYS_DBG" statement, right?


For the uninitiated:
1. rpc is a library in the standard Erlang distribution,
2. ?SYS_DBG is a macro that works like a printf.


Thanks for ANY help you can give me!

Andy Allen
Ericsson, EUS/SA/BA

P.S. Has anyone considered expanding the MAN pages with simple hello-world 
examples of each library call?
Get your FREE download of MSN Explorer at http://explorer.msn.com

More information about the erlang-questions mailing list