update.
parent
940afad713
commit
9e9d47ce80
|
@ -60,7 +60,7 @@ int main()
|
|||
}
|
||||
// 打印usb设备信息
|
||||
// print_devs(devs);
|
||||
dev_handle = libusb_open_device_with_vid_pid(NULL, 0x2833, 0x0002);
|
||||
dev_handle = libusb_open_device_with_vid_pid(NULL, 0x0483, 0x5750);
|
||||
if (dev_handle == NULL)
|
||||
{
|
||||
printf("Cannot open device\n");
|
||||
|
@ -94,20 +94,23 @@ int main()
|
|||
while (1)
|
||||
{
|
||||
|
||||
r = libusb_bulk_transfer(dev_handle, (0x01 | LIBUSB_ENDPOINT_IN), data, 64, &transferred, 1000);
|
||||
if (r == 0 && actual == 64) // we read the 64 bytes successfully
|
||||
printf("Read Successful\n");
|
||||
else
|
||||
r = libusb_interrupt_transfer(dev_handle, (0x01 | LIBUSB_ENDPOINT_IN), data, 64, &transferred, 1000);
|
||||
if (r == 0 && actual == 127){
|
||||
// 解析GeekIMU的磁力计信息
|
||||
int16_t mx = *(int16_t *)(data + 3);
|
||||
int16_t my = *(int16_t *)(data + 5);
|
||||
int16_t mz = *(int16_t *)(data + 7);
|
||||
printf("mag:%d,%d,%d\n", mx, my, mz);
|
||||
}else{
|
||||
printf("Read Error\n");
|
||||
printf("%i,%i\n", r, actual);
|
||||
}
|
||||
|
||||
//printf("%i,%i\n", r, actual);
|
||||
|
||||
|
||||
|
||||
// 解析GeekIMU的磁力计信息
|
||||
int16_t mx = *(int16_t *)(data + 56);
|
||||
int16_t my = *(int16_t *)(data + 58);
|
||||
int16_t mz = *(int16_t *)(data + 60);
|
||||
printf("mag:%d,%d,%d\n", mx, my, mz);
|
||||
// 睡眠延时100ms
|
||||
usleep(1000 * 100);
|
||||
usleep(1000 * 10);
|
||||
// 清屏
|
||||
// printf("%s","\033[1H\033[2J");//clear display
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue