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!
Only primitive data-type which is unsigned is char, but it's 16 bits! While C's 8 bits.
You can also use 16-bit short, but it's signed!

I wonder whether it's possible to work this out.
When you read the unsigned byte from RS232 into Processing , store it in a short data-type variable.
Just before sending it back to RS232, use a (byte) cast operator upon the short variable's stored value.
    short s = 150;
    byte  b = (byte) s;
    
    println(s + "\t " + b);
    
    exit();
    


Viewing all articles
Browse latest Browse all 1768

Trending Articles