Make a Simple GUI and Displaying Serial Arduino data got NullPointerException

hello @glv and @RichardDL thank you for triggering me, I will move on to the next stage of my project.
I think I can solve the nullpointer problem that I encountered in the previous code. Here are the results and the latest code that I made

//Simple Dyno Logger

import processing.serial.*;
import controlP5.*;


Serial serial;
ControlP5 cp5;

String val;

int speed = 9600;
String portName;
String filename = "contoh";
Table table;

//Variabel Date
int d = day();
int m = month();
int y = year();

//Variable Time
int h = hour();
int min = minute();
int s = second();

//Variable value from serial
float rpm1;
float rpm2;
float torsi;
float daya;
float load;
float tinlet;
float texhaust;
float temp;
float hum;

//variable panjang lengan dyno
float l = 0.152;


void setup() {
  size(600, 400);
  cp5 = new ControlP5(this);

  //make a button for CP
  cp5.addButton("refresh")
    .setPosition(110, 0)
    .setSize(50, 30);
  cp5.addButton("openPort")
    .setPosition(170, 0)
    .setSize(50, 30);
  cp5.addButton("closePort")
    .setPosition(230, 0)
    .setSize(60, 30);
  cp5.addButton("ledOn")
    .setPosition(300, 0)
    .setSize(50, 30);
  cp5.addButton("ledOff")
    .setPosition(360, 0)
    .setSize(50, 30);
  cp5.addScrollableList("comlist")
    .setPosition(0, 0)
    .setSize(100, 150)
    .setBarHeight(30)
    .setItemHeight(30).close();

  //Buat table penyimpanan data
  table = new Table();

  table.addColumn("Date", Table.STRING);
  table.addColumn("Nomor", Table.INT);
  table.addColumn("Time", Table.STRING);
  table.addColumn("RPM Roller", Table.FLOAT);
  table.addColumn("RPM Engine", Table.FLOAT);
  table.addColumn("Torsi (N.m)", Table.FLOAT);
  table.addColumn("Daya (HP)", Table.FLOAT);
  table.addColumn("Load (Kg)", Table.FLOAT);
  table.addColumn("Tinlet (°C)", Table.FLOAT);
  table.addColumn("Texhaust (°C)", Table.FLOAT);
  table.addColumn("Temp (°C)", Table.FLOAT);
  table.addColumn("Humidity (%)", Table.FLOAT);

  TableRow newRow = table.addRow();

  newRow.setString("Date", str(d) + "/" + str (m) + "/" + str(y));
}

void refresh() {
  String list[] = Serial.list();
  cp5.get(ScrollableList.class, "comlist").addItems(list);
}
void comlist(int n) {
  portName = Serial.list()[n];
}
void openPort() {
  serial = new Serial(this, portName, speed);
}
void closePort() {
  serial.stop();
}
void ledOn() {
  serial.write('n');
}
void ledOff() {
  serial.write('f');
}

void draw() {
  background(120);

  //Take data from serial
  if (serial != null) {
    if (serial.available() > 0)
    {
      String val = serial.readStringUntil('\n');

      if (val != null)
      {
        val = val.trim();
        String [] data = split(val, ',');
        print("data : ");
        if (data.length >= 7)
        {
          printArray (data);
        }
        rpm1 = float(data[0]);
        rpm2 = float(data[1]);
        load = float(data[2]);
        tinlet = float(data[3]);
        texhaust = float(data[4]);
        temp = float(data[5]);
        hum = float(data[6]);

        //Data Torsi dan Daya
        torsi = (rpm2 * l)/100;
        daya  = (rpm2 * torsi)/100;
      }

      //Make rows for each data
      TableRow newRow = table.addRow();

      newRow.setInt("Nomor", table.getRowCount());
      newRow.setString("Time", str(h) + ":" + str(min) + ":" + str(s));
      newRow.setFloat("RPM Roller", rpm1);
      newRow.setFloat("RPM Engine", rpm2);
      newRow.setFloat("Torsi (N.m)", torsi);
      newRow.setFloat("Daya (HP)", daya);
      newRow.setFloat("Load (Kg)", load);
      newRow.setFloat("Tinlet (°C)", tinlet);
      newRow.setFloat("Texhaust (°C)", texhaust);
      newRow.setFloat("Temp (°C)", temp);
      newRow.setFloat("Humidity (%)", hum);

      // saveTable(table, "data/new2.csv");
    }

    //make a rect as a value box
    stroke(255);
    fill(0, 50, 100);
    rect(10, 80, 40, 40, 4);
    rect(60, 160, 40, 40, 4);
    rect(110, 80, 40, 40, 4);
    rect(160, 160, 40, 40, 4);
    rect(210, 80, 40, 40, 4);
    rect(260, 160, 40, 40, 4);
    rect(310, 80, 40, 40, 4);
    rect(360, 160, 40, 40, 4);
    rect(410, 80, 40, 40, 4);

    //make a lable for each value
    PFont f = createFont ("Georgia", 15);
    textFont (f);
    text("Rpm Roll", 0, 70);
    text("Rpm Engine", 100, 70);
    text("Torsi (N.m)", 200, 70);
    text("Daya (HP)", 300, 70);
    text("Load (Kg)", 400, 70);
    text("Tinlet (°C)", 50, 150);
    text("Texhaust (°C)", 150, 150);
    text("Temp. (°C)", 250, 150);
    text("Humidity (%)", 350, 150);

    //write value on rect
    int x = 105;
    int y = 185;
    PFont t = createFont ("arial", 15);
    textFont (t);
    fill(255);
    text(rpm1, 15, x);
    text(rpm2, 115, x);
    text(torsi, 220, x);
    text(daya, 320, x);
    text(load, 420, x);
    text(tinlet, 70, y);
    text(texhaust, 170, y);
    text(temp, 270, y);
    text(hum, 370, y);

    //Write SIMPLE DYNOTEST
    stroke(255);
    textFont(f);
    textSize(60);
    fill(255, 255, 255);
    text("SIMPLE DYNOTEST", 20, 300);
  }
}

image