Export on os x not working

edited November 2013 in Using Processing

Hey, I have this code for adalight. It work when I play it in processing, but when I export it like app its not working anymore. Where is problem? Thanks for support :)

import processing.serial.*;

int N_LEDS = 25; // Max of 65536
byte[] buffer = new byte[6 + N_LEDS * 3];
Serial myPort;
int    i, hue1, hue2, bright, lo, r, g, b, t, prev, frame = 0,x;
long   totalBytesSent = 0;
float  sine1, sine2;

void setup()
{
  noLoop();

  myPort = new Serial(this, Serial.list()[3], 115200);

  buffer[0] = 'A';                                // Magic word
  buffer[1] = 'd';
  buffer[2] = 'a';
  buffer[3] = byte((N_LEDS - 1) >> 8);            // LED count high byte
  buffer[4] = byte((N_LEDS - 1) & 0xff);          // LED count low byte
  buffer[5] = byte(buffer[3] ^ buffer[4] ^ 0x55); // Checksum

  sine1 = 0.0;
  hue1  = 0;
  prev  = second(); // For bandwidth statistics

  for (;;) {
    sine2 = sine1;
    hue2  = hue1;

    for (i = 6; i < buffer.length; ) {
      lo = hue2 & 255;
      buffer[i++] = byte((172 * 50) / 255);
      buffer[i++] = byte((172 * 50) / 255);
      buffer[i++] = byte((172 * 50) / 255);

      hue2  += 40;
      sine2 += 0.3;
    }

    hue1   = (hue1 + 4) % 1536;
    sine1 -= .03;

    myPort.write(buffer);
    totalBytesSent += buffer.length;
    frame++;

    if ((t = second()) != prev) {
      print("Average frames/sec: ");
      print(int((float)frame / (float)millis() * 1000.0));
      print(", bytes/sec: ");
      println(int((float)totalBytesSent / (float)millis() * 1000.0));
      prev = t;
    }
  }  
}
Tagged:

Answers

  • Can you be more specific? E.g. is it running but not giving the result you expect, or is it not running at all?

  • When I double click on exported app its open application but not working, not doing what it do when I play it from processing.

  • I'm having the same problem. A sketch using the Serial library works from the IDE, but not from an exported standalone app. It seems to freeze at the first Serial call (Serial.list, "new Serial" etc.) I tried exporting one of the example sketches (SerialCallResponse) and get the same behavior: works from IDE, hangs on Serial.list in standalone.

    I'm using Processing 2.1 on OSX 10.8.5

  • I think you may have to put a copy of the serial library into the exported folder. It's worth a try

  • The serial.jar file got exported into the standalone app, as did the .jar files for other libraries I'm using. The other libs work fine, only Serial misbehaves. Is there something besides the .jar that could be missing? Is the RXTX code baked into the .jar?

    I've duplicated this issue using the SerialCallResponse example on a couple macs with fresh installs of Processing.

    Thanks!

  • Here is a minimal example:

    import processing.serial.*;
    String ports[];
    
    void setup() {
      size(256,256);
      ports = Serial.list();
    }
    
    void draw() {
      text(ports[0],20,50);
    }
    
  • I found a solution. I had to copy the file "libjSSC-2.6.jnilib" from the processing app to the exported app. I think this is a bug in the export.

    Copy: Processing.app->Contents->Java->modes->java->libraries->serial->library->macosx->libjSSC-2.6.jnilib

    To: YourApp->Contents->MacOS->libjSSC-2.6.jnilib

    michalcerny, could you try this and see if it works for you also? To see the contents of an app, right-click it and "Show Package Contents"

  • Omg it works!! Thanks for that :)

Sign In or Register to comment.