Re: PySerial & RXTX query

"Corgi" <[email protected]> Tue, 27 Sep 2016 19:23:36 +0100
Newsgroups gmane.comp.lang.jython.user
Message-ID <9B21FF3AEAB7497C975C25F8F2AB791A@GrahamKate915>
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" <[email protected]>
To: <[email protected]>
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
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/jython-users 


------------------------------------------------------------------------------