On September 17, 2010 at 12:31, bnokes@AAVViD said...
can it be something other then \r like if the equipment sends some other kind of string other then a \r ? :) and if so then that would have to be in here: so if label = s.match(" ", "a different string here", 2000);
As BluPhenix says (or some other string). This is where you must read the protocol specification from your equipment. If you are lucky, they will always terminate a response with a specific character or sequence of characters. In that case, that character or sequence of characters is what you must use as the 2nd parameter for match().
If the equipment does NOT supply such a string, you will have to resort to using serial.receive for an anticipated number of characters and rely on the likelihood that you will be getting impartial messages which will require you to concatenate strings together
var buffer;
// serPort is a variable containing target serial port. check for proper casing against Dev Guide for onData below, please.
serPort.onData = function(x)
{
buffer += x;
// Your code goes here.. check buffer for a complete message String.substring() useful here.
// Your code goes here.. If complete message there, extract full message. String.substring() useful for this.
// Your code goes here.. Process the complete message.
// Your code goes here.. Remove complete message from buffer.
buffer = buffer(fullMsg.length); // assuming fullMsg is variable with string containing complete message, this discards the first fullMsg.length characters from the buffer.
};