Receive data from a NAO
When ALInfrared receive a data from an other NAO, it raise an event containing the data.
Every information of the event are also keep in memory.
The event array and the separated data are describe in the following table:
Event / Data | Type | ALMemory | Description |
---|---|---|---|
Event | string | "InfraRedIpAdressReceived" | IP address |
Data | string | "Device/SubDeviceList/IR/LIRC/Data/uInt8/Byte/Sensor/Value/" | IP address |
Event | int | "InfraRedOneByteReceived" | 8 bits value |
Data | int | "Device/SubDeviceList/IR/LIRC/Data/uInt8/Byte/Sensor/Value/" | 8 bits value |
Event | array | "InfraRedFourBytesReceived" | array containing the 4 octets |
Data | int | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte1/Sensor/Value/" | 1st octet |
Data | int | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte2/Sensor/Value/" | 2nd octet |
Data | int | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte3/Sensor/Value/" | 3rd octet |
Data | int | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte4/Sensor/Value/" | 4th octet |
Python example to receive an IP address:
from naoqi import * import time # create python module class myModule(ALModule): """python class myModule test auto documentation""" def pythondatachanged(self, strVarName, value, strMessage): """callback when data change""" print "----------------------------------------------------------" print "IP address = ", value, " ", strMessage print "----------------------------------------------------------" broker = ALBroker("pythonBroker","127.0.0.1",9999,"127.0.0.1",9559) # call method try: lirc=ALProxy("ALInfrared") eventName = "InfraRedIpAdressReceived" pythonModule = myModule("pythonModule") prox = ALProxy("ALMemory") prox.subscribeToEvent(eventName,"pythonModule", "pythondatachanged") except Exception,e: print "error" print e exit(1) time.sleep(10) exit(0)