/** * Receive scantron info from scanmark ES2010 in 5320 emulation mode * * Serial settings: * 9600, 8, N, 2 * */ import processing.serial.*; Serial myPort; // Create object from Serial class int val; // Data received from the serial port //byte[] inBuffer = new byte[53*8]; int numrows = 0; int numread = 0; void setup() { size(1100, 850); // I know that the first port in the serial list on my mac // is always my FTDI adaptor, so I open Serial.list()[0]. // On Windows machines, this generally opens COM1. // Open whatever port is the one you're using. String portName = Serial.list()[0]; //myPort = new Serial(this, portName, 9600, 'N', 8, 2.0); myPort = new Serial(this, portName, 9600); background(255); } void draw() { while (myPort.available () > 0) { //inBuffer = myPort.readBytes(); byte[] inBuffer = new byte[53*8]; //numread = myPort.readBytes(inBuffer); numread = myPort.readBytesUntil(13, inBuffer); if (numread > 0) { String myString = new String(inBuffer); println(myString); // println(inBuffer.length); // println(numread); numrows=numread/8; println(str(numrows)+" rows on form"); background(255); drawForm(inBuffer); } } // while (myPort.available() > 0) { // int lf = 10; // int cr = 13; // int numread; // //Expand array size to the number of bytes you expect: // numread = myPort.readBytesUntil(lf, inBuffer); // if (inBuffer != null) { // String myString = new String(inBuffer); // println(myString); // } // } } void drawForm(byte[] inBuffer) { stroke(0); //fill(0); for (int i=0; i>b)==0); println(binary((curritem>>b)&0x01)); if((((curritem>>b)&0x01))>0) { fill(0); } else { noFill(); } ellipse(x, (height-y-100), 10, 10); } } //delay(1000); }