10 years, 10 months ago.

USB serial. how to receive multiple characters in 1 usb packet?

my setup: PC and lpc1768 communicating over usb serial. I type "blah" from my pc. and receive "hello". but 1 usb packet sent "blah" and 5 usb packets receive "h" "e" "l" "l" "o".

test code

#include "mbed.h"
#include "USBSerial.h"

USBSerial serial;

void main(){
   char serial_in[31] = "";
  serial.scanf("%s", serial_in));
  serial.printf("hello\r\n");
   
}

and in my USB sniffer(USBPcap and wireshark), I type in "blah" and i see blah in 1 usb packet:

usb sniffer output

69	0.026000	host	8.2	USB	31	URB_BULK out    "blah"
70	0.027000	8.2	host	USB	28	URB_BULK in      "h"
71	0.028000	8.2	host	USB	28	URB_BULK in      "e"
72	0.029000	8.2	host	USB	28	URB_BULK in      "l"
73	0.030000	8.2	host	USB	28	URB_BULK in      "l"
74	0.031000	8.2	host	USB	28	URB_BULK in      "o"

Is there any way to output a few characters within 1 USB packet, instead of a single character per USB packet?

this is a slow way to transferring data via USB.

1 Answer

10 years, 10 months ago.

nvm.. solved.

used writeBlock() function.