Someone will probably be able to answer this in two seconds…
I have a bluegiga module connected to my IMP via UART, and its working properly, I’m just trying to get my Squirrel “Read()” function correct.
I have this:
`function blueRead() {
local readValue = “”;
local b = uart.read();
// block until data available
while(b==-1){b = uart.read();}
while(b!=-1) {
readValue += format("%c", b);
b = uart.read();
}
return readValue;
}
local result = “”;
…and I call it like this…
uart.write(“AT
”);
imp.sleep(0.000002);
result = blueRead();
server.log("response: " + readValue);
uart.write(“AT
”);
imp.sleep(0.000002);
result = blueRead();
server.log("response: " + readValue);
uart.write(“AT
”);
imp.sleep(0.000002);
result = blueRead();
server.log("response: " + readValue);`
…The interesting thing, is - the module replies with “>ATOK”, but this is the program output
2014-03-05 21:15:09 UTC+13: [Device] response: > 2014-03-05 21:15:10 UTC+13: [Device] response: A 2014-03-05 21:15:10 UTC+13: [Device] response: T
I know that all my data is being read back in my the blueRead() method (I logged the individual chars) - but for some reason, each “server.log(result)” is just… reading a single char from the readValue variable…
What am I doing wrong here?
Thanks