i downloaded the source code and compiled Tester.java under ubuntu linux.
When i run the Tester class
connection.getNumberDevices() returns 1, but
connection.getDevice(0) returns null
What should I check?
Thanks,
Mauro
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
System.out.println("> end of connection.getDevices()");
int size = v.size();
System.out.println("size of connection.getDevices() => " + size);
for (int deviceNum = 0;
deviceNum < connection.getNumberDevices();
++deviceNum)
{
....
....
connection.getDevices() returns an empty vector, while getNumberDevices() still returns 1.
In fact getDevices calls getNumberDevices which tests if _devices == null and since this happens it calls
_devices = net_get_devices();
The net_get_devices() method issues
reply.devices = _wire.getPtrArray( dev );
The getPtrArray method calls
int size = getWord();
This call returns 1, so getWord is called a second time
isNull = getWord();
and it returns 1 this time too, so
vec.add(null)
is executed.
As a result the _devices.devices Vector has one element and this element is null. This explains why
getNumberDevices returns 1 and getDevices() returns an empty vector.
But i cannot explain why my device is not correctly detected.
I enclose a log i have made (here also getWord is logged).
> calling connection.getDevices()
> start of getNumberDevices
_devices == null
> start of net_get_devices
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 0
value is => 0
> start of getPtrArray
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 1
value is => 1
> 1st getWord returns => 1
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 1
value is => 1
> 2nd getWord returns => 1
> getPtrArray returns a vector with size => 1
first element of returned Vector is null
> end of getPtrArray
> end of net_get_devices
getNumberDevices: _devices.devices has size => 1
first element of _devices.devices is null
> start of getNumberDevices
> end of connection.getDevices()
size of connection.getDevices() => 0
I hope you can give some help.
Thanks, Mauro
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi
i downloaded the source code and compiled Tester.java under ubuntu linux.
When i run the Tester class
connection.getNumberDevices() returns 1, but
connection.getDevice(0) returns null
What should I check?
Thanks,
Mauro
This is a rather interesting problem.
Have you tried
connection.getDevices();
which returns a vector of devices?
and check the size of that and if it contains the device?
Andi
I have modified the tester class to include a call to connection.getDevices().
public Tester()
{
try
{
JSane_Net_Connection connection = new JSane_Net_Connection("127.0.0.1", 6566);
System.out.println("> calling connection.getDevices()");
Vector v = connection.getDevices();
System.out.println("> end of connection.getDevices()");
int size = v.size();
System.out.println("size of connection.getDevices() => " + size);
for (int deviceNum = 0;
deviceNum < connection.getNumberDevices();
++deviceNum)
{
....
....
connection.getDevices() returns an empty vector, while getNumberDevices() still returns 1.
In fact getDevices calls getNumberDevices which tests if _devices == null and since this happens it calls
_devices = net_get_devices();
The net_get_devices() method issues
reply.devices = _wire.getPtrArray( dev );
The getPtrArray method calls
int size = getWord();
This call returns 1, so getWord is called a second time
isNull = getWord();
and it returns 1 this time too, so
vec.add(null)
is executed.
As a result the _devices.devices Vector has one element and this element is null. This explains why
getNumberDevices returns 1 and getDevices() returns an empty vector.
But i cannot explain why my device is not correctly detected.
I enclose a log i have made (here also getWord is logged).
> calling connection.getDevices()
> start of getNumberDevices
_devices == null
> start of net_get_devices
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 0
value is => 0
> start of getPtrArray
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 1
value is => 1
> 1st getWord returns => 1
1st getbyte returns => 0
value is => 0
2nd getbyte returns => 0
value is => 0
3rd getbyte returns => 0
value is => 0
4th getbyte returns => 1
value is => 1
> 2nd getWord returns => 1
> getPtrArray returns a vector with size => 1
first element of returned Vector is null
> end of getPtrArray
> end of net_get_devices
getNumberDevices: _devices.devices has size => 1
first element of _devices.devices is null
> start of getNumberDevices
> end of connection.getDevices()
size of connection.getDevices() => 0
I hope you can give some help.
Thanks, Mauro
i believe the scanner is correctly installed because we can scan with scanimage
also, in net_get_devices i get reply.status = 0 (= SANE_STATUS_GOOD)
Thanks for the debugging.
I'll add a check to make sure that null is not entered in to the vector.
Have you tried performing scanimage -L on the same box as you are trying to run JSane and checking that the device is listed with a net: interface.
Andi
it was a kind of problem with permissions, we have solved by starting saned with user = root and group = root.
Mauro