Trying to read serial text that is
\r terminated. I am able to read the text coming from my test unit using the Impee-Kelly reference design, however all the text lines run together. I was hoping to use
\r to start a new line of text.
Any code examples or ideas on how to use
\r to get individual lines of text. Thanks.
function rx() {
local d = uart.read();
while(d >= 0) {
if (d>=’ ‘) line += d.tochar();
if (d==’\r’) {
server.log(“RX:”+line);
line="";
}
d=uart.read();
}
}
// set up uart on pins 8/9, with an RX handler
uart <- hardware.uart1289;
uart.configure(9600, 8, PARITY_NONE, 1, NO_CTSRTS, rx);
`
I have the code shown below running using the Impee-Kelly reference design.
When running agent code Xively does not updated with each \r
. I suspect its running to fast for Xivley to keep up?
I get the “Messages trottled” message on the IDE.
Is there a good way to slow things down. Or do I have something else hosed.
Device code:
imp.configure(“Cloud Serial Cable”,[],[]);
line <- “”;
function rx() {
local d = uart.read();
while (d >= 0) {
if (d >= ' ') line += d.tochar();
if (d =='\\r') {
// server.log("UDA message: " + line);
agent.send("Xively", line); //send string to agent
line="";
}
d = uart.read();
}