Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Coding (clearing the buffer)

Status
Not open for further replies.

bbqrob8

Technical User
Mar 26, 2003
8
CA
Can anyone help me with my code? I want to clear the message from the display, and display another one to it. I thought i could clear the buffer but it doesnt want to do it. I am using the dcd and dsr line for input and i wanted to OR the two, to give various results.
My first message comes up then when a volt comes on the DSR line i have a message to be displayed, but the original message will stay there!!
Heres the beginning of my code:
Option Explicit
Private Declare Function SER_OPEN& Lib "SERSEN04.DLL" (ByVal commPort&, ByVal baudRate&)
Private Declare Function SER_CLOSE& Lib "SERSEN04.DLL" ()
Private Declare Sub SER_SEND Lib "SERSEN04.DLL" (theString$)
Private Declare Sub SER_RAWSEND Lib "SERSEN04.DLL" (theString$)
Dim intEnd As Integer

Private Sub cmdExit_Click()
intEnd = 1
End

End Sub

Private Sub cmdStart_Click()
MSComm1.PortOpen = True
Dim SerData As Integer, SerData1 As Integer
MSComm1.Output = "normal"

If MSComm1.DSRHolding > 0 Or MSComm1.CDHolding = 1 Then
'MSComm1.OutBufferCount = 0
'MSComm1.PortOpen = False
'MSComm1.PortOpen = True
MSComm1.Output = "Crying"

'If MSComm1.DSRHolding = False Then
'MSComm1.Output = "" 'Text2.Text
Else
MSComm1.Output = ""
End If
'Loop
'If MSComm1.DSRHolding = True Then
' MSComm1.InBufferCount = 0


' MSComm1.Output = "Crying"
'Else
' MSComm1.Output = ""

'MSComm1.PortOpen = False
' End If

End Sub

Private Sub Form_Load()
frmdetect.Top = (Screen.Height - frmdetect.Height) / 2
frmdetect.Left = (Screen.Width - frmdetect.Width) / 2

End Sub


Private Sub Delay(HowLong As Date)
Dim TempTime As Date
TempTime = DateAdd("s", HowLong, Now)
While TempTime > Now
DoEvents 'Allows windows to handle other stuff
Wend

End Sub

 
is this related to the LCD mentioned in earlier threads...

are you trying to clear the LCD display?? If somethings hard to do, its not worth doing - Homer Simpson
 
Adoozer:
Yes, I am trying to clear the LCD display, this is something that i have no idea. I though about looping something blank, hoping to clear it but to no avail.
 
what make is the LCD??
is there any documentation online??
is there not a clearLCD command you can send to it??

many questions i know, but it like wearing a blindfold and trying to walk upstairs on your hands!!

good luck! If somethings hard to do, its not worth doing - Homer Simpson
 
Adoozer:
thanks that worked!

Now i need to know how to start a loop over after it is completed. My program is looping looking for a particular input, and when that criteria is met it displays a message. What i need to know is how to start the loop again looking for something else, and resetting the info that it found previously.
 
im not 100% sure, ive not read the full documentation yet,

what are you wanting to loop? the message?

are you sending text to the lcd display with say an mp3 file name, playing the mp3, clearing the display and then sending the name of a new mp3 or are you just looking for highs and lows on the DSR and CD lines?!?

have you got a rough outline of what you are trying to do?

good luck! If somethings hard to do, its not worth doing - Homer Simpson
 
Adoozer:

i am looping looking for a the dsr and cd lines, their state. Then i wanted to be able to disable them, after they are enabled and loop again, looking for the state again. I am not sure if this is even possible.

this is what i got so far:
Private Sub cmdStart_Click()
MSComm1.PortOpen = True

Dim SerData As Integer, SerData1 As Integer
MSComm1.Output = "Normal1" 'Text4.Text
Dim fso
Dim monitor
StartOver: monitor
Do Until MSComm1.DSRHolding = True Or intEnd=1 'Or MSComm1.CTSHolding = True
Delay 1
If MSComm1.DSRHolding = False Then
MSComm1.Output = Chr$(0)
If MSComm1.CTSHolding = True Then
MSComm1.Output = Chr$(1)
MSComm1.Output = " Message "
End If
End If
Loop

If MSComm1.DSRHolding = True Then
MSComm1.Output = Chr$(1)
MSComm1.Output = "Message2"
Delay 1
If MSComm1.CTSHolding = False Then
MSComm1.Output = Chr$(1)
MSComm1.Output = "Message3"

End If

End If
GoTo StartOver: monitor

MSComm1.PortOpen = False

End Sub


I tried to start it over and check the states but it don't work, and i have no idea what to do. I tried putting in another loop, but i got trapped in the inner loop when the program was running, so i gave that idea up.

Anyidea would help!
 
sorry to keep replying with questions, but what is setting the DSR and CD lines?

secondly could you not try (bearing in mind i dont know exactly what you want)

Code:
dim myExitLoop as boolean  'set to true to exit the loop

do
doevents
if MSComm1.DSRHolding then
   'do whatever needs doing if DSRHolding is true
elseif MSComm1.CDHolding then
   'do whatever needs doing if CDHolding is true
end if
loop until MyExitLoop=true

hope this helps a little more!! If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top