$3a瑂*
转换为二进制:
24 06 33 07 05 01 01 61 17 08 AC 73 1A 00
我如何能将这些数据读取出来?读取出来后是字符串还是数组?
另外还涉及到的问题就是数据写入,如何将数据打包再写入?
还有可能就是碰到多个串口如何自动变化com口?
(波特率2400)
11 个解决方案
#1
转的是16进制吧?
string 就行了.
string 就行了.
#2
我知道这些数据的格式和内容,但我如何用PB读取出来?
#3
你不是说得到这些数据了么? 这些数据一般是通过函数读取得到啊.
#4
#5
感觉现在很少用到这类技术了,因为现在的硬件大部分都是USB接口的东东了。楼主居然还能遇到串口通讯的设备,真是不幸。
#6
大概了解,但要用到mscomm组件的,对mscomm组件的函数完全陌生,有没有例子?
#7
怎么没高手指点啊?
现在遇到新问题,就是我在pb中无法注册mscomm.ocx控件,采用多种方法注册后,仍然在insert control中找不到Microsoft Communications Control,请指点,谢谢!
现在遇到新问题,就是我在pb中无法注册mscomm.ocx控件,采用多种方法注册后,仍然在insert control中找不到Microsoft Communications Control,请指点,谢谢!
#8
你的设备有开发SDK吧,直接找开发商,不好浪费时间搞这东西
#9
看了这个,但dcb类型在PB中是不接受的,PB中这个类型是什么?
#10
DCB是个结构体,需要在PB中自己定义的。具体的DCB描述自己可以参阅MSDN文档之类的资料,下面给出我在MSDN查阅的关于DCB结构体的描述。
DCB Structure
Defines the control setting for a serial communications device.
typedef struct _DCB { DWORD DCBlength;
DWORD BaudRate;
DWORD fBinary :1;
DWORD fParity :1;
DWORD fOutxCtsFlow :1;
DWORD fOutxDsrFlow :1;
DWORD fDtrControl :2;
DWORD fDsrSensitivity :1;
DWORD fTXContinueOnXoff :1;
DWORD fOutX :1;
DWORD fInX :1;
DWORD fErrorChar :1;
DWORD fNull :1;
DWORD fRtsControl :2;
DWORD fAbortOnError :1;
DWORD fDummy2 :17;
WORD wReserved;
WORD XonLim;
WORD XoffLim;
BYTE ByteSize;
BYTE Parity;
BYTE StopBits;
char XonChar;
char XoffChar;
char ErrorChar;
char EofChar;
char EvtChar;
WORD wReserved1;
} DCB, *LPDCB;
Members
DCBlength
The length of the structure, in bytes. The caller must set this member to sizeof(DCB).
BaudRate
The baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes.
Value Meaning
CBR_110
110
110 bps
CBR_300
300
300 bps
CBR_600
600
600 bps
CBR_1200
1200
1200 bps
CBR_2400
2400
2400 bps
CBR_4800
4800
4800 bps
CBR_9600
9600
9600 bps
CBR_14400
14400
14400 bps
CBR_19200
19200
19200 bps
CBR_38400
38400
38400 bps
CBR_57600
57600
57600 bps
CBR_115200
115200
115200 bps
CBR_128000
128000
128000 bps
CBR_256000
256000
256000 bps
fBinary
If this member is TRUE, binary mode is enabled. Windows does not support nonbinary mode transfers, so this member must be TRUE.
fParity
If this member is TRUE, parity checking is performed and errors are reported.
fOutxCtsFlow
If this member is TRUE, the CTS (clear-to-send) signal is monitored for output flow control. If this member is TRUE and CTS is turned off, output is suspended until CTS is sent again.
fOutxDsrFlow
If this member is TRUE, the DSR (data-set-ready) signal is monitored for output flow control. If this member is TRUE and DSR is turned off, output is suspended until DSR is sent again.
fDtrControl
The DTR (data-terminal-ready) flow control. This member can be one of the following values.
Value Meaning
DTR_CONTROL_DISABLE
0x00
Disables the DTR line when the device is opened and leaves it disabled.
DTR_CONTROL_ENABLE
0x01
Enables the DTR line when the device is opened and leaves it on.
DTR_CONTROL_HANDSHAKE
0x02
Enables DTR handshaking. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
fDsrSensitivity
If this member is TRUE, the communications driver is sensitive to the state of the DSR signal. The driver ignores any bytes received, unless the DSR modem input line is high.
fTXContinueOnXoff
If this member is TRUE, transmission continues after the input buffer has come within XoffLim bytes of being full and the driver has transmitted the XoffChar character to stop receiving bytes. If this member is FALSE, transmission does not continue until the input buffer is within XonLim bytes of being empty and the driver has transmitted the XonChar character to resume reception.
fOutX
Indicates whether XON/XOFF flow control is used during transmission. If this member is TRUE, transmission stops when the XoffChar character is received and starts again when the XonChar character is received.
fInX
Indicates whether XON/XOFF flow control is used during reception. If this member is TRUE, the XoffChar character is sent when the input buffer comes within XoffLim bytes of being full, and the XonChar character is sent when the input buffer comes within XonLim bytes of being empty.
fErrorChar
Indicates whether bytes received with parity errors are replaced with the character specified by the ErrorChar member. If this member is TRUE and the fParity member is TRUE, replacement occurs.
fNull
If this member is TRUE, null bytes are discarded when received.
fRtsControl
The RTS (request-to-send) flow control. This member can be one of the following values.
Value Meaning
RTS_CONTROL_DISABLE
0x00
Disables the RTS line when the device is opened and leaves it disabled.
RTS_CONTROL_ENABLE
0x01
Enables the RTS line when the device is opened and leaves it on.
RTS_CONTROL_HANDSHAKE
0x02
Enables RTS handshaking. The driver raises the RTS line when the "type-ahead" (input) buffer is less than one-half full and lowers the RTS line when the buffer is more than three-quarters full. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
RTS_CONTROL_TOGGLE
0x03
Specifies that the RTS line will be high if bytes are available for transmission. After all buffered bytes have been sent, the RTS line will be low.
Windows Me/98/95: This value is not supported.
fAbortOnError
If this member is TRUE, the driver terminates all read and write operations with an error status if an error occurs. The driver will not accept any further communications operations until the application has acknowledged the error by calling the ClearCommError function.
fDummy2
Reserved; do not use.
wReserved
Reserved; must be zero.
XonLim
The minimum number of bytes allowed in the input buffer before flow control is activated to inhibit the sender. Note that the sender may transmit characters after the flow control signal has been activated, so this value should never be zero. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl.
XoffLim
The maximum number of bytes allowed in the input buffer before flow control is activated to allow transmission by the sender. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl. The maximum number of bytes allowed is calculated by subtracting this value from the size, in bytes, of the input buffer.
ByteSize
The number of bits in the bytes transmitted and received.
Parity
The parity scheme to be used. This member can be one of the following values.
Value Meaning
EVENPARITY
2
Even parity.
MARKPARITY
3
Mark parity.
NOPARITY
0
No parity.
ODDPARITY
1
Odd parity.
SPACEPARITY
4
Space parity.
StopBits
The number of stop bits to be used. This member can be one of the following values.
Value Meaning
ONESTOPBIT
0
1 stop bit.
ONE5STOPBITS
1
1.5 stop bits.
TWOSTOPBITS
2
2 stop bits.
XonChar
The value of the XON character for both transmission and reception.
XoffChar
The value of the XOFF character for both transmission and reception.
ErrorChar
The value of the character used to replace bytes received with a parity error.
EofChar
The value of the character used to signal the end of data.
EvtChar
The value of the character used to signal an event.
wReserved1
Reserved; do not use.
Remarks
When a DCB structure is used to configure the 8250, the following restrictions apply to the values specified for the ByteSize and StopBits members:
The number of data bits must be 5 to 8 bits.
The use of 5 data bits with 2 stop bits is an invalid combination, as is 6, 7, or 8 data bits with 1.5 stop bits.
Requirements
Client
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server
Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header
Declared in Winbase.h; include Windows.h.
See Also
BuildCommDCB
ClearCommError
EscapeCommFunction
GetCommState
SetCommState
Send comments about this topic to Microsoft
Build date: 8/10/2007
#11
type commprop from structure
integer wPacketLength
integer wPacketVersion
long dwServiceMask
long dwReserved1
long dwMaxTxQueue
long dwMaxRxQueue
long dwMaxBaud
long dwProvSubType
long dwProvCapabilities
long dwSettableParams
long dwSettableBaud
integer wSettableData
integer wSettableStopParity
long dwCurrentTxQueue
long dwCurrentRxQueue
long dwProvSpec1
long dwProvSpec2
character wcProvChar[1]
end type
type commtimeouts from structure
long ReadIntervalTimeout
long ReadTotalTimeoutMultiplier
long ReadTotalTimeoutConstant
long WriteTotalTimeoutMultiplier
long WriteTotalTimeoutConstant
end type
type dcb from structure
long DCBlength
long RaudRate
long fBinary
long fParity
long fOutxCtsFlow
long fOutxDsrFlow
long fDtrControl
long fDsrSensitivity
long fTXContinueOnXoff
long fOutX
long fInX
long fErrorChar
long fNull
long fRtsControl
long fAbortOnError
long fDummy2
integer wReserved
integer XonLim
integer XoffLim
character ByteSize
character Parity
character StopBits
character XonChar
character XoffChar
character ErrorChar
character EofChar
character EvtChar
character wReserved1
end type
#1
转的是16进制吧?
string 就行了.
string 就行了.
#2
我知道这些数据的格式和内容,但我如何用PB读取出来?
#3
你不是说得到这些数据了么? 这些数据一般是通过函数读取得到啊.
#4
你这个问题主要是串口通讯的问题,帮你找了两个网址,自己去看下吧
http://bbs.lzjtu.edu.cn/bbsanc.php?path=%2Fgroups%2Fsci.faq%2FComputer%2FProgramOld%2FDatabase%2F3%2F2%2F1%2F52.txt
http://topic.csdn.net/u/20071011/18/fdd22298-4a23-40cc-9817-03056f725991.html?1451975628
http://bbs.lzjtu.edu.cn/bbsanc.php?path=%2Fgroups%2Fsci.faq%2FComputer%2FProgramOld%2FDatabase%2F3%2F2%2F1%2F52.txt
http://topic.csdn.net/u/20071011/18/fdd22298-4a23-40cc-9817-03056f725991.html?1451975628
#5
感觉现在很少用到这类技术了,因为现在的硬件大部分都是USB接口的东东了。楼主居然还能遇到串口通讯的设备,真是不幸。
#6
大概了解,但要用到mscomm组件的,对mscomm组件的函数完全陌生,有没有例子?
#7
怎么没高手指点啊?
现在遇到新问题,就是我在pb中无法注册mscomm.ocx控件,采用多种方法注册后,仍然在insert control中找不到Microsoft Communications Control,请指点,谢谢!
现在遇到新问题,就是我在pb中无法注册mscomm.ocx控件,采用多种方法注册后,仍然在insert control中找不到Microsoft Communications Control,请指点,谢谢!
#8
你的设备有开发SDK吧,直接找开发商,不好浪费时间搞这东西
#9
看了这个,但dcb类型在PB中是不接受的,PB中这个类型是什么?
#10
DCB是个结构体,需要在PB中自己定义的。具体的DCB描述自己可以参阅MSDN文档之类的资料,下面给出我在MSDN查阅的关于DCB结构体的描述。
DCB Structure
Defines the control setting for a serial communications device.
typedef struct _DCB { DWORD DCBlength;
DWORD BaudRate;
DWORD fBinary :1;
DWORD fParity :1;
DWORD fOutxCtsFlow :1;
DWORD fOutxDsrFlow :1;
DWORD fDtrControl :2;
DWORD fDsrSensitivity :1;
DWORD fTXContinueOnXoff :1;
DWORD fOutX :1;
DWORD fInX :1;
DWORD fErrorChar :1;
DWORD fNull :1;
DWORD fRtsControl :2;
DWORD fAbortOnError :1;
DWORD fDummy2 :17;
WORD wReserved;
WORD XonLim;
WORD XoffLim;
BYTE ByteSize;
BYTE Parity;
BYTE StopBits;
char XonChar;
char XoffChar;
char ErrorChar;
char EofChar;
char EvtChar;
WORD wReserved1;
} DCB, *LPDCB;
Members
DCBlength
The length of the structure, in bytes. The caller must set this member to sizeof(DCB).
BaudRate
The baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes.
Value Meaning
CBR_110
110
110 bps
CBR_300
300
300 bps
CBR_600
600
600 bps
CBR_1200
1200
1200 bps
CBR_2400
2400
2400 bps
CBR_4800
4800
4800 bps
CBR_9600
9600
9600 bps
CBR_14400
14400
14400 bps
CBR_19200
19200
19200 bps
CBR_38400
38400
38400 bps
CBR_57600
57600
57600 bps
CBR_115200
115200
115200 bps
CBR_128000
128000
128000 bps
CBR_256000
256000
256000 bps
fBinary
If this member is TRUE, binary mode is enabled. Windows does not support nonbinary mode transfers, so this member must be TRUE.
fParity
If this member is TRUE, parity checking is performed and errors are reported.
fOutxCtsFlow
If this member is TRUE, the CTS (clear-to-send) signal is monitored for output flow control. If this member is TRUE and CTS is turned off, output is suspended until CTS is sent again.
fOutxDsrFlow
If this member is TRUE, the DSR (data-set-ready) signal is monitored for output flow control. If this member is TRUE and DSR is turned off, output is suspended until DSR is sent again.
fDtrControl
The DTR (data-terminal-ready) flow control. This member can be one of the following values.
Value Meaning
DTR_CONTROL_DISABLE
0x00
Disables the DTR line when the device is opened and leaves it disabled.
DTR_CONTROL_ENABLE
0x01
Enables the DTR line when the device is opened and leaves it on.
DTR_CONTROL_HANDSHAKE
0x02
Enables DTR handshaking. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
fDsrSensitivity
If this member is TRUE, the communications driver is sensitive to the state of the DSR signal. The driver ignores any bytes received, unless the DSR modem input line is high.
fTXContinueOnXoff
If this member is TRUE, transmission continues after the input buffer has come within XoffLim bytes of being full and the driver has transmitted the XoffChar character to stop receiving bytes. If this member is FALSE, transmission does not continue until the input buffer is within XonLim bytes of being empty and the driver has transmitted the XonChar character to resume reception.
fOutX
Indicates whether XON/XOFF flow control is used during transmission. If this member is TRUE, transmission stops when the XoffChar character is received and starts again when the XonChar character is received.
fInX
Indicates whether XON/XOFF flow control is used during reception. If this member is TRUE, the XoffChar character is sent when the input buffer comes within XoffLim bytes of being full, and the XonChar character is sent when the input buffer comes within XonLim bytes of being empty.
fErrorChar
Indicates whether bytes received with parity errors are replaced with the character specified by the ErrorChar member. If this member is TRUE and the fParity member is TRUE, replacement occurs.
fNull
If this member is TRUE, null bytes are discarded when received.
fRtsControl
The RTS (request-to-send) flow control. This member can be one of the following values.
Value Meaning
RTS_CONTROL_DISABLE
0x00
Disables the RTS line when the device is opened and leaves it disabled.
RTS_CONTROL_ENABLE
0x01
Enables the RTS line when the device is opened and leaves it on.
RTS_CONTROL_HANDSHAKE
0x02
Enables RTS handshaking. The driver raises the RTS line when the "type-ahead" (input) buffer is less than one-half full and lowers the RTS line when the buffer is more than three-quarters full. If handshaking is enabled, it is an error for the application to adjust the line by using the EscapeCommFunction function.
RTS_CONTROL_TOGGLE
0x03
Specifies that the RTS line will be high if bytes are available for transmission. After all buffered bytes have been sent, the RTS line will be low.
Windows Me/98/95: This value is not supported.
fAbortOnError
If this member is TRUE, the driver terminates all read and write operations with an error status if an error occurs. The driver will not accept any further communications operations until the application has acknowledged the error by calling the ClearCommError function.
fDummy2
Reserved; do not use.
wReserved
Reserved; must be zero.
XonLim
The minimum number of bytes allowed in the input buffer before flow control is activated to inhibit the sender. Note that the sender may transmit characters after the flow control signal has been activated, so this value should never be zero. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl.
XoffLim
The maximum number of bytes allowed in the input buffer before flow control is activated to allow transmission by the sender. This assumes that either XON/XOFF, RTS, or DTR input flow control is specified in fInX, fRtsControl, or fDtrControl. The maximum number of bytes allowed is calculated by subtracting this value from the size, in bytes, of the input buffer.
ByteSize
The number of bits in the bytes transmitted and received.
Parity
The parity scheme to be used. This member can be one of the following values.
Value Meaning
EVENPARITY
2
Even parity.
MARKPARITY
3
Mark parity.
NOPARITY
0
No parity.
ODDPARITY
1
Odd parity.
SPACEPARITY
4
Space parity.
StopBits
The number of stop bits to be used. This member can be one of the following values.
Value Meaning
ONESTOPBIT
0
1 stop bit.
ONE5STOPBITS
1
1.5 stop bits.
TWOSTOPBITS
2
2 stop bits.
XonChar
The value of the XON character for both transmission and reception.
XoffChar
The value of the XOFF character for both transmission and reception.
ErrorChar
The value of the character used to replace bytes received with a parity error.
EofChar
The value of the character used to signal the end of data.
EvtChar
The value of the character used to signal an event.
wReserved1
Reserved; do not use.
Remarks
When a DCB structure is used to configure the 8250, the following restrictions apply to the values specified for the ByteSize and StopBits members:
The number of data bits must be 5 to 8 bits.
The use of 5 data bits with 2 stop bits is an invalid combination, as is 6, 7, or 8 data bits with 1.5 stop bits.
Requirements
Client
Requires Windows Vista, Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, or Windows 95.
Server
Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server.
Header
Declared in Winbase.h; include Windows.h.
See Also
BuildCommDCB
ClearCommError
EscapeCommFunction
GetCommState
SetCommState
Send comments about this topic to Microsoft
Build date: 8/10/2007
#11
type commprop from structure
integer wPacketLength
integer wPacketVersion
long dwServiceMask
long dwReserved1
long dwMaxTxQueue
long dwMaxRxQueue
long dwMaxBaud
long dwProvSubType
long dwProvCapabilities
long dwSettableParams
long dwSettableBaud
integer wSettableData
integer wSettableStopParity
long dwCurrentTxQueue
long dwCurrentRxQueue
long dwProvSpec1
long dwProvSpec2
character wcProvChar[1]
end type
type commtimeouts from structure
long ReadIntervalTimeout
long ReadTotalTimeoutMultiplier
long ReadTotalTimeoutConstant
long WriteTotalTimeoutMultiplier
long WriteTotalTimeoutConstant
end type
type dcb from structure
long DCBlength
long RaudRate
long fBinary
long fParity
long fOutxCtsFlow
long fOutxDsrFlow
long fDtrControl
long fDsrSensitivity
long fTXContinueOnXoff
long fOutX
long fInX
long fErrorChar
long fNull
long fRtsControl
long fAbortOnError
long fDummy2
integer wReserved
integer XonLim
integer XoffLim
character ByteSize
character Parity
character StopBits
character XonChar
character XoffChar
character ErrorChar
character EofChar
character EvtChar
character wReserved1
end type