Hi.
I am trying to create a library from an sdk (caiosdevice) Casio.
I am using SLC and I have the source code of a class called LineDisplay.java
This is the code.
Compile correctly, but when I try to use it from b4a, I get an error of Null Pointer in the method Open
This is the code:
The error occurs in line:
nRes = casioVisor.open( casioVisor.DEVICE_MODE_COMMON, casioVisor.DEVICE_HOST_LOCALHOST )
Null Pointer Exception.
Someone be so kind to help me.
A greeting and thanks.
I am trying to create a library from an sdk (caiosdevice) Casio.
I am using SLC and I have the source code of a class called LineDisplay.java
This is the code.
B4X:
package axinfor.casiosdk.com;
import android.app.Application;
import anywheresoftware.b4a.BA;
import anywheresoftware.b4a.BA.*;
import anywheresoftware.b4a.AbsObjectWrapper;
import jp.co.casio.caios.framework.device.*;
@ShortName("LineDisplay")
@DependsOn(values = { "caiosdevice" })
/*
LineDisplay
Created with Basic4Android Library Generator - by XverhelstX
Line Display class enables the line display (back display) to be indicated.
The line display device has display area of 20 lines of 20 half-byte characters.
*/
public class LineDisplay extends AbsObjectWrapper<LineDisplay> {
public static final int DEVICE_MODE_COMMON = 0x01;
public static final int DEVICE_MODE_EXCLUSIVE = 0x02;
public static final String DEVICE_HOST_LOCALHOST = "localhost";
public static final int LCD_CONTROL_NORMAL = 0x00;
public static final int LCD_CONTROL_HEIGHT = 0x01;
public static final int LCD_CONTROL_REVERSE = 0x02;
public static final int LCD_BACKLIGHT_OFF = 0x00;
public static final int LCD_BACKLIGHT_GREEN = 0x01;
public static final int LCD_BACKLIGHT_WHITE = 0x02;
public static final int LCD_BACKLIGHT_EMEGREEN = 0x03;
public static final int LCD_DEFAULT_MODE_NORMAL = 0x00;
public static final int LCD_DEFAULT_MODE_ANK = 0x01;
public static final int LCD_DEFAULT_MODE_JAPAN = 0x02;
public static final int LCD_DEFAULT_MODE_CHINA = 0x03;
public static final int LCD_DEFAULT_CODE_NORMAL = 0x00;
public static final int LCD_DEFAULT_CODE_AMERICA = 0x01;
public static final int LCD_DEFAULT_CODE_FRANCE = 0x02;
public static final int LCD_DEFAULT_CODE_GERMAN = 0x03;
public static final int LCD_DEFAULT_CODE_ENGLAND = 0x04;
public static final int LCD_DEFAULT_CODE_DENMARK = 0x05;
public static final int LCD_DEFAULT_CODE_SWEDEN = 0x06;
public static final int LCD_DEFAULT_CODE_ITALY = 0x07;
public static final int LCD_DEFAULT_CODE_SPAIN = 0x08;
public static final int LCD_DEFAULT_CODE_JAPAN = 0x09;
public static final int LCD_DEFAULT_CODE_NORWAY = 0x0A;
public static final int LCD_DEFAULT_CODE_DENMARK2 = 0x0B;
public static final int LCD_DEFAULT_TABLE_NORMAL = 0x00;
public static final int LCD_DEFAULT_TABLE_USA = 0x01;
public static final int LCD_DEFAULT_TABLE_JAPAN = 0x02;
public static final int LCD_DEFAULT_TABLE_EURO = 0x03;
public static final int LCD_DEFAULT_TABLE_ARABIC = 0x03;
public static final int LCD_SLEEP_OFF = 0x01;
public static final int LCD_SLEEP_ON = 0x01;
private BA ba;
private String eventName;
private LineDisplay linedisplay;
public void Initialize(final BA ba) {
this.ba = ba;
this.linedisplay = new LineDisplay();
}
public LineDisplay getLineDisplay() {
return this.linedisplay;
}
public void setLineDisplay(LineDisplay linedisplay) {
this.linedisplay = linedisplay;
}
/*
Opens a device and controls it exclusively
int open(int mode, String hostname)
*/
public int open(int arg0, String arg1) {
return this.linedisplay.open(arg0, arg1);
}
/*
Closes a device.
int close(void)
*/
public int close() {
return this.linedisplay.close();
}
/*
Clears line display indication.
int clear(void)
*/
public int clear() {
return this.linedisplay.clear();
}
/*
Enables line display indication.
When assigned character number is less than the display area, spaces are filled in the remaining area.
If assigned character number exceeds display area, the exceeded characters are cancelled.
int setText(byte[] line1, byte[] line2, int control)
Byte[] line1: Character string of the first display line: 20 bytes.
Byte[] line2: Character string of the second display line: 20 bytes.
int control: Assigns display control (multiple assignment available).
*/
public void setText(byte[] arg0, byte[] arg1, int arg2) {
this.linedisplay.setText(arg0, arg1, arg2);
}
/*
Assigns backlight color.
int setBacklight(int backlightStatus)
Sets contrast value: 0 to 255
*/
public void setBacklight(int arg0) {
this.linedisplay.setBacklight(arg0);
}
/*
Assigns contrast value.
int setContrast(int contrastStatus)
*/
public void setContrast(int arg0) {
this.linedisplay.setContrast(arg0);
}
/*
Registers the initial value at power recovery.
setPowerDefault(int mode, int code, int table)
*/
public void setPowerDefault(int arg0, int arg1, int arg2) {
this.linedisplay.setPowerDefault(arg0, arg1, arg2);
}
/*
Sleep control. Turns the backlight on or off. The ON status depends on the set status of the backlight.
setSleep(int mode)
*/
public void setSleep(int arg0) {
this.linedisplay.setSleep(arg0);
}
/*
Sets character code type, international character, and character code table by discriminating the locale.
setCurrentCodepage()
*/
public void setCurrentCodepage() {
this.linedisplay.setCurrentCodepage();
}
}
Compile correctly, but when I try to use it from b4a, I get an error of Null Pointer in the method Open
This is the code:
B4X:
Sub ButtonVisor_Click
Dim casioVisor As LineDisplay
Dim nRes As Long
Dim cLinea1, cLinea2 As String
Dim byteConv As ByteConverter
Dim bLinea1(20) As Byte
Dim bLinea2(20) As Byte
casioVisor.Initialize
nRes = casioVisor.open( casioVisor.DEVICE_MODE_COMMON, casioVisor.DEVICE_HOST_LOCALHOST )
casioVisor.clear
cLinea1 = "hello"
cLinea2 = "world"
bLinea1 = byteConv.StringToBytes(cLinea1, "UTF8")
bLinea2 = byteConv.StringToBytes(cLinea2, "UTF8")
casioVisor.setText( bLinea1, bLinea2, casioVisor.LCD_CONTROL_NORMAL)
casioVisor.close
End Sub
The error occurs in line:
nRes = casioVisor.open( casioVisor.DEVICE_MODE_COMMON, casioVisor.DEVICE_HOST_LOCALHOST )
Null Pointer Exception.
Someone be so kind to help me.
A greeting and thanks.