发送数据至NAO
可以发送三种数据:
- 一个8位无符号整数(0-255)
- 一个32位无符号整数(0-4294967295)
- 一个IP地址(如 "192.168.0.56")
操作时,分别使用以下三个绑定方法:
/** * Function sendIpAddress is called to send an IP address * @param pIP: string containing an IP address (eg "127.0.15.129") */ void sendIpAddress(const std::string& pIP); /** * Function send8 is called to send 1 octet * @param pOctet : Integer containing an octet */ void send8(const int& pOctet); /** * Function send32 is called to send 4 octets * @param pData_IR: string containing a 4 octet value (be careful it's a string) */ void send32(const std::string& pData_IR); // OR /** * Function send32 is called to send 4 octets * @param pOctet1 : 1st octet of the 32 bits value * @param pOctet2 : 2nd octet of the 32 bits value * @param pOctet3 : 3rd octet of the 32 bits value * @param pOctet4 : 4th octet of the 32 bits value */ void send32(const int& pOctet1, const int& pOctet2, const int& pOctet3, const int& pOctet4);
Python范例:依次发送这三种数据:
import naoqi from naoqi import ALProxy import time lirc=ALProxy("ALInfrared","127.0.0.1",9559) # change IP with NAO IP lirc.sendIpAddress("127.0.0.1") # Send IP address time.sleep(0.5) # Delay necessary for a reliable transfer lirc.send8(42) # Send the number 42 time.sleep(0.5) lirc.send32(0x42, 0x2A, 0x13, 0x0D) # Send four 8 bits numbers time.sleep(0.5) lirc.send32("36757575") # Send one 32 bits number
注意: |
发送1个八位字节时需要0.5秒。发送4个八位字节或1个IP地址时需要2秒。 |
---|
注意: |
每次发送之间需要有一定的延迟(约0.5''),以保证传送的可靠性。 |
---|
发送一个数据后,相应的数据会被保存在ALMemory里:
事件/数据 | 类型 | ALMemory | 说明 |
---|---|---|---|
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/IP/Actuator/Value/" | IP地址 |
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/uInt8/Byte/Actuator/Value/" | 8位无符号整数 |
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte1/Actuator/Value/" | 32位无符号整数的第1个八位字节 |
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte2/Actuator/Value/" | 32位无符号整数的第2个八位字节 |
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte3/Actuator/Value/" | 32位无符号整数的第3个八位字节 |
数据 | 整型(int) | "Device/SubDeviceList/IR/LIRC/Data/uInt32/Byte4/Actuator/Value/" | 2位无符号整数的第4个八位字节 |