PDA

View Full Version : loadNvParam() and localAddress() usage


l091
08-13-2009, 06:40 AM
How can I send the localAddress() and loadNvParam in an rpc? When I do:

rpc('logEvent',localAddress()+", says: Hello")I get his output in de logevent in Portal:

says: Hello

kbanks
08-13-2009, 09:44 AM
Try dumping the received string in HEX-ASCII up in Portal. You will likely find that the address of the node contains unprintable characters, making it look funny in the event log, but that the bytes ARE actually getting sent.

FYI, when an RPC comes in, Portal already knows who it is from. Look at variable remoteAddr in your Portal RPC handler.

The following snippet shows both techniques


# This is a Portal script
import binascii

def convertAddr(addr):
"""Converts binary address string to hex-ASCII address string"""
return binascii.hexlify(addr)

def testRemoteAddr():
print convertAddr(remoteAddr)+' made an RPC into Portal'

admin
08-13-2009, 09:45 AM
More than likely you are seeing the problem where non-printable characters are not shown in Portal's event log. A network address usually contains characters like \x00 and others that do not have an printable ASCII value. There have been some posts around the forum about using hexSupport to print these characters.