My problem is to redirect the duino's IDE serial port to something I can use.
On OSX I have no choice, it only shows "serial ports" and I can't specify a PTY.
Any suggestion ? If I could talk to the bootloader, I could use simavr as a "target board" exactly like a real board, bootloader and all!
Yes. If everything were working properly on OS X, you would specify valid serial ports in a file named "gnu.io.rxtx.properties".
Sadly, this fails on OS X. Happily, there's a fix.
If everything were working, the file would live in any of the following locations:
- /Users//Library/Java/Extensions/gnu.io.rxtx.properties
- /Library/Java/Extensions/gnu.io.rxtx.properties
- /System/Library/Java/Extensions/gnu.io.rxtx.properties
- ... and so on.
The file would read something like this:
gnu.io.rxtx.SerialPorts=/dev/ttys005:/dev/ttys006:/dev/ttys007
Mine reads like so:
[list]
gnu.io.rxtx.SerialPorts=/dev/ttys001:/dev/ttys002:/dev/ttys003:/dev/ttys004:/dev/ttys005:/dev/ttys006:/dev/ttys007:/dev/ttys008:/dev/ttys009:/dev/ttys010:/dev/ttys011
[/list]
On OS X this fails because of bugs in RXTX, a library included with Arduino for OS X. RXTX is an open-source serial-port communication library. Its website is rxtx.qbang.org.
In Arduino version 0021 for OS X, the part of RXTX that needs to be fixed is the following file. It lives inside of the Arduino application bundle:
Arduino.app/Contents/Resources/Java/RXTXcomm.jar
Fixing this file is kind of a pain. The short version:
--- src/RXTXCommDriver.java.orig 2011-01-01 23:12:47.000000000 -0500
+++ src/RXTXCommDriver.java 2011-01-01 23:36:54.000000000 -0500
@@ -306,13 +306,11 @@
file. If that doesn't exist, then scan for ports.
*/
for (int PortType=CommPortIdentifier.PORT_SERIAL;PortType<=CommPortIdentifier.PORT_PARALLEL;PortType++) {
- if (!registerSpecifiedPorts(PortType)) {
- if (!registerKnownPorts(PortType)) {
+ registerSpecifiedPorts(PortType);
+ registerKnownPorts(PortType);
registerScannedPorts(PortType);
}
}
- }
- }
private void addSpecifiedPorts(String names, int PortType)
{
@@ -351,25 +349,36 @@
private boolean registerSpecifiedPorts(int PortType)
{
String val = null;
-
- try
- {
-
- String ext_dir=System.getProperty("java.ext.dirs")+System.getProperty("file.separator");
- FileInputStream rxtx_prop=new FileInputStream(ext_dir+"gnu.io.rxtx.properties");
+ String ext_dirs = System.getProperty("java.ext.dirs");
+ String[] ext_dir_list = ext_dirs.split(":");
+ String sep = System.getProperty("file.separator");
+
+ for (int i = 0; i < ext_dir_list.length; i++){
+ String ext_dir = ext_dir_list[i];
+ String rxtx_prop_fnam = ext_dir + sep + "gnu.io.rxtx.properties";
+ try {
+ FileInputStream rxtx_prop=new FileInputStream(rxtx_prop_fnam);
Properties p=new Properties();
p.load(rxtx_prop);
- System.setProperties(p);
for (Iterator it = p.keySet().iterator(); it.hasNext();) {
String key = (String) it.next();
System.setProperty(key, p.getProperty(key));
- }
- }catch(Exception e){
if (debug){
- System.out.println("The file: gnu.io.rxtx.properties doesn't exists.");
+ System.out.println("Set property " + key + " to " + p.getProperty(key) + " ...");
+ }//end if
+ }
+ break;
+ }
+ catch(Exception e) {
+ if (debug) {
+ System.out.println("The file: " + rxtx_prop_fnam + " doesn't exist.");
System.out.println(e.toString());
}//end if
}//end catch
+ }
+ if (debug){
+ System.out.println("Loaded properties seems to have worked ...");
+ }//end if
if (debug)
System.out.println("checking for system-known ports of type "+PortType);
- Follow the instructions included with the source code in order to build a new version of
RXTXcomm.jar, using the patched version of src/RXTXCommDriver.java. This will probably not work without some hacking, because RXTX is hard to build on OS X. However, if you're able to get RXTXcomm.jar built, don't worry about the rest. RXTXcomm.jar is the only file you'll need.
- Make a backup of
Arduino.app/Contents/Resources/Java/RXTXcomm.jar so you can restore it in case Bad Things Happen (don't worry, they will). I back-up by renaming Arduino.app/Contents/Resources/Java/RXTXcomm.jar to Arduino.app/Contents/Resources/Java/RXTXcomm.jar.old.
- Copy the patched version of
RXTXcomm.jar into Arduino.app/Contents/Resources/Java/.
- Create the file
/Users/<Your username here>/Library/Java/Extensions/gnu.io.rxtx.properties described above.
When you next launch Arduino, your new, custom serial ports should be available.
Good luck ...