|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Serial communication
Hi, dear friend,
Can anybody answer my question? thanks a lot! I'm doing my school project. It's about to record the Temperature and the humidity in the greenhouse. The data is transmitted through RS232, the folowing is code, but anyway, I can only record one data Temperature, but how can I record humidity at the same time? Millions of thanks! Private Sub Form_Load() With MSComm1 .CommPort = 1 .Settings = "9600,N,8,1" .InputMode = comInputModeText .RThreshold = 1 .InputLen = 0 .PortOpen = True .RTSEnable = True End With End Sub Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then tmpstr$ = MSComm1.Input txtTemp.Text = tmpstr$ End If End sub |
|
#2
|
|||
|
|||
|
Why are you limited to only Temperature? You can send any string you want over a serial line, you can combine Temp and Humidity in some kind of delimited string.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#3
|
|||
|
|||
|
Quote:
Yes, I have tried to do this, following is my code, but I caould not get the correct value. The data is sent in Binary format through 8052 Micro ropcessor. By the way, how can i convert it into decimal format? Thanks a lot! I'm new to VB. Private Sub MSComm1_OnComm() If MSComm1.CommEvent = comEvReceive Then tmpstr$ = MSComm1.Input Dim tmp%, hum%, scn% tmp% = Asc(Left(tmpstr$, 1)) hum% = Asc(Mid(tmpstr$, 2, 1)) txtTemp.Text = tmp% txtHum.Text = hum% End If Pingping |
|
#4
|
|||
|
|||
|
See if this can help:
'SimpleBinaryToString converts binary data (VT_UI1 | VT_ARRAY Or MultiByte string) 'to a string (BSTR) using MultiByte VBS functions Function SimpleBinaryToString(Binary) Dim I, S For I = 1 To LenB(Binary) S = S & Chr(AscB(MidB(Binary, I, 1))) Next SimpleBinaryToString = S End Function |
![]() |
| Viewing: ASP Free Forums > Programming > Visual Basic Programming > Serial communication |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
![]() |
|