Home > database >  Pb to realize data, read the com read is null.
Pb to realize data, read the com read is null.

Time:09-16

PB8, I want to a serial port to send data after receiving and displayed in the text box, why received is empty?
It is code, ace to help me analyse what went wrong?

//use COM1 port,
MPort=1
ole_2.object.Com//set rate for 9600, parity, 8 bits of data, and a stop bit.
Ole_2. Object. Settings="9600, N, 8, 1", "
//read the data of the buffer,

If ole_2. Object. PortOpen=true then
Ole_2. Object. PortOpen=false
End the if

Ole_2. Object. PortOpen=True

String ls_re_data

Ls_re_data=""
Mle_1. Text=""

Messagebox (' 1 ', '1')
Ole_2. Object. InputLen=0
//open port
Ole_2. Object. An InputMode=0

//Ole_2. Object. OutBufferCount=0//empty send buffer
//ole_2. Object. InBufferCount=0

Ole_2. Object. The output="h"

Messagebox (' a ', 'a')
Sleep (5)
Messagebox (' b ', 'b')
Ls_re_data=https://bbs.csdn.net/topics/string (ole_2. Object. Input)
Messagebox (' ls_re_data 'ls_re_data)

Mle_1. Text=ls_re_data

CodePudding user response:

refer to the original poster u011643825 response:
PB8, I want to achieve after to a serial port to send data in the receiving and displayed in the text box, why received is empty?
It is code, ace to help me analyse what went wrong?

//use COM1 port,
MPort=1
ole_2.object.Com//set rate for 9600, parity, 8 bits of data, and a stop bit.
Ole_2. Object. Settings="9600, N, 8, 1", "
//read the data of the buffer,

If ole_2. Object. PortOpen=true then
Ole_2. Object. PortOpen=false
End the if

Ole_2. Object. PortOpen=True

String ls_re_data

Ls_re_data=""
Mle_1. Text=""

Messagebox (' 1 ', '1')
Ole_2. Object. InputLen=0
//open port
Ole_2. Object. An InputMode=0

//Ole_2. Object. OutBufferCount=0//empty send buffer
//ole_2. Object. InBufferCount=0

Ole_2. Object. The output="h"

Messagebox (' a ', 'a')
Sleep (5)
Messagebox (' b ', 'b')
Ls_re_data=https://bbs.csdn.net/topics/string (ole_2. Object. Input)
Messagebox (' ls_re_data 'ls_re_data)

Mle_1. Text=ls_re_data


If you want to receive, you need to send a continuous process, can receive and send you after receiving, of course, there is no data again

CodePudding user response:

There are serial debugging tools, you download, there can continue to simulate the function of sending data

CodePudding user response:

http://download.csdn.net/detail/afu1972715000/5270164
This is my own writing pb9.0 serial port communication, hope to be of any help to you,
  • Related