ofSerial read on every loop

In the ofSerial example, the serial data is only read when the mouse is pressed.

How can I get it to read on every loop? I have changed the code to the following, and still, it is only reading my button data from Arduino when I press the mouse. I need it to check constantly if there is has been a button press.

Thanks for any advice!

Arduino code:

  
 if (digitalRead(3) == HIGH) {  
        Serial.print(3);  
    }  
      
    if (digitalRead(6) == HIGH) {  
        Serial.print(6);  
    }  
      
    if (digitalRead(8) == HIGH) {  
        Serial.print(8);  
    }  

oF Code:

  
void testApp::draw(){  
	if(serial.available()){          
		cout << "Serial Available" << endl;  
		unsigned char bytesReturned[1];          
		  
        memset(bytesReadString, 0, 1);          
        memset(bytesReturned, 0, 1);      
		  
        // This reads the data now that arduino is sending a response,       
        serial.readBytes(bytesReturned, 1);  
		cout << "bytes Returned: " << bytesReturned << endl;  
        string serialData = (char*) bytesReturned;            
        int serialValue = ofToInt(serialData);    
		cout << "serial Value: " << serialValue << endl;  
		  
		if((serialValue)==6){  
			cout << "SerialValue of Button:"  << serialValue << endl;  
		}	  
		  
		if((serialValue)==3){  
			cout << "SerialValue of Button:"  << serialValue << endl;  
		}	  
		  
		if((serialValue)==8){  
			cout << "SerialValue of Button:"  << serialValue << endl;  
		}	  
		  
        //This was allows for the whole process to repeat without    
        // getting strange overlapping readings from the encoder:    
        serial.flush();    
		  
	}  
  
}  
  

The Console does give me the following, but only if I am pressed the button WHILE I click the mouse…

Serial Available
bytes Returned: 6
serial Value: 6
SerialValue of Button:6

It seems that no matter how I implement if(serial.available()), it reports to 0, as if it is not checking the serial data on each update() loop? The only way I seem to be able to get it to check is if the program is writing on a mouse click, at which time it (sometimes) checks the serial.read on that mouse click, which the serial port is “open” anyway…

Any advice on this would be helpful.

VeeBee