serial port communication and my.application.doevents changed

07/04/2008 - 11:16 von Uwe Renschler | Report spam
Hello,
I upgraded from Visual Basic6 t Visual Basic 2008. I have an application
which writes a hex file to a comport.
The comport selection is nice on Visual Basic 2008, but the software didn t
work any more. I assume it is the behaviour of the my.application.doevents
together with the serial port. (see my code below)
Has anybody an idea how to resolve this ?

I wish all developers a nice bugfree day.

Cheers
Uwe Renschler
email: uwe@renschler.de


For i = 1 To Len(l) Step 2
sendchar = Mid(l, i, 2)
sc = Convert.ToInt32(sendchar, 16)
SerialPort1.Write(sc)
'MSComm1.Output = sc has been the visual basic 6 code, which
works
cc = cc + 1
'Stop
Next i
'this sends the hex data to the com port.
'MSComm1.InBufferCount = 0 ' Clear input buffer
Timer1.Interval = 500
Timer1.Enabled = True
'Stop
Do
My.Application.DoEvents() ' visual basic 6 has a dummy =
doevents
Loop Until SerialPort1.BytesToRead >= 1 Or timeout > 60000
' I always run into the timeout, cause the device doesn t repond cause
nothing has been send.
Uwe Renschler
 

Lesen sie die antworten

#1 Peter Götz
07/04/2008 - 11:39 | Warnen spam
Hallo Uwe,

Hello,
I upgraded from Visual Basic6 t Visual Basic 2008.
I have an application which writes a hex file to a
comport.
The comport selection is nice on Visual Basic 2008,
but the software didn t work any more. I assume it is
the behaviour of the my.application.doevents
together with the serial port. (see my code below)
Has anybody an idea how to resolve this ?



Das "de.german" im Namen der NG làsst eigentlich
kaum Zweifel offen, dass es sich hier um eine
deutschsprachige NG handelt.

.

For i = 1 To Len(l) Step 2
sendchar = Mid(l, i, 2)



Wer oder was ist dieses l im Ausdruck Mid(l,i,2)?
Welchen konkreten Inhalt hat es?


sc = Convert.ToInt32(sendchar, 16)
SerialPort1.Write(sc)
'MSComm1.Output = sc has been the
visual basic 6 code, which works
cc = cc + 1



Wie und wo ist cc deklariert?

'Stop
Next i
'this sends the hex data to the com port.
'MSComm1.InBufferCount = 0 ' Clear input buffer
Timer1.Interval = 500
Timer1.Enabled = True



Was machst Du mit diesem Timer?

'Stop
Do
My.Application.DoEvents() ' visual basic 6
has a dummy =doevents
Loop Until SerialPort1.BytesToRead >= 1
Or timeout > 60000
' I always run into the timeout, cause the device
doesn t repond cause nothing has been send.



Mit Deinem Codefragment wird nicht so wirklich
klar, was Du da eigentlich machst.
Schau Dir vielleicht mal

www.gssg.de -> Visual Basic -> VB.net
-> SerialPort (RS232) Chat

an.

Gruß aus St.Georgen
Peter Götz
www.gssg.de (mit VB-Tipps u. Beispielprogrammen)

Ähnliche fragen