From: Corgi <co...@te...> - 2016-09-27 18:23:55
|
Here's a listing to demonstrate serial port connection with Jython and the RXTX module. Much more needs to be done to make it a useful program but it demonstrates the key points to make a connection! Hope this helps anyone just starting out on a similar project. Graham #Jython.py Serial Port connection with RXTX import sys, socket, gnu.io import gnu.io.RXTXPort as RXTX #Open port COM3 portId=gnu.io.CommPortIdentifier.getPortIdentifier("COM3") serialPort=portId.open("Demo1",2000) #(Name,delay) #Set port parameters serialPort.setSerialPortParams(9600,RXTX.DATABITS_8,RXTX.STOPBITS_1,RXTX.PARITY_NONE) #Open input & output streams outStream=serialPort.getOutputStream() inStream=serialPort.getInputStream() #Define some output and write it to the serial port toOutput="Test output to serial port" outStream.write(toOutput) #Close inStream, outStream before closing the port itself outStream.close() inStream.close() serialPort.close() ----- Original Message ----- From: "Corgi" <co...@te...> To: <jyt...@li...> Sent: Monday, September 26, 2016 8:54 AM Subject: Re: [Jython-users] PySerial & RXTX query > Thanks, I've now sorted out how to use the RXTX module! > > I'll post a listing shortly. > > Graham > > ------------------------------------------------------------------------------ > _______________________________________________ > Jython-users mailing list > Jyt...@li... > https://lists.sourceforge.net/lists/listinfo/jython-users |