Skip to content
This repository was archived by the owner on Jan 11, 2024. It is now read-only.
This repository was archived by the owner on Jan 11, 2024. It is now read-only.

Serial Port won't open #544

Description

@davideserra

Hi everyone,
I'm in migration phase of my project from Raspberry PI 3B+ on Raspberry 4B due "low System Memory" error in previous version. I buyed Raspberry PI4 8 Gbytes Version, with a 64 bit Operating System ad I migrate my NetBeans project. The appliance is a Radio Telescope with 1 Raspebrry PI4 as central Unit connected to 4 Arduino Due platform. In the main unit I has written in Java (with NetBeans) a main program that comunicate with the Arduino on COM port "/dev/ttyACMxxx" for read radio data and pilot he azimuth and altitude rotor. The oldest version works fine (until the memory problem). I download 64 bit version of pi4j, then set the code as follow:
Rotorconfig = new SerialConfig();
Rotorconfig.device(RotorPortName);
Rotorconfig.baud(Baud._57600);
Rotorconfig.dataBits(DataBits._8);
Rotorconfig.parity(Parity.NONE);
Rotorconfig.stopBits(StopBits._1);
Rotorconfig.flowControl(FlowControl.NONE);
RotorPort.open(Rotorconfig);

I have also a listener to serial event but this happen after the port open (as like as previous version)
Rotor = new RotorControl(RotorPortName);
Rotor.RotorPort.addListener((SerialDataEventListener) new SerialDataEventListener() {
@OverRide
public void dataReceived(SerialDataEvent sde) {
String Data = "";
try
{
Data = sde.getAsciiString();
int AziPos = Data.indexOf("AZI");
int AltPos = Data.indexOf("ALT");
if(AziPos >= 0){
try{
int EndData = Data.indexOf(";", AziPos);
if(EndData > AziPos){
String Azimuth = Data.substring(AziPos + 5, EndData);
//jTextField1.setText(Azimuth);
jTextField1.setText(Rotor.GetAzimuthValue(Azimuth));
saveProperties();
if(AzimuthGo){
int Delta = Math.abs(Integer.valueOf(AzimuthToGo) - Integer.valueOf(Azimuth));
if(Delta < 2) {
AzimuthGo = false;
Rotor.AzimuthStop();
loadProperties();
}
}
}
}catch(Exception ex){
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
if(AltPos >= 0){
try{
int EndData = Data.indexOf(";", AltPos);
if(EndData > AltPos){
String Altitude = Data.substring(AltPos + 5, EndData);
//jTextField2.setText(Altitude);
jTextField2.setText(Rotor.GetAltitudeValue(Altitude));
saveProperties();
if(AltitudeGo){
int Delta = Math.abs(Integer.valueOf(AltitudeToGo) - Integer.valueOf(Altitude));
if(Delta < 2) {
AltitudeGo = false;
Rotor.AltitudeStop();
loadProperties();
}
}
}
}catch(Exception ex){
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
if(AzimuthGo || AltitudeGo){
jButton16.setEnabled(false);
}
} catch (Exception ex) {
Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
}
}
});

But on the statement "RotorPort.open(Rotorconfig);" that doesn't work and return this exception:

Exception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: 'int com.pi4j.jni.Serial.open(java.lang.String, int, int, int, int, int)'
at com.pi4j.jni.Serial.open(Native Method)
at com.pi4j.io.serial.impl.SerialImpl.open(SerialImpl.java:149)
at com.pi4j.io.serial.impl.SerialImpl.open(SerialImpl.java:319)
at skywalker.RotorControl.InizializeRotor(RotorControl.java:55)
at skywalker.RotorControl.(RotorControl.java:38)
at skywalker.Main.(Main.java:298)
at skywalker.Main.lambda$main$1(Main.java:4073)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(Native Method)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

Anyone can help me? Thanks very much!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions