uint32 USBSerial::read(void *buf, uint32 len) { if (!buf || gbUsbVcpStatus == USB_PORT_CLOSE) { //[ROBOTIS]2012-12-19 to prevent USB Blocking issue! return 0; } uint32 rxed = 0; while (rxed < len) { rxed += usbReceiveBytes((uint8*)buf + rxed, len - rxed); } return rxed; }
void usbSendHello(void) { uint8 bufin = 48 + recvBufIn;; uint8 bufout = 48 + recvBufOut; uint8 avail = 48 + usbBytesAvailable(); char *line = "\r\n"; while(usbSendBytes(&bufin,1) == 0); while(usbSendBytes(&bufout,1) == 0); while(usbSendBytes(&avail,1) == 0); while(usbSendBytes((uint8*)line,2) == 0); uint8 recv[64]; usbReceiveBytes(&recv[0],1); }
uint8 serialUsbRead(void) { uint8 ch; usbReceiveBytes(&ch, 1); return ch; }
uint32 serialUsbReadBuf(void *buf, uint32 len) { if (!buf) { return 0; } return usbReceiveBytes((uint8*)buf, len); }