From: Corgi <co...@te...> - 2016-09-24 15:50:45
|
Thanks, I've added two listings: Python 2.7 import sys, socket, serial ser = serial.Serial(port="COM9",baudrate=9600) if ser.is_open: ser.close() print "Closed" ser.open() #open port print(ser.portstr) # confirm which port was really used s="Test" ser.write(s) print "written:",s This works fine and I can see the data being written to the port. Jython 2.7 import sys, socket, serial, gnu.io ser = serial.Serial(port="COM9",baudrate=9600) if ser.is_open: ser.close() print "Closed" ser.open() #open port print(ser.portstr) # confirm which port was really used s="Test" ser.write(s) print "written:",s This fails with the following trace back Traceback (most recent call last): File "C:\jee-neon\eclipse\workspace\JythonTest\src\Jython_USB_232.py", line 9, in <module> ser = serial.Serial(port="COM9",baudrate=9600) File "C:\jython2.7.0\Lib\site-packages\serial\serialutil.py", line 182, in __init__ self.open() File "C:\jython2.7.0\Lib\site-packages\serial\serialjava.py", line 69, in open portId = comm.CommPortIdentifier.getPortIdentifier(self._port) at javax.comm.CommPortIdentifier.getPortIdentifier(CommPortIdentifier.java:105) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) javax.comm.NoSuchPortException: javax.comm.NoSuchPortException It all seems to be to do with javax.comm and its replacement (in theory) by gnu.io (RXTX) The RXTX jar is in the JRE and pythonpath and is the 64 bit version also installed is the serial.dll that is required. Any help gratefully appreciated - I'm sure it's something very simple that I've misunderstood! Graham ----- Original Message ----- From: "Adam Burke" <ada...@gm...> To: "Corgi" <co...@te...> Cc: <jyt...@li...> Sent: Saturday, September 24, 2016 9:25 AM Subject: Re: [Jython-users] PySerial & RXTX query Hi, do you get exceptions, or can you share a simple test program? Adam > 在 24 Sep 2016,4:15 PM,Corgi <co...@te...> 写道: > > I have had no success with opening a serial port (device is a Prolific USB > to serial comm port [COM9]) from Jython (2.7) using PySerial (tried both > 2.7 > and 3.1.1) and the RXTX replacement for javax.comm on windows 64 bit. I > have tried the usual googling for examples but found no really helpful > jython specific ones. If anyone has an example program that works, I > should > be really grateful to see it! > > It all works fine in Python 2.7 ! > > Thanks in advance, > > Graham > > (Apologies if this is posted twice) > > > ------------------------------------------------------------------------------ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |