Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Crazy Serial overhead sending to USB CDC Serial devices on Mac

$
0
0
I'm currently sending data to an Arduino Leo from Processing (Mac OS X Mountain Lion) over the Serial port. Here's the relevant snippet of code:
  1. for(int q=1; q<int(buffer_size_n*buffer_size_X*buffer_size_Y/2)+1; q++){   
  2.       newBuf[q%newBufSize] = byte(sendBuf[2*(q-1)] << 4);
  3.       newBuf[q%newBufSize] |= sendBuf[2*(q-1)+1];
  4.       if((q+1) % newBufSize == 0){
  5.         myPort.write(newBuf);
  6.         delay(1);
  7.       }
  8.     }
  9.     myPort.write(newBuf);
In total I'm sending 600 bytes with this function, and I've been playing the variable newBufSize to change the size of the packets I'm sending. No matter what baud rate I set it to or what size packets I pick this code always takes at least 100ms which is all taken up in the serial writing calls. This is WAY slower than the baud rates I'm setting. However, if I switch to an FTDI serial device it takes closer to 1ms, which makes sense. Is RXTX shitty in some way? Is Mac's driver for generic USB CDC Serial devices crap? Is there an alternative?

I've been googling all day and night and I can't seem to find a definitive answer. I've updated and downgraded RXTX already.

Thanks in advance for any help!

Viewing all articles
Browse latest Browse all 1768

Trending Articles