Sg2.9
Java libraries with new Scrip...
Recent RSS
Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  19. April 2007, 10:03

Hey all,

When I moved to CS3 and the latest scripto I've been getting this error when working with rxtx (serial communication) from within scriptographer.

  • -

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
Error InternalError: Can't find method gnu.io.RXTXPort.setSerialPortParams(number,org.mozilla.javascript.Undefined,org.mozilla.javascript.Undefined,org.mozilla.javascript.Undefined).

  • -

I don't know if this has to do with any changes in the architecture of scriptographer? Well, maybe some of you know.

Thanks

Re: Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  19. April 2007, 17:24

Hello Simon,

This is the function:

setSerialPortParams
public abstract void setSerialPortParams(int baudrate,
int dataBits,
int stopBits,
int parity) throws UnsupportedCommOperationException
Sets serial port parameters.

This is my code:

this.port.setSerialPortParams(9600,
this.port.DATABITS_8,
this.port.STOPBITS_1,
this.port.PARITY_NONE);

My code does work with the previous version of scriptographer though (from within Illustrator CS2 that is)

Re: Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  21. April 2007, 22:14

Hey Simon,

Thanks for helping out. The constants are part of the java class, here's some more code. Do you know if there were any changes considering the handling of java classes in general? I'm still wondering why it does work with the previous version of scriptographer.

Thanks again,

Thijs.

importPackage(Packages.gnu.io);
importPackage(java.io);
importPackage(java.util);

function Plotter() {
var symbols = new java.text.DecimalFormatSymbols();
symbols.decimalSeparator = '.';
this.formater = new java.text.DecimalFormat("0.0#", symbols);
this.inPath = false;
}

Plotter.prototype.getPort = function() {
var portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements()) {
var portId = portList.nextElement();
if (portId.name == "/dev/tty.KeySerial1") {
return portId;
}
}

}

Plotter.prototype.connect = function(speed, pressure) {
var portId = this.getPort();
this.port = portId.open("Plotter", 100);
this.port.setSerialPortParams(9600,
this.port.DATABITS_8,
this.port.STOPBITS_1,
this.port.PARITY_NONE);

Re: Java libraries with new Scripto?
From:  Jürg Lehni
Date:  22. April 2007, 19:58

Hi Thijs and Simon,

That's weird... Accessing static fields through object instances is supported, so this.port.DATABITS_8 should give correct results.

Also, this line should not be needed, as you already import the full gnu.io package:

var SerialPort = Packages.gnu.io.SerialPort;

I am looking into this now.

Re: Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  22. April 2007, 20:26

Thanks for looking into it, and Simon, I haven't tried your solution yet, but thanks for the input!

Re: Java libraries with new Scripto?
From:  Jürg Lehni
Date:  22. April 2007, 21:15

The lat version broke this code because I accidentaly removed support for accessing static fields on instances. I will add it again in the next version, but until then Simon's workaround does the trick, and the code is actually cleaner that way, as it is more Java like.

Re: Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  22. April 2007, 21:25

Ah, that explains!. Well thanks again for the intercontinental support.

Re: Java libraries with new Scripto?
From:  Jürg Lehni
Date:  26. April 2007, 22:06

I've fixed the bug that was causing this. It will be in the next version. Sorry for the confusion.

Re: Java libraries with new Scripto?
From:  Thijs Gadiot
Date:  28. April 2007, 09:40

Thanks alot for the fix!. The workaround didn't seem to fix everything though, as I wasnt able to set the flowcontrol with the following code:

this.port.setFlowControlMode(SerialPort.FLOWCONTROL_RTSCTS_OUT);

But I'll try again when the new version is here.

Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Abstract Foliage 18.08.08