Problem with serial

Hello

I am trying a new peripheral (kind of compass). I have to send a *start command (with the *) and then it will send me back a continuous stream of data

I tried to adapt the serial example, but I cannot make it work. I can connect but receive no data, just the ‘ofSerial: trouble reading from port’ message (there’s nothing to read)

Can you see any mistake in my code? The device is working with the provided application, so I think that I’m doing something wrong.

Update: The specifications of the device say that I have to set the port to “115200 Bit per second, 8 Data bits, Parity None; 1 Stop bit, Flow control None”. Is it something that I have to configure “outside” of OF?

  
  
		serial.setup("/dev/cu.usbmodem3a21", 115200);  
...  
		serial.writeByte('*');  
		serial.writeByte('s');  
		serial.writeByte('t');  
		serial.writeByte('a');  
		serial.writeByte('r');  
		serial.writeByte('t');  
		serial.writeByte('\r');  
		serial.writeByte('\n');  
		   
		nTimesRead = 0;  
		nBytesRead = 0;  
		int nRead  = 0;  // a temp variable to keep count per read  
		  
		unsigned char bytesReturned[3];  
  
		memset(bytesReadString, 0, 4);  
		memset(bytesReturned, 0, 3);  
		  
		while( (nRead = serial.readBytes( bytesReturned, 3)) > 0){  
			nTimesRead++;	  
			nBytesRead = nRead;  
			printf("// Got something! //");  
		};  
		nTimesRead=0;  
		memcpy(bytesReadString, bytesReturned, 3);  
		  
		bSendSerialMessage = false;  
		readTime = ofGetElapsedTimef();  
  

I am in using a MBP

Thanks! :slight_smile: