Home > database >  Questions about the pb programming and mouth, please call
Questions about the pb programming and mouth, please call

Time:09-29

Some problems consult ace ha, text is as follows:
(1) open the serial port 9600, N, 8, 1
(2) send four bytes 0 XFF,
0 xaa, XX, YYThe first two bytes are fixed,
Behind two bytes is a customer to output parameters, XX bit0 ~ bit7 corresponds to the control panel of relay grade 0 to 7, YY bit0 ~ 1 label corresponding to relay 8 ~ 9.

How to translate into pb language, I know is to use a serial port programming, is don't know how to value, vb I have been debugging through, is not implemented in the pb, please expert advice,

Vb code is as follows:


'open the serial port
Private Sub Command1_Click ()


MPort=5 MSComm1.Com

MSComm1. RThreshold=1
MSComm1. InputLen=1


If MSComm1. PortOpen=False Then
MSComm1. PortOpen=True
End the If



End Sub

'perform data output

'send four bytes 0 XFF. Zero xaa, XX, YY
'the first two bytes are fixed,
'behind two bytes is a customer to output parameters, XX bit0 ~ bit7 corresponds to the control panel of relay grade 0 to 7, YY bit0 ~ 1 label corresponding to relay 8 ~ 9.

Private Sub Command2_Click (Index As an Integer)
Dim sendtemp (0) As Byte
Const sendcmd=& amp; HFF
Sendtemp (0)=sendcmd
MSComm1. The Output=sendtemp ()

Sendtemp (0)=& amp; HAA
MSComm1. The Output=sendtemp ()

Sendtemp (0)=0 'modify parameters can output different relay state here
MSComm1. The Output=sendtemp ()

Sendtemp (0)=0 'modify parameters can output different relay state here
MSComm1. The Output=sendtemp ()



End Sub

Private Sub Command3_Click (Index As an Integer)
Dim sendtemp (0) As Byte
Const sendcmd=& amp; HFF
Sendtemp (0)=sendcmd
MSComm1. The Output=sendtemp ()

Sendtemp (0)=& amp; HAA
MSComm1. The Output=sendtemp ()

Sendtemp (0)=& amp; HFF 'modify parameters can output different relay state here
MSComm1. The Output=sendtemp ()

Sendtemp (0)=11 'modify parameters can output different relay state here
MSComm1. The Output=sendtemp ()

End Sub

CodePudding user response:

Didn't do serial program, are turning to online more popular this period, if not, you can study together
How to realize serial programming in the original concept

You can use mscomm32. Ocx.

The script is as follows:

String ls_data
//use COM1 port,
MPort=1
ole_1.object.Com//set rate for 9600, parity, 8 bits of data, and a stop bit.
Ole_1. Object. Settings="9600, N, 8, 1", "
//read the data of the buffer,
Ole_1. Object. InputLen=0
Open port
Ole_1. Object. PortOpen=True

//send command attention
Ole_1. Object. The Output="ATV1Q0" + char (13)

//wait for data,
Do
The Yield ()
//data from the Com port
+=ls_data ole_1. Object. Input
LOOP Until (Pos (ls_data, "OK" + char (13) + char (10)) & gt; 0)

//to the Com port to send data using the Output method
Ole_1. Object. The Output=ls_data

//close port,
Ole_1. Object. PortOpen=FALSE

CodePudding user response:

Make a serial port, a online pbcomm. PBL download, to look for you,
Or, in c # serial port is more convenient, pb to the underlying point is,

CodePudding user response:

Top,

CodePudding user response:

Try moving a think, you can, it is nothing to difficult.
First of all, the registered Mscomm32. Ocx.
Then, OLE controls in the PB window.
Sometimes Mscomm32. Ocx will find license, need to manually modify the registry.
HKEY_CLASSES_ROOT \ Licenses
Then create a new item, named: "4250 e830-6 ac2-11 cf - 8 adb - 00 aa00c00905"
Value is: "kjljvjjjoquqmjjjvpqqkqmqykypoqjquoun
"Then send you an example. Oneself fumble.

CodePudding user response:

http://download.csdn.net/source/1797026

CodePudding user response:

See information send when a simple question with a blob or char [] sent better

CodePudding user response:

Happen information remember to add char (0)

CodePudding user response:

Learning thank you upstairs on November 15, 2009, 13 when 5 minutes and 17 seconds
  • Related