I'm a beginner in Java. I'm reading data from the serial port. I got

   9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, 

What is the meaning of 9600, DATABITS_8,STOPBITS_1 and PARITY_NONE?

No correct solution



9600 BAUD: Baud is synonymous with symbols or pulses per second. In this case it refers to the number of bits transferred per second.

DATABITS_8: 8-bits of data are transferred at a time. This is typical since most machines have 8-bit bytes these days.

STOPBITS_1: One trailing bit is added to mark the end of the word.

PARITY_NONE: No parity bit is included. This is an error checking feature. For even parity, a 1 is added if it would make the sum of the bits even and vice versa for odd parity. Mark and space parity are sometimes used as well. RS-232 is a low level protocol and error checking is often left to the application layer. A checksum or CRC is often included with packets of serial data for this reason. For example, Ethernet uses a 32-bit CRC for its data frames, but it never concerns an applications developer.

In RS-232 communications a start bit is always included. A universal asynchronous receiver/transmitter (UART) -- the hardware this Java library will control -- looks for this marker and then begins shifting the data bits into a buffer. So, each word in your transfer will take 10 bits: 1 start bit + 8 data bits + 1 stop bit. At 9600 BAUD, this would give you a maximum data transfer rate of 960 bytes per second even though the equivalent of 1200 bytes will be sent: 9600 bits per second divided by 10 bits per word yields 960 words per second with 8 data-bits (1 byte) per word.

This configuration you are using will commonly be abbreviated as 9600,8,N,1 for speed, data-bits, parity and stop bits in that order.

When you say you "got serialPort.setSerialPortParams(....", where did you get it? If you want to understand the parameters to the method, please see the javadoc

if you are not familiar with serial port, just read

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top