Results 1 to 3 of 3
- 03-06-2012, 10:33 AM #1
Member
- Join Date
- Feb 2012
- Location
- Bruges, BELGIUM
- Posts
- 16
- Rep Power
- 0
Variabel Parameters Serial Communication
Hello,
I have created a program that allows me to establish serial communication with a certain device. This device has the following properties:
-Baud Rate=9600
-1 stopbit
-8 databits
-No Parity
These parameters are set as followed:
I would like to adjust the program so that a user can adjust these properties from the form I created. Right now only the baud rate is variabel. Offcourse the easiest way is to create and if-elsif-...-else loop describing every possible combination, bu I can't imagine there is no more effective way to do this. Can anyone suggest me anything?Java Code:myPort.setSerialPortParams(Baud,SerialPort.DATABITS_8,SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
- 03-06-2012, 11:07 AM #2
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Re: Variabel Parameters Serial Communication
Use combo boxes for the three non-baud ones containgin the allowable options.
Please do not ask for code as refusal often offends.
- 03-07-2012, 10:48 AM #3
Member
- Join Date
- Feb 2012
- Location
- Bruges, BELGIUM
- Posts
- 16
- Rep Power
- 0
Re: Variabel Parameters Serial Communication
Found it. I didn't know you could just change the variabels by normal integers en declare those integers elsewhere. I thought it had to be done there.
Kind off stupid of me if you think of it now
.
For anyone in the future looking for this:
-Declare integers:
-Set properties:Java Code:protected int Baud=9600, //Baud rate dataBits=SerialPort.DATABITS_8, //number of databits stopBits=SerialPort.STOPBITS_1, //can be 1, 1_5 or 2 Parity=SerialPort.PARITY_NONE; //set type of parity
Java Code:myPort.setSerialPortParams(Baud,dataBits,stopBits,Parity);
Last edited by F.S.; 03-07-2012 at 10:57 AM.
Similar Threads
-
Serial Communication
By F.S. in forum Advanced JavaReplies: 9Last Post: 03-06-2012, 07:07 AM -
Help with USB/Serial communication
By Blackmore in forum Advanced JavaReplies: 0Last Post: 08-16-2011, 08:45 PM -
Serial communication via ethernet-serial hub
By Idiodyssey in forum New To JavaReplies: 0Last Post: 05-04-2011, 02:23 PM -
Serial port Communication Problem
By rjagan in forum New To JavaReplies: 8Last Post: 04-20-2011, 12:36 PM -
serial communication is very slow while reading from serial port
By elsanthosh in forum AWT / SwingReplies: 1Last Post: 07-30-2010, 08:29 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks