-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails on Apple Silicon #142
Comments
On 28. Jun 2023, at 15.44, Bob Jacobsen ***@***.***> wrote:
JMRI is an application that works cross-platform with PureJavaComm just fine across multiple platforms, including macOS Intel and macOS Rosetta2 on Apple Silicon.
When running on Apple Silicon, attempting to set a control line on a port gives:
[java] purejavacomm.PureJavaIllegalStateException: ioctl(m_FD, TIOCMGET, m_ioctl) == -1
[java] at purejavacomm.PureJavaSerialPort.setControlLineState(PureJavaSerialPort.java:1277)
[java] at purejavacomm.PureJavaSerialPort.setRTS(PureJavaSerialPort.java:313)
[java] at jmri.jmrix.AbstractSerialPortController.configureLeadsAndFlowControl(AbstractSerialPortController.java:121)
[java] at jmri.jmrix.AbstractSerialPortController.configureLeadsAndFlowControl(AbstractSerialPortController.java:142)
The JMRI code line where it occurs:
serialPort.setRTS(rts);
The port seems to have been successfully opened. At least, there was no exception at that point.
If I bypass setting the control lines, I get an I/O exception the first time I attempt to access the port's input stream:
[java] java.io.IOException
[java] at purejavacomm.PureJavaSerialPort$2.available(PureJavaSerialPort.java:721)
[java] at jmri.jmrix.AbstractPortController.purgeStream(AbstractPortController.java:566)
Happens with Azul JDKs from Java 11 (earliest supported by application) through JDK 20. Observed on macOS Ventura with both M1 and M2 chips.
Working on debugging this, but would greatly appreciate any suggestions on how to go about it.
—
Reply to this email directly, view it on GitHub <#142>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAFP7LNDYFNXPJAH5S6DGVTXNQRMNANCNFSM6AAAAAAZXCNWLE>.
You are receiving this because you are subscribed to this thread.
On 28. Jun 2023, at 15.44, Bob Jacobsen ***@***.***> wrote:
JMRI is an application that works cross-platform with PureJavaComm just fine across multiple platforms, including macOS Intel and macOS Rosetta2 on Apple Silicon.
When running on Apple Silicon, attempting to set a control line on a port gives:
[java] purejavacomm.PureJavaIllegalStateException: ioctl(m_FD, TIOCMGET, m_ioctl) == -1
[java] at purejavacomm.PureJavaSerialPort.setControlLineState(PureJavaSerialPort.java:1277)
[java] at purejavacomm.PureJavaSerialPort.setRTS(PureJavaSerialPort.java:313)
[java] at jmri.jmrix.AbstractSerialPortController.configureLeadsAndFlowControl(AbstractSerialPortController.java:121)
[java] at jmri.jmrix.AbstractSerialPortController.configureLeadsAndFlowControl(AbstractSerialPortController.java:142)
The JMRI code line where it occurs:
serialPort.setRTS(rts);
The port seems to have been successfully opened. At least, there was no exception at that point.
If I bypass setting the control lines, I get an I/O exception the first time I attempt to access the port's input stream:
[java] java.io.IOException
[java] at purejavacomm.PureJavaSerialPort$2.available(PureJavaSerialPort.java:721)
[java] at jmri.jmrix.AbstractPortController.purgeStream(AbstractPortController.java:566)
Happens with Azul JDKs from Java 11 (earliest supported by application) through JDK 20. Observed on macOS Ventura with both M1 and M2 chips.
Working on debugging this, but would greatly appreciate any suggestions on how to go about it.
—
Reply to this email directly, view it on GitHub <#142>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAFP7LNDYFNXPJAH5S6DGVTXNQRMNANCNFSM6AAAAAAZXCNWLE>.
You are receiving this because you are subscribed to this thread.Hi Bob,
Thanks for reaching out to me.
It so happens that I have a M2 Mac so I might have a look at this in during coming vacation.
Meanwhile, my hunch is that there is something wrong with the ioctl().
Maybe the signature parameter mapping from Java type to the actual C type is wrong and has so far worked by fluke.
The actual mapping is here:
https://github.com/nyholku/purejavacomm/blob/d3b6903ec2e220d63e55a06ae6bf6ced929d961e/src/jtermios/macosx/JTermiosImpl.java#L117C12-L117C12
Ref doc for mappings is here:
https://java-native-access.github.io/jna/4.2.1/overview-summary.html#pointers
If you google for "man ioctl' you will see the ioctl call C signature, which is kind of not too helpful.
I suspect the third parameter but this is pure conjecture.
You might ask on the the JNA list if the Java
public int ioctl(int fd, NativeLong cmd, int[] arg);
matches the C:
int ioctl(int fd, unsigned long request, ...);
You could/should also check the errno to see why the ioctl fails.
In any case you should work the ioctl failure because if that fails, nothing is going to work.
wbr Kusti
|
Thank you for the quick reply! This is the minimal test program I'm using:
It gives:
Thanks again. |
Using
|
On 28. Jun 2023, at 18.31, Bob Jacobsen ***@***.***> wrote:
Using com.sun.jna.Native.getLastError() I find that the errno is 14:
14 EFAULT Bad address. The system detected an invalid address in attempting to use an argument of a call.
—
Reply to this email directly, view it on GitHub <#142 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAFP7LIMUM7CWUEZP6O7TLLXNRE4DANCNFSM6AAAAAAZXCNWLE>.
You are receiving this because you commented.
I think you should take this up on the JNA list
.
Something wrong with the 3rd argument I'm guessing.
wbr Kusti
|
See a possible solution descend on the JNA list. There's an odd dependence on debugging output, unfortunately. |
On 1. Jul 2023, at 18.03, Bob Jacobsen ***@***.***> wrote:
See a possible solution descend on the JNA list <https://groups.google.com/g/jna-users/c/wF4aJ5ViQJE/m/u1b9dl4rAAAJ>. There's an odd dependence on debugging output, unfortunately.
—
Reply to this email directly, view it on GitHub <#142 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAFP7LI56WIIFIM6TW6IYADXOA35XANCNFSM6AAAAAAZXCNWLE>.
You are receiving this because you commented.
Thanks, I saw it. Yeah, that looks suspicious.
|
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JMRI is an application that works cross-platform with PureJavaComm just fine across multiple platforms, including macOS Intel and macOS Rosetta2 on Apple Silicon.
When running on Apple Silicon, attempting to set a control line on a port gives:
The JMRI code line where it occurs:
The port seems to have been successfully opened. At least, there was no exception at that point.
If I bypass setting the control lines, I get an I/O exception the first time I attempt to access the port's input stream:
Happens with Azul JDKs from Java 11 (earliest supported by application) through JDK 20. Observed on macOS Ventura with both M1 and M2 chips.
Working on debugging this, but would greatly appreciate any suggestions on how to go about it.
The text was updated successfully, but these errors were encountered: