设置通过串口读取的数据格式?

时间:2021-03-05 15:09:59

while reading a data through the serial port.I want to know that the data which is coming through the port in which format it is ? wheathr ASCII, Decimal or Hexa or in Bytes it is,

同时通过串口读取数据。我想知道通过端口来的数据是以哪种格式出现的? wheathr ASCII,十进制或六进制或字节为,

plz any boby give the hint

PLZ任何boby给出提示

3 个解决方案

#1


Use a terminal program like HyperTerminal or TeraTerm to see the output from the serial device. You can use these software to establish a connection from your PC to the device, then check the output on your screen to determine the data format.

使用HyperTerminal或TeraTerm等终端程序查看串行设备的输出。您可以使用这些软件建立从PC到设备的连接,然后检查屏幕上的输出以确定数据格式。

Also check the manufacturer manual, they typically will details about the data format and also the serial port connection details (baud rate etc).

另请查看制造商手册,它们通常会详细介绍数据格式以及串行端口连接详细信息(波特率等)。

#2


ByteSize is simply the number of bits the device manufacturer has chosen to use per BYTE of data the device outputs. Typically they use 7 or 8: the range itself is limited to 5,6,7 or 8.

ByteSize只是设备制造商根据设备输出的每个BYTE数据选择使用的位数。通常他们使用7或8:范围本身限制为5,6,7或8。

So there will be this BYTE stream irrespective of ASCII, HEX format. For example you can have both ASCII or HEX format using any of the 5,6,7 or 8 bits per BYTE.

因此,无论ASCII,HEX格式如何,都会有此BYTE流。例如,您可以使用每个BYTE的5,6,7或8位中的任何一种来使用ASCII或HEX格式。

Which is why one should look at the manufacturer manuals or try the hyperterminal to see that data format.

这就是为什么人们应该查看制造商手册或尝试使用超级终端查看数据格式的原因。

#3


It depends upon how you are configuring serial port to connect the device: data length (Bytesize) is one of the property to decide data to receive and ofcourse how the device is transferring

这取决于您如何配置串行端口以连接设备:数据长度(Bytesize)是决定接收数据的属性之一,以及当前设备如何传输的属性

DCB structure looks like following:

DCB结构如下所示:

DWORD BaudRate: Speed

DWORD BaudRate:速度

BYTE StopBits: 0,1,2 = 1, 1.5, 2 (default = 0)

BYTE StopBits:0,1,2 = 1,1.5,2(默认= 0)

BYTE Parity: 0-4= no, odd, even, mark, space (default = 0)

BYTE奇偶校验:0-4 =不,奇数,偶数,标记,空格(默认= 0)

BYTE ByteSize: Number of bits/byte, 4-8 (default = 8)

BYTE ByteSize:位数/字节,4-8(默认值= 8)

Last one decides the data stream and all other decides the connectivity..

最后一个决定数据流,所有其他决定连接..

#1


Use a terminal program like HyperTerminal or TeraTerm to see the output from the serial device. You can use these software to establish a connection from your PC to the device, then check the output on your screen to determine the data format.

使用HyperTerminal或TeraTerm等终端程序查看串行设备的输出。您可以使用这些软件建立从PC到设备的连接,然后检查屏幕上的输出以确定数据格式。

Also check the manufacturer manual, they typically will details about the data format and also the serial port connection details (baud rate etc).

另请查看制造商手册,它们通常会详细介绍数据格式以及串行端口连接详细信息(波特率等)。

#2


ByteSize is simply the number of bits the device manufacturer has chosen to use per BYTE of data the device outputs. Typically they use 7 or 8: the range itself is limited to 5,6,7 or 8.

ByteSize只是设备制造商根据设备输出的每个BYTE数据选择使用的位数。通常他们使用7或8:范围本身限制为5,6,7或8。

So there will be this BYTE stream irrespective of ASCII, HEX format. For example you can have both ASCII or HEX format using any of the 5,6,7 or 8 bits per BYTE.

因此,无论ASCII,HEX格式如何,都会有此BYTE流。例如,您可以使用每个BYTE的5,6,7或8位中的任何一种来使用ASCII或HEX格式。

Which is why one should look at the manufacturer manuals or try the hyperterminal to see that data format.

这就是为什么人们应该查看制造商手册或尝试使用超级终端查看数据格式的原因。

#3


It depends upon how you are configuring serial port to connect the device: data length (Bytesize) is one of the property to decide data to receive and ofcourse how the device is transferring

这取决于您如何配置串行端口以连接设备:数据长度(Bytesize)是决定接收数据的属性之一,以及当前设备如何传输的属性

DCB structure looks like following:

DCB结构如下所示:

DWORD BaudRate: Speed

DWORD BaudRate:速度

BYTE StopBits: 0,1,2 = 1, 1.5, 2 (default = 0)

BYTE StopBits:0,1,2 = 1,1.5,2(默认= 0)

BYTE Parity: 0-4= no, odd, even, mark, space (default = 0)

BYTE奇偶校验:0-4 =不,奇数,偶数,标记,空格(默认= 0)

BYTE ByteSize: Number of bits/byte, 4-8 (default = 8)

BYTE ByteSize:位数/字节,4-8(默认值= 8)

Last one decides the data stream and all other decides the connectivity..

最后一个决定数据流,所有其他决定连接..