// If the port is actually open, close itif (fd != -1) {close(fd);printf("SERIAL: Device %s is now closed.\n", dev);}}

In summary the Serial object can be created and used to read char values using .getChar().

This seems to work fine however calling .getChar() only sometimes contains the chars that I'm interested in and most of the time contains junk characters. Also the message send from the arduino is frequently chopped up with junk characters inbetween.

Can someone direct me to the best way to read the serial data so that I only recieve the string I'm interested in.

for (int i = 0; i < (n - 1); i++) {bufferIndex++;buffer[bufferIndex] = temp[i + 1];}bufferIndex should be incremented AFTER storing the value, not before. Also, after storing the value, you should add a NULL to the buffer;

I'm essentially looking for a way to re-create the function of the serial monitor in C++ on Linux (netbeans) so I can take the char array sent from the arduino and pass it into a char array in my C program that I can then tokenize and do further processing on.

void loop() { int delayValue = analogRead(0); Serial.println("Data:Here is Some data"); Serial.print(Delay : ); Serial.println(delayValue); digitalWrite(LEDPin1, HIGH); // set the LED on digitalWrite(LEDPin2, LOW); // set the LED off delay(delayValue); // wait for a second digitalWrite(LEDPin1, LOW); // set the LED off digitalWrite(LEDPin2, HIGH); // set the LED on delay(delayValue); // wait for a second}

I'm a biochemist and I have a PhD in electrochemistry, I am not an expert in electronics or programming but I can just about get by, and I'm doing this amature programming in an attempt to get serveral pieces of instrumention to talk to each other (A peristatic pump, a signal generator and a relay board).

I'm posting here to ask for help from people who have a better understanding of electronics and programming than I do. I'm sorry if you don't think that is a good enough reason to post here. I was under the impression that this is what this forum is for (asking for help). If not maybe you could point me in the direction of a place where I can get some help.

This IS a great place to get help. Help was offered. You chose to ignore it.

There is no need to add delays to make serial data transmission work. The code you first posted had blocking and non-blocking methods that had some issues. I suggested you should fix those issues. I still think you should go back to that code, and fix the issues.

If you would rather add delays, that will slow things down, as you've observed. If you can live with that, fine. If not, get rid of them and fix the original code.