PDA

View Full Version : Client app/RFE RTC call limitation


korda
05-26-2008, 03:55 PM
Tried to call a function on a node, running a custom script, which must return more then one parameters.
I could not use existing C# example to receive more then one argument. I guess I could pass all data as one array, but the Phyton script for a node does not support arrays, only script for Portal can compile them w/out errors.

Can you extend your C# example so it will pass back random number AND actual node MAC?
The current example is using MAC on the computer, assuming it is the same...

In my practical application I would like to pass back from a node several parameters and the node's MAC. Each parameter must be 4-byte array, which must be accepted by PC as an 32-bit integer. The 4-byte array is read from the node's flash by loadNvParameter(). It is placed there before by the client app, by calling node function, which uses saveNvParameter(128, data1) and saveNvParameter(132, data2), where data1 and data2 32-bit unsiged int on the PC and 4-byte array on RFE...

mgenti
05-27-2008, 03:05 PM
The SNAP Gateway does support calling a user function with multiple parameters. I tested passing two integers back to a C# client and successfully received both. You may not need to pass the MAC address of the node back if you are using that to determine who is calling your function. In the event response structure that is sent to your application it includes the network address of the node that is calling your function. The network address should be all that is required to determine which node is calling your function. In the provided C# example the class level variable "netAddr" is automatically set for you before calling the function. Then in your function you should then be able to check who called you (as demonstrated in the "myTest" function).

I believe you maybe running into a known bug with the SNAP Gateway where certain binary strings that have non ASCII characters are not correctly encoded. This bug is fixed in what will be our official first release of the gateway with version 2.1. I will see if in the mean time we can roll back the fix into another 2.0 beta version of the gateway.

korda
05-27-2008, 05:19 PM
I do not know if I had a problem with known Gateway bug converting int to byte array, but it worked fine with one int parameter. every time I pass second parameter back - receive nothing. For example:

#this call works
rpc(myPortalAddr, 'reportLineStation', Line)

# this does not work
rpc(myPortalAddr, 'reportLineStation', Line, Station)

I am not sure what the Line, Station type is in PY, but I have tried them to be 32-bit int originally, sent to a RFE, saved in NV, read back and sent to C#.
Can you make a code to do this?

mgenti
05-28-2008, 10:37 AM
In my test I just modified the signature of the "myTest" method and made it look like:
public void myTest(int a, int b)

Then in the SNAPpy script I modified it to return two random integers:
rpc('\x00\x00\x01', 'myTest', random(), random())