|
Author |
Topic: Syntax error? GPS Serial fed to screen as text () (Read 288 times) |
|
reg
|
Syntax error? GPS Serial fed to screen as text ()
« on: Dec 4th, 2004, 6:25pm » |
|
Hi. well I've been fiddling with processing for a while, and this particular problem for ages so any help appreciated. I'm posting here as my less than superior coding skills mean it's more likely a syntax than a serial issue, but... Aim : read some serial in (from Garmin eTREX via USB serial Adapter), write it back our to the screen as text. Problem 1: I get intermittent Arrary out of Bound errors (relating to BFont.text?). They are less frequent if I truncate the sentences taken from the GPS. But they happen, and about a third of the time they bring down the whole OS (Blue Screen of Death). Not sure if it's my syntax, the serial coms, or something else. Problem 2: Normally I stop the serial events with a mousePressed event (see code). However, if I forget, and just stop the App, if I run it again I ALWAYS get the error message below. I also tried Glenn's original code, but sometimes get EmptyString error, so started with a stripped down version, and ran into this problem. Any pointers TC, r //--------CODE-------------------------// / GPS Serial ... problems writings strings back to screen as text(). // Stripped down version of code posted by Glen Murphy, glen@glenmurphy.com //seems to work now I have reset the nmea string after each sentence, before was accumulating data. BFont metaBold; String outputSentence = ""; String nmea = ""; boolean speak = false; void setup() { size (800,240); background (0); outputSentence = ""; nmea = ""; metaBold = loadFont("Meta-Bold.vlw.gz"); speak = false; beginSerial(4800); } void loop() { if (speak == true) { background (0); textFont(metaBold, 22); text(outputSentence, 25, 25); text(outputSentence.length(), 25, 50); //text(nmea.length(), 25, 50); speak = false; } delay(10); } void serialEvent() { processNMEA((char)serial); } void mousePressed () { endSerial (); // Stop the serial port when the mouse is pressed background (255,0,0); textFont(metaBold, 22); text("stopped safely.", 25, 25); } void processNMEA(char nmeaIn) { nmea += nmeaIn; if(nmeaIn == '\n') { outputSentence = nmea; speak = true; nmea = ""; } /* if (nmea.length()>35){ outputSentence = nmea; speak = true; //println("truncated..."); nmea = ""; } */ } //-------ERROR MESSAGE--------------// Error while running applet.java.lang.ArrayIndexOutOfBoundsException: 167 at BFont.text (BFont.java:523) at BFont.text(BFont.java:670) at BGraphics.text(BGraphics.java:4410) at BApplet.text(BApplet.java:2833) at Temporary_1026_9401.loop(Temporary_1026_9401.java:27) at BApplet.nextFrame(BApplet.java:434) at BApplet.run(BApplet.java:369) at java.lang.Thread.run (Thread.java:536) //----------SYSTEM-----------// proce55ing 68, winXPHome, java 1.4.2 p.s. Anyone know where to get 69 from? Also need a way to solve splitStrings() errors and loadVideo() - hogs system resources - that I understand are fixed in 69.
|
|
|
|
|