After testing on x86 PC exported arm64 program does not run on Pi 4

I have a program written in Processing 3.x, which I have tested on an x86 PC, after exporting the program without bundling Java. The same process also exported an arm64 and armv6hf version. I tested the linux64 version with OpenJDK 11.x on my PC and it works OK.

When I run the arm64 or the armv6hf program on a Raspberry Pi with OpenJDK 11.x installed, my 1000 x 1000 pixel screen opens up but its just blank. I don’t get my graphics, even though the /data folder has the graphics PNG files.

I suspect this has something to do with the serial interface, on which data is streaming in from a data source on a RasPi Pico. But then, on the PC, if there’s a serial interface missing, the Processing program just hangs. On the RasPi 4, the screen is opening up sans graphics but nothing is locking up. So it just could be something else…

Is there a way I can scan the serial interfaces and select an interface programmatically?

My Processing code, Arduino Pico code and graphics files are as under:


RadarBeam

Processing code:

import processing.serial.*; //importing serial library 
PImage beam; // to store meter needle image
PImage display; // to store meter image 
PImage mapTile; // store map tile
float increment;
float previousAzimuth = 0;
float currentAzimuth = 0;
float plottedAzimuth;
String azimuthString;
int nl = 10;
int inByte; //to store incomming value from serial port
int reading=0; //to store mapped inByte value
Serial azimuth; //naming our serial port as "arduino"

void setup(){ //only runs one time when program starts
  background(0); //making background color as black
  size(1000, 1000); //output window size 1000 x 1000 pixel
  //fullScreen(); //output window size full screen
  beam=loadImage("RadarBeam.png"); //loading timebase image
  display=loadImage("RadarDisplay.png"); //loading radar rose image
  mapTile=loadImage("Centre_Delhi.png"); //loading map tile
  //beam.resize(66, 66); //resizing needle image to fit our meter
  //printArray(Serial.list()); //listing serial port to find the port in which arduino is connected
  azimuth = new Serial(this, Serial.list()[0], 115200); //initializing port, in my case arduino is no.4 in the list
  
}

void draw(){ //this will loop by 60 frame per second by default , frame rate can be changed by frameRate() function
  if (azimuth.available()>0){ //checking whether there is incomming serial values
    azimuthString = azimuth.readStringUntil(nl);
    if (azimuthString != null){
      currentAzimuth = float(azimuthString);
    }
    //currentAzimuth=azimuth.read(); //storing incoming values to variable inByte
    if (currentAzimuth != previousAzimuth){
      plottedAzimuth = currentAzimuth;
      previousAzimuth = currentAzimuth;
    }
    else{
      plottedAzimuth = previousAzimuth;
    }
  }
  
  imageMode(CENTER); //draw image using center mode
  //image(mapTile, width/2, height/2);
  tint(255,255);
  image(display, width/2, height/2); //drawing meter image
  tint (255,128); //first param is tint color. second param is alpha channel
  image(mapTile, width/2, height/2);
  pushMatrix(); //saving current transformation matrix onto the matrix stack
  imageMode(CORNERS); //draw image using corners mode
  translate((width/2)+0, (height/2)+2); //translating "(width/2)+2, (height/2)+15" to "0,0"
  //rotate(((HALF_PI)-19.69)+ plottedAzimuth); //rotation needle image to position to zero in meter image
  rotate(-(HALF_PI) + radians(currentAzimuth));
  image(beam, 0, 0, 350, 2); //drawing needle image
  popMatrix();//removing the current transformation matrix off the matrix stack
  
  println(currentAzimuth);
}



Arduino code:

int azimuth = 0;

void setup() {
  Serial.begin(115200);
}

void loop() {
  for(int i=0; i<360; i++){
    //Serial.write(i);
    Serial.println(i);
    delayMicroseconds(28000);
  }
}

Hi @rajiv.tctech, I have a sketch that I use on PC and Pi, want to use exactly the same code, so I put the name of the Arduino device COM4 or ttyAMA0 in a data file (ArdPort.dat). Read that with loadStrings at sketch start. On he Pi you could use a bash script file to do ‘ls /dev’, text processing to find the Arduino port name, write that into the dat file, then run the processing sketch. (Might be possible to do all that from within Processing, but I don’t know.)

1 Like

Thanks @RichardDL. Can you share your code here?

The contents of the dat file is simply text (I’d forgotten that I’d put window dimensions in there) :

PortName,COM9
Width,1500
Height,800

And the code to read it:

String sGetOption(String Option)
{
  /* read through the options file,
  find the one requested,
  return the value */
 
  String[] lines;
  String[] parts;
  String retstr;
 
  int index = 0;

  retstr = "";
  lines = loadStrings("Humidity_Chart.dat");
  for (index = 0; index < lines.length; index++)
  {
    parts = split(lines[index], ',');
    if (parts[0].equals(Option)){retstr = parts[1];}
 }
 
  return retstr;
}

int iGetOption(String Option)
{
    int iRetVal = 0;
    String sRetVal;
    sRetVal = sGetOption(Option);
    if (!sRetVal.equals("")){iRetVal = int(sRetVal);}
    return iRetVal;
}

Setup...
PortName = sGetOption("PortName");

Settings...
int opt_wide = iGetOption("Width");
int opt_hite = iGetOption("Height");

Draw...
(conditional)
myPort = new Serial(this, PortName, 9600);
1 Like

Thank you! It’s a neat solution…