In one UART, out another.
RShirley
Posts: 12
Hi folks,
I have been trying to get caracters out of one UART, parse and format them, and send them out another UART with no success. The toString always causes me to run out of memory. Any suggestions on how best to do this. The input is time/date from a GPS unit, in ASCII ("09252005011200.000"). I want to sent to a LCD display "09/25/2005, 01:12:00.000".
Thanks, Russell
I have been trying to get caracters out of one UART, parse and format them, and send them out another UART with no success. The toString always causes me to run out of memory. Any suggestions on how best to do this. The input is time/date from a GPS unit, in ASCII ("09252005011200.000"). I want to sent to a LCD display "09/25/2005, 01:12:00.000".
Thanks, Russell
Comments
char[noparse]/noparse buf = new char[noparse][[/noparse]25];
int index;
// input· 18 chars 09252005011200.000
// output 24 chars 09/25/2005, 01:12:00.000
//·················· 2· 5··· 9·· D· G
//assume start of message
index = 0;
while (index < 24) {
· while (!rx.byteAvailable()) {
··· //do other stuff
· }
· buf[noparse][[/noparse]index++] = rx.receiveByte();
· switch (index) {
··· case 2:
··· case 5:· buf[noparse][[/noparse]index++] = '/';
············ break;
··· case 9:· buf[noparse][[/noparse]index++] = ',';
············ buf[noparse][[/noparse]index++] = ' ';
············ break;
··· case 13:
··· case 16: buf[noparse][[/noparse]index++] = ':';
············ break;
··· default:
· }
}
buf[noparse][[/noparse]24] = 0; //closing zero, optional
tx.writeString(buf,24,0); //write char array, 24 bytes, start at offset 0
regards peter
Post Edited (Peter Verkaik) : 9/26/2005 4:48:47 PM GMT
I get an error on the line "buf[noparse][[/noparse]index++] = rx.receiveByte();"
Left hand "char" not compatible with right hand "int".
What did I do wrong?
Thanks, Russell
buf[noparse][[/noparse]index++] = (char)rx.receiveByte();
regards peter
I finally got my project complete and functional. Thanks for all your help on this and other troubles i have had.
Russell