import processing.serial.*; Serial myPort; // The serial port int data; // strings from input text file String lines[] = { "" }; int pos = 0; static int LF = 10; boolean done=false; void setup() { // serial init println(Serial.list()); // I know that the first port in the serial lines on my mac // is always my Keyspan adapter, so I open Serial.lines()[0]. // Open whatever port is the one you're using. myPort = new Serial(this, Serial.list()[1], 4800); // graphics init size(200, 200); // read speech transcript from SC log file loadText(); // init receipt printer // myPort.write(27); // myPort.write("@"); // form-feed 5 lines myPort.write(27); myPort.write(100); myPort.write(5); }; void draw() { sendNextLine(); // delay(2000); if (done) { myPort.stop(); exit(); } } void sendNextLine() { String curr = lines[pos]; println("\t"+curr.substring(14)); myPort.write(curr.substring(14)); myPort.write(LF); myPort.write(LF); pos++; if (pos>=lines.length-1) { println("reached the end"); // advance five lines // form-feed 10 lines myPort.write(27); myPort.write(100); myPort.write(10); // cut paper myPort.write(27); myPort.write("i"); done=true; } } void loadText() { lines = loadStrings("/Users/rtwomey/Sounds/SpeechFiles/logs/110604_160254.txt"); println("there are " + lines.length + " lines in the file."); pos = 0; }