Java中串口参数的含义?

时间:2021-11-25 01:49:57

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

我是Java的初学者。我正在从串口读取数据。我有

serialPort.setSerialPortParams(
   9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, 
   SerialPort.PARITY_NONE); 

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

9600,DATABITS_8,STOPBITS_1和PARITY_NONE是什么意思?

3 个解决方案

#1


9600, DATABITS_8,STOPBITS_1 and PARITY_NONE

9600,DATABITS_8,STOPBITS_1和PARITY_NONE

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

9600 BAUD:波特是每秒符号或脉冲的同义词。在这种情况下,它指的是每秒传输的位数。

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

DATABITS_8:一次传输8位数据。这是典型的,因为现在大多数机器都有8位字节。

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

STOPBITS_1:添加一个尾随位以标记单词的结尾。

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.

PARITY_NONE:不包括奇偶校验位。这是一个错误检查功能。对于偶校验,如果将奇数奇偶校验的比特求和,则加1,反之亦然。有时也使用标记和空间奇偶校验。 RS-232是一种低级协议,错误检查通常留给应用层。出于这个原因,校验和或CRC通常包含在串行数据包中。例如,以太网对其数据帧使用32位CRC,但它从不涉及应用程序开发人员。

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.

在RS-232通信中,始终包括起始位。通用异步接收器/发送器(UART) - 这个Java库将控制的硬件 - 查找该标记,然后开始将数据位移入缓冲区。因此,传输中的每个字将占用10位:1个起始位+ 8个数据位+ 1个停止位。在9600 BAUD,这将为您提供每秒960字节的最大数据传输速率,即使相当于1200字节将被发送:每秒9600位除以每字10位,每秒产生960字8位数据(每个字1个字节)。

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.

对于速度,数据位,奇偶校验和停止位,您正在使用的此配置通常缩写为9600,8,N,1。

#2


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

当你说“得到serialPort.setSerialPortParams(....”,你在哪里得到它?如果你想了解该方法的参数,请参阅javadoc

#3


if you are not familiar with serial port, just read http://www.beyondlogic.org/serial/serial.htm

如果您不熟悉串口,请阅读http://www.beyondlogic.org/serial/serial.htm

#1


9600, DATABITS_8,STOPBITS_1 and PARITY_NONE

9600,DATABITS_8,STOPBITS_1和PARITY_NONE

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

9600 BAUD:波特是每秒符号或脉冲的同义词。在这种情况下,它指的是每秒传输的位数。

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

DATABITS_8:一次传输8位数据。这是典型的,因为现在大多数机器都有8位字节。

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

STOPBITS_1:添加一个尾随位以标记单词的结尾。

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.

PARITY_NONE:不包括奇偶校验位。这是一个错误检查功能。对于偶校验,如果将奇数奇偶校验的比特求和,则加1,反之亦然。有时也使用标记和空间奇偶校验。 RS-232是一种低级协议,错误检查通常留给应用层。出于这个原因,校验和或CRC通常包含在串行数据包中。例如,以太网对其数据帧使用32位CRC,但它从不涉及应用程序开发人员。

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.

在RS-232通信中,始终包括起始位。通用异步接收器/发送器(UART) - 这个Java库将控制的硬件 - 查找该标记,然后开始将数据位移入缓冲区。因此,传输中的每个字将占用10位:1个起始位+ 8个数据位+ 1个停止位。在9600 BAUD,这将为您提供每秒960字节的最大数据传输速率,即使相当于1200字节将被发送:每秒9600位除以每字10位,每秒产生960字8位数据(每个字1个字节)。

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.

对于速度,数据位,奇偶校验和停止位,您正在使用的此配置通常缩写为9600,8,N,1。

#2


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

当你说“得到serialPort.setSerialPortParams(....”,你在哪里得到它?如果你想了解该方法的参数,请参阅javadoc

#3


if you are not familiar with serial port, just read http://www.beyondlogic.org/serial/serial.htm

如果您不熟悉串口,请阅读http://www.beyondlogic.org/serial/serial.htm