On 10.4.2013 22.33, "Rebecca Bird" <
bi...@bainet.com> wrote:
>Thanks, Rick, for Java 8 tip. Maybe TWall or Nyholku will also see this
>from jna-users, for JTermios problem:
I (nyholku) happened to see this, but it is better to contact
me directly or via the PJC mailing list
pureja...@freelists.org
or via
https://github.com/nyholku/purejavacomm.
I do hang around here but don't read every mail
of every thread and I guess this OT for this list.
>
>My serial test program can find connected devices, but can't open; here's
>the PureJavaComm log:
You can get a more detailed log (from the one
you provided the exact place in the source code where calls
occur is not 100% clear) if you do:
jtermios.JTermios.JTermiosLogging.setLogMask(255);
>log: > open('ttyACM1',00000902)
>log: < open('ttyACM1',00000902) => 97384
>log: > close(97384)
>log: < close(97384) => 185
>log: > open('ttyACM1',00000902) (don't know why it opens and reopens...)
If your code does CommPortIdentifier.getPortIdentifiers() then this
requires PJC to try to open the port because that is about the
only way to reliable check weather the portName is valid and to
throw NoSuchPortException, which cannot be thrown later when the
I try to really open the port.
>log: < open('ttyACM1',00000902) => 12
>log: > fcntl(12, 3, 0)
>log: < fcntl(12, 3, 0) => 97384
>log: > fcntl(12, 4, 95336)
>log: < fcntl(12, 4, 95336) => 1 (real problem is here)
>log: JTermios call returned 1 at class purejavacomm.PureJavaSerialPort
>line 1075
Obviously fcntl failed as it does below too:
>log: < fcntl(12, 4, 1085741088) => 1085741088
>log: fcntl(-1,4,1085741088) returned 1085741088
This looks strange too:
>log: > close(12)
>log: < close(12) => 1085741220
To me this looks like something is wrong with the
stack because fcntl(-1,4,1085741088) seems to return
the parameters it was passed (the -1 is red herring
caused by buggy log statement).
This can happen if my fcntl()/JNA mapping is wrong
or if there is a bug in JNA or the underlaying libffi
implementation for your platform.
My def looks like:
native public int fcntl(int fd, int cmd, int[] arg);
Hmm, looking at 'man fcntl' it seems that the third argument
should be 'long' (in C that is).
Looks like my bug then.
Now why does it work for me and everyone else?
Could be endian issues, don't recall if Raspberry/ARM
is big or little endian.
Anyway, more to the point, how to fix or workaround this?
Although the third argument for F_SETFD is 'long' it must
actually fit in 'int' as it is the value return from the
fcntl for F_GETFD, which is int.
So I guess changing the fcntl third argument to NativeLong
in Linux_C_lib_DirectMapping and Linux_C_lib and
changing jtermios.linux.JTermiosImpl.fcntl to:
public int fcntl(int fd, int cmd, int arg) {
return m_Clib.fcntl(fd, cmd, new NativeLong(arg));
}
could do the trick, don't have the time to implement and
test this right now but you could try that.
br Kusti
BTW I've heard that PJC has been successfully used on RaspberryPI
but I've also heard that the serial driver is very buggy. This
is not my firsthand knowledge.
This e-mail may contain confidential or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorized copying, disclosure or distribution of the material in this e-mail is strictly forbidden. We will not be liable for direct, indirect, special or consequential damages arising from alteration of the contents of this message by a third party or as a result of any virus being passed on or as of transmission of this e-mail in general.