• Post Reply Bookmark Topic Watch Topic
  • New Topic

Serial Communication using JNI?

 
arya putra
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchos,(I hope you dont mind me calling this)
So here is the thing.....
I am developing a webservices project for controlling a Meade ETX125 telescope, for that I have the protocol file written in C, which I converted to JAVA platform using JNI. The C code is mainly the serial port communication. Along side I have written another JAVA program which calls the JNI functions.
The thing is I am not able to open the ports, even though I have tried everything. One doubt that came to my mind is whether the C files can be handled using JNI like this from an outside calling JAVA program?
I made pure C Code for serial port and it worked. For everyones reference here is the JAVA code which calls the JNI library code. During the test.ConnectLX200() call I get an error no such process: no such directory, which are clearly the error nos 3 and 4 returned by a call to open().
public class TestLx200{
public static final int TELESCOPE_SLEW = 1;
public static final int NORTH = 1;
public static float startRA,startDec;
public static void main(String[] args) {
Lx200 test = new Lx200();
int i=1;
String[] port= new String[]{"/dev/ttyS0"};
i=test.InitiatePortLX200(port);
System.out.println(i);
if (test.ConnectLX200() != 1)
System.out.println("Error connecting to LX200");
if(i==1)
{
System.out.println("Connected");
test.SetFormat(1);
System.out.println("Format set");
test.SetRate(TELESCOPE_SLEW);
System.out.println("Rate set");
startRA=test.GetRA();
System.out.println("GetRA()");
startDec=test.GetDec();
System.out.println("GetDec()");
System.out.println(startRA + " " + startDec);
j=test.SlewToCoords(startRA+1,startDec+24);
}
else
System.out.println("Not Connected");
}

}
Pls pls pls drop in your wise words and suggestions.
Regards,
Aryan.
 
ravinder thirumala
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
send ur c code also.....
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!