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

Re : Serial data is limited to signed 8-bit data???

$
0
0
>> One of the worst Java's implementation decisions -> signed byte primitive data-type!

Thanks for the reply.  I didn't want to say it cause I'm new to the forum and to Java but I was definitely thinking it!!

The only problem with your solution is that it doesn't solve the problem of efficiently getting data from the Serial library.  It seems the only function that take a buffer array parameter is Serial.readBytes(byteBuffer).

It seems that the only option I have is to use a loop of some kind to read out the data with readChar() or read() in the serialEvent() handler.  However now that I'm thinking about it I wonder if in reality thats what the readBytes(byteBuffer) function does in the background or some kind of memcopy.  When the serialEvent handler is called the data isn't already in the buffer I pass to the function so there is going to be overhead anyway.

For convenience I wonder if the Serial library author could add a new readChars() function - the fact that in Java the "char" or short is 16-bit wont matter because data from USART in normal mode is at max only 8-bits.

Viewing all articles
Browse latest Browse all 1768

Trending Articles