Go Down

Topic: serial connection in processing (ubuntu) (Read 3651 times) previous topic - next topic


I'm trying to make a graph of the serial data my arduino is sending back to the computer via processing. I realize this is a question to be asked on the processing board, but frankly the processing message board seems a little dead. The arduino is singing happily over serial port "/dev/ttyACM1" in the arduino IDE environment. However nothing I try will get any sort of connection in processing. In fact the serial.list() command doesn't even return any serial connections at all. There are no compile errors. Here is a basic program that isn't working. It simply doesnt return anything!

Code: [Select]

import processing.serial.*;

Serial myPort;        // The serial port
int xPos = 1;         // horizontal position of the graph

void setup () {
 // set the window size:
 size(400, 300);        

 // List all the available serial ports
 myPort = new Serial(this, "/dev/ttyACM1", 9600);
 // don't generate a serialEvent() unless you get a newline character:
 // set inital background:
void draw () {
 // everything happens in the serialEvent()

void serialEvent (Serial myPort) {
 // get the ASCII string:
 String inString = myPort.readStringUntil('\n');

 if (inString != null) {
   // trim off any whitespace:
   inString = trim(inString);
   // convert to an int and map to the screen height:
   float inByte = float(inString);
   inByte = map(inByte, 0, 1023, 0, height);

   // draw the line:
   line(xPos, height, xPos, height - inByte);

   // at the edge of the screen, go back to the beginning:
   if (xPos >= width) {
     xPos = 0;
     // increment the horizontal position:

before people chew me out for explicitly putting "/dev/ttyACM1" in there, I have tried all the variations of serial.list()[0] etc... to no avail. Any help would be appreciated.


If it makes you feel any better, I have an extremely similar problem, maybe the exact same problem. Under Ubuntu 9, the arduino IDE properly detects the /dev/ttyACM0 port created when I plug in the arduino, but processing apps don't see /dev/ttyACM0 and therefore can't ever talk to the arduino. I downloaded the latest versions of processing and arduino yesterday to try them out under Ubuntu; so far, no-go for processing.

The only difference between your problem and mine is that my processing apps DO see my USB mouse port, /dev/ttyS0. Of course, you can't connect to that port (it's in use) and even if you could, it's not where the arduino is anyway (as verified in the arduino IDE and by dmesg upon connection of the arduino.)

SO, it would be really cool if someone could provide us some leads about where to look to solve this problem. :-)


FWIW, I verified that both the arduino app and the processing app are using the same version of the RXTX library. Their startup scripts do find different versions of the java libraries, though, since processing ships with its own, I am wondering if some of the JNI stuff processing uses is out-of-spec for the ubuntu box...


I appreciate the tip. Ill look into it more and see if I can figure anything out, but if anyone knows anything or comes up with a fix I know at least a few people that would sure appreciate it!


Santa brings me a arduino Uno and I have exactly the same problem...
in arduino (soft) I can see ttyACM0 and use it, blink example, etc...
in processing the Arduino.list() function only returns ttyS0


Probably we should all say "we have this problem" at the Processing board and perhaps the Ubuntu boards, as, strictly speaking, it turns out this is probably a processing problem and not an arduino problem. :-/


I tried to replace the "processing-1.2.1/libraries/serial/library/librxtxSerial.so" and "RXTXcomm.jar" by the arduino ones "/home/viande/arduino/arduino-0022/lib/librxtxSerial.so" and "RXTXcomm.jar"

and it works !

Go Up