Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
LPC1768でUSBHostライブラリを使い、XboxONEのコントローラと通信したいです。 一応はできているのですが、通信でデータを受け取る間隔がパソコンとの通信と比べ長いのです。 パソコンとの通信では最短8msおきにデータを受信できていたのですが、mbedとの通信だと最短でも32msおきにデータを受信します。 その影響で受信できないパケットがあり、困っています。 手持ちのマウスとの通信も試してみたのですが、パソコンとの通信だと最短8msおきにデータが受信できたものが、mbedとの通信だと32msおきにしかデータを受信できませんでした。 プログラムは下記のものを使用し、パソコンとの通信間隔はWiresharkで、mbedとの通信間隔はプログラム中のTimerで計りました。 何故32msおきにしかデータを受信できないのでしょうか、また、解決するためにはどうすればよいのでしょうか。
#include "mbed.h" #include "USBHostMouse.h" Serial pc(USBTX, USBRX); DigitalOut led(LED1); Timer timer; void onMouseEvent(uint8_t buttons, int8_t x, int8_t y, int8_t z) { printf("buttons: %d, x: %d, y: %d, z: %d\r\n", buttons, x, y, z); std::printf("timer=%f\r\n", timer.read()); timer.reset(); timer.start(); } void mouse_task(void const *) { USBHostMouse mouse; while(1) { // try to connect a USB mouse while(!mouse.connect()) Thread::wait(500); // when connected, attach handler called on mouse event mouse.attachEvent(onMouseEvent); // wait until the mouse is disconnected while(mouse.connected()) Thread::wait(500); } } int main() { pc.baud(115200); pc.printf("----------\r\n"); Thread mouseTask(mouse_task, NULL, osPriorityNormal, 256 * 4); timer.start(); while(1) { led=!led; Thread::wait(500); } }