PDA

View Full Version : some LQ related questions


kbanks
03-31-2009, 02:36 PM
from an email...
We are attempting to further qualify the links between specific modules in a multi node network, and were hoping you could clarify a couple items.

(1) “scanEnergy()” does not seem to return a “readable” 16 byte string in Portal as described in the SNAP Reference Manual.

Using the following function:

print “scanEnergy= -”, scanEnergy(),"dBm"

we see the following values returned at Portal:

scanEnergy= -________________dBm

scanEnergy= -__________H=M___dBm

Can you clarify the letter/underscore significance and whether a “decode” of the string must be performed?


Since SNAPpy does not currently support arrays, we sometimes have to make do with character strings. Such was the case with the scanEnergy() function.

Each character in the returned string should be interpreted based on it's ordinal value. For example, you saw a value of "H" on one of your channels. This corresponds to 0x48, or 72 decimal. The energy reading on that channel at the time of the scan was 72 dBm, from a possible range of 18 dBm (strong) to 95 dBm (weak).

In SNAPpy (as well as in "full" Python) you can use the ord() builtin to convert from a "character" value to numeric one.


(2) There does not appear to be a means to differentiate or specify which node has sent the packet which is being used to calculate the received link quality of a node with the “getLq()” function. The SNAP Reference Manual states that the received link quality is derived from “the most recently received packet, regardless of which node the packet came from”.

In a network with many nodes, how would we determine the link quality between two specific nodes?


When a RPC is invoked on a node, the rpcSourceAddr() built-in can be used to see who the "invoker" is (refer to page 52 of the SNAP reference Manual).

So, for example, you can determine the links between a node "A" and "B" by having node B invoke rpc(nodeA,"callback","tellLq","getLq") and having a function like the following in Node B.


def tellLq(otherLq):
# Here otherLQ is how well the other node heard US
# rpcSourceAddr() reminds us WHO that node is
# getLq() here tells us how well we hear HIM
# Do something here with BOTH pieces of info

joecool
07-07-2009, 01:34 PM
from an email...


Since SNAPpy does not currently support arrays, we sometimes have to make do with character strings. Such was the case with the scanEnergy() function.

Each character in the returned string should be interpreted based on it's ordinal value. For example, you saw a value of "H" on one of your channels. This corresponds to 0x48, or 72 decimal. The energy reading on that channel at the time of the scan was 72 dBm, from a possible range of 18 dBm (strong) to 95 dBm (weak).

In SNAPpy (as well as in "full" Python) you can use the ord() builtin to convert from a "character" value to numeric one.


Seeing as how ord() only works with a single character, can you show an example of how to parse all 16 bytes returned by scanEnergy()? Due to all the interference by 2.4GHz Wi-Fi routers, cordless phones, etc, it is very important for our customers to be able to find a clear channel (without resorting to running portal with a SnapStick).

kbanks
07-07-2009, 02:44 PM
If you have (for example) a 16-character string, then the individual characters are accessible using indexing.

For example, if the variable is named data, then data[0] is the first character, data[1] is the next, up to data[15] which is the last character.

Those individual characters can then be converted to their numeric values using the ord() function.

c0 = ord(data[0])
c1 = ord(data[1])
etc.

joecool
07-07-2009, 02:49 PM
If you have (for example) a 16-character string, then the individual characters are accessible using indexing.

For example, if the variable is named data, then data[0] is the first character, data[1] is the next, up to data[15] which is the last character.

Those individual characters can then be converted to their numeric values using the ord() function.

c0 = ord(data[0])
c1 = ord(data[1])
etc.

Great, but isn't that an array? I'd have tried that, but your earlier post said you didn't support arrays.

Just curious why you folks decided to go with Python instead of C or even Basic?

kbanks
07-07-2009, 04:21 PM
Subscripting works with strings as well as true arrays. This is true of "desktop" Python as well as SNAPpy.

As for the choice of what language to embed, Basic was considered, along with several others. We also considered inventing "yet another scripting language", and not matching any existing language.

We were already programming in Python here at Synapse (Portal for example was written in Python). Also, Portal 1.x supported running Python scripts that interacted with SNAP 1.x nodes, but that ran up on the PC.

It seemed a natural extension to support "pushing those PC scripts down into the nodes". (However, we did retain the ability for Portal to run Python scripts too.)