Pages: [1]   Go Down
Author Topic: Processing  (Read 1013 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi.
When I try to run any processing code that involves serial communication I get the error:
 WARNING:  RXTX Version mismatch
   Jar version = RXTX-2.2pre1
   native lib Version = RXTX-2.2pre2

What can I do to fix this?

Thanks.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I try to run any processing code that involves serial communication I get the error:
 WARNING:
Error != Warning.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I get the warning. Then I get a whole bunch of errors.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Sorry, I get the warning.
Which can generally be ignored.

Quote
Then I get a whole bunch of errors.
Most likely having nothing to do with the warning, not mentioned in your first post, and not shown.

Do you really want help?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is my code. It is the example that comes with processing.
Code:
import processing.serial.*;

int bgcolor;      // Background color
int fgcolor;      // Fill color
Serial myPort;                       // The serial port
int[] serialInArray = new int[3];    // Where we'll put what we receive
int serialCount = 0;                 // A count of how many bytes we receive
int xpos, ypos;              // Starting position of the ball
boolean firstContact = false;        // Whether we've heard from the microcontroller

void setup() {
  size(256, 256);  // Stage size
  noStroke();      // No border on the next thing drawn

  // Set the starting position of the ball (middle of the stage)
  xpos = width/2;
  ypos = height/2;

  // Print a list of the serial ports, for debugging purposes:
  println(Serial.list());

  // 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);
}

void draw() {
  background(bgcolor);
  fill(fgcolor);
  // Draw the shape
  ellipse(xpos, ypos, 20, 20);
}

void serialEvent(Serial myPort) {
  // read a byte from the serial port:
  int inByte = myPort.read();
  // if this is the first byte received, and it's an A,
  // clear the serial buffer and note that you've
  // had first contact from the microcontroller.
  // Otherwise, add the incoming byte to the array:
  if (firstContact == false) {
    if (inByte == 'A') {
      myPort.clear();          // clear the serial port buffer
      firstContact = true;     // you've had first contact from the microcontroller
      myPort.write('A');       // ask for more
    }
  }
  else {
    // Add the latest byte from the serial port to array:
    serialInArray[serialCount] = inByte;
    serialCount++;

    // If we have 3 bytes:
    if (serialCount > 2 ) {
      xpos = serialInArray[0];
      ypos = serialInArray[1];
      fgcolor = serialInArray[2];

      // print the values (for debugging purposes only):
      println(xpos + "\t" + ypos + "\t" + fgcolor);

      // Send a capital A to request new sensor readings:
      myPort.write('A');
      // Reset serialCount:
      serialCount = 0;
    }
  }
}
When I run it I get the errors:
Exception in thread "Animation Thread" java.lang.RuntimeException:
Error inside Serial.<init>()
   at processing.serial.Serial.errorMessage(Serial.java:591)
   at processing.serial.Serial.<init>(Serial.java:151)
   at processing.serial.Serial.<init>(Serial.java:105)
   at SerialCallResponse.setup(SerialCallResponse.java:64)
   at processing.core.PApplet.handleDraw(PApplet.java:1608)
   at processing.core.PApplet.run(PApplet.java:1530)
   at java.lang.Thread.run(Thread.java:680)

Thanks.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
When I run it I get the errors:
Exception in thread "Animation Thread" java.lang.RuntimeException:
Error inside Serial.<init>()
This tells me that this code:
Code:
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);
failed.

What was printed by this code?
Code:
  println(Serial.list());

Do you have the Arduino connected? Is the Serial Monitor open? Are you able to upload sketches to the Arduino?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The processing program now works but when I try to upload a program to the Arduino I get the error: Programmer not responding even though the arduino's power is on and the right serial port is selected.

How do I fix this?

Thanks.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The processing program now works
As in is successfully talking to the Arduino? Or as in starts without throwing an exception?

Quote
but when I try to upload a program to the Arduino I get the error: Programmer not responding even though the arduino's power is on and the right serial port is selected.
With the Processing application running? Or shut down? What is attached to the Arduino? Where?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Processing program starts without throwing an except. When I go to upload the program to the arduino the processing program is not running and the arduino is connected to my mac via the usb cable.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 611
Posts: 49092
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
The Processing program starts without throwing an except.
I suppose that that is one definition of "working".

Quote
the arduino is connected to my mac via the usb cable.
Doesn't answer the question of what, if anything, is attached to the Arduino.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 31
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry, I have a led attached to pin 13. But thats all.
Logged

Pages: [1]   Go Up
Jump to: