sunacha3 / java-simple-serial-connector

Automatically exported from code.google.com/p/java-simple-serial-connector
1 stars 0 forks source link

SerialPortEventListener returns invalid type #84

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago

This isn't necessarily a bug, it just looks incredibly weird.

In SerialPortEvent the event types look exactly like a bit field:

    public static final int RXCHAR = 1;
    public static final int RXFLAG = 2;
    public static final int TXEMPTY = 4;
    public static final int CTS = 8;
    public static final int DSR = 16;
    public static final int RLSD = 32;
    public static final int BREAK = 64;
    public static final int ERR = 128;
    public static final int RING = 256;

All the values are double previous values.

And yet all the code doesn't examine the value like a bitfield, but like a 
regular field:

    public boolean isRXCHAR() {
        if(eventType == RXCHAR){
            return true;
        }
        else {
            return false;
        }
    }

Maybe not wrong, but just looks a lot like it!

Original issue reported on code.google.com by xpusosto...@gmail.com on 23 May 2015 at 7:54