English
Forum

RS 232 Handshake lines

 

GDL
Hi,

knows of you someone, How one with Profan on The Handshake lines(CTS would long) grab or. the value settle can ?

Hello
Georg
 
Windows7 Xprofan 8,9,10 [...]  [...] 
05/07/06  
 




Ragnar
Rehbein
yes:
CompileMarkSeparation
def createfile(7)  !"kernel32.dll","CreateFileA"
def getlasterror(0)  !"kernel32.dll","GetLastError"
def FormatMessage(7) !"Kernel32.dll","FormatMessageA"
def EscapeCommFunction(2)  !"kernel32.dll","EscapeCommFunction"
def GetCommModemStatus(2)  !"kernel32.dll","GetCommModemStatus"
def &clrbreak 0
def &clrdtr 6
def &clrrts 4
def &setbreak 8
def &setdtr 5
def &setrts 3
def &setxoff 1
def &setxon 2
def &cts_on $10
def &dsr_on $20
def &ring_on $40
def &rlsd_on $80
declare hport&    porthandle
declare modemstatus&  Modemstatus
declare ret&, message#

Proc lasterrorstring   nur um den Text des letzten Fehlers von GetLastError zu bekommen

    dim message#,1029
    declare buffer&, flags&,source&,language&,arguments&, errorstring$
    buffer& = 1024
    flags& = $1000
    language& =  0 ~lang_neutral
    clear message#
    FormatMessage((flags&),addr(source&),GetLastError(),(language&),message#,addr(buffer&),addr(arguments&))
    errorstring$ = trim$(string$(message#,0))
    dispose message#
    return errorstring$

endproc

hport& = createfile("COM1",0,0,0,3,0,0)opencom("COM1",1024,1024)
print "Porthandle :",hport&
print
ret& = EscapeCommFunction(hport&,&setdtr)
print "DTR setzen"
case ret& = 0 : print "Fehler"
print lasterrorstring()
-----am besten einen Schalter zwischen DTR und z.B. CTS setzen
ret& = GetCommModemStatus(hport&,addr(modemstatus&))
print
print "Status der Eingänge ermitteln"
case ret& = 0 : print "Fehler"
print lasterrorstring()
-----Maskierung um an die einzelnen Bits zu kommen

if ret&

    casenot modemstatus& & $FF : print "alles auf LOW"
    case modemstatus& & &cts_on  : print "CTS ON"
    case modemstatus& & &dsr_on  : print "DSR ON"
    case modemstatus& & &ring_on : print "Ring ON"
    case modemstatus& & &rlsd_on : print "RLSD ON"

endif

waitinput
print "Start"
declare zeit&,stop&,count&
zeit& = &gettickcount

whilenot stop&

    whileloop 10

        ret& = GetCommModemStatus(hport&,addr(modemstatus&))
        print modemstatus&,"";
        inc count&

    endwhile

    sleep 1
    case &gettickcount - zeit& > 50 : stop& = 1

endwhile

print ""
print &gettickcount - zeit&
print "durchläufe :",count&
closecom(hport&)waitinput

was only time so one testprogramm circa altogether 4 switch seriell abzufragen.
Please not so critically his

r.r.
 
05/11/06  
 




GDL
Hello Ragnar (hope)

many Thanks.so paradox this sound likes, but I must The CTS pipeline as Sendeleitung missbrauchen, there with DCCNMRA only nobodies transfer go.

0 bit lasts 58 ms
1 bit lasts 109 ms
Trennbit lasts 230 ms.

The reason: so one The Lokomotiven on the track turn can is no Highbit Auswertung possible.
so one too without I/O ticket rad can, this ploy.

Hello
Georg
 
Windows7 Xprofan 8,9,10 [...]  [...] 
05/11/06  
 




Ragnar
Rehbein
Hello georg !

i see not integrally How one CTS as sendeleitung using can.
CTS is still only one entry and can itself to my knowledge not umprogrammieren.

but independent of it .. having you my zeilen help can ?
or had You the already ?

ragnar
 
05/11/06  
 




GDL
Hello Ragnar,

your code helps on any Cases moreover.

CTS has too The RS232 as exit circa one modem communicating to,whether The interface empafangsbereit is.

How before described, go only Low states ausgewertet.

the heist.
CTS becomes on standardmäßig on High staid.
with one zero bit becomes The pipeline for 58 ms on Low staid.
with one Highbit for 109 ms etc.
Startbit is a Präambel from 10 zero Bits one after another.

The actual RS232 Lines and irgendeine Baudrate go NOT using.it'll solely a pipeline needed.

Why:
the Ausgangssignal and Computermasse go one Booster zugeführt.The power from it +18 and -18 Volt rectangle.
now have I on the track on the a Anschluss The Rechteckspannung and on the others The volume.

with normalen RS 232 and Minimodem in the Lok could The Lok only in a direction the track staid go, there otherwise Yes The Empfangsleitung the Lok(abgenommen over The Räder) on volume läge.
accordingly scheidet the normal RS232 lane from.
Solution:
in the Lok operates one Microcontroler the The abfallende and steigende centre pass in the Spannungversorgung recognize and the Time between both misst.

usually gives one The signals through 8255 I/O ticket from.there most normalen computer(no Industrierechner) no ISA Slots More and have PCI cards extreme valuable are,make I this lane over The RS232,Centronics and USB interface.where only More The RS232 abging.

Hello
Georg
 
Windows7 Xprofan 8,9,10 [...]  [...] 
05/11/06  
 




GDL
Hello Ragnar,

have your code adjusted. must but yet after a settimer Anpassung search,there settimer 1 not unterschiedlichen Taktfrequenzen exakt 1 ms is.

get this but certainly there.

Hello and over again thanks
Georg
 
Windows7 Xprofan 8,9,10 [...]  [...] 
05/22/06  
 




Ragnar
Rehbein
minimale timerzyklen lying between 10 - 20 ms, according to betriebssystem.
settimer 1 becomes always zyklen > 1 ms produce.
CompileMarkSeparation
decimals 0
Def QPF(1 )!"KERNEL32","QueryPerformanceFrequency"   rückgabe als LARGE_INTEGER
Def QPC(1 )!"KERNEL32","QueryPerformanceCounter"     rückgabe als LARGE_INTEGER
Declare time#
dim time#,8
declare cpu!

proc laint2float   wandelt einen longintiger in einen fload um / leider recht zeitintensiv

    parameters t&
    declare t#,ta&
    dim t#,8
    declare z!
    ta& = t#   adresse speichern
    t# = t&

    whileloop 8

        z! = z! + byte(t#,&loop-1)*(Pow(256,&loop-1))

    endwhile

    t# = ta&   wieder die alte adresse zuweisen
    dispose t#
    return z!

endproc

if qpf(time#)

    print "es gibt einen QueryPerformanceCounter"
    cpu! = laint2float(time#)

else

    print "es gibt keinen QueryPerformanceCounter !"
    waitinput
    end

endif

print "HiPerfFreq.: ",cpu!
settimer 1

WhileLoop 20

    qpc(time#)
    AddString str$(laint2float(time#))+"  wert in ms: "+str$(laint2float(time#)/cpu!*1000)
    waitinput  bedarfsweise auskommentieren dann dauert ein schleifendurchlauf 1-2 ms

Wend

ListBox$("QueryPerformanceCounter"2)

so can too smaller ones zeitabstände Is it Unikode.
becomes but from older boards not supported.

r.r.
 
05/22/06  
 




GDL
Hello Ragnar,

have now so experimented, get but my Frequenzperioden of 0.056 ms 0,128 ms and 0,230 ms +/- max. 3% Fluctuation not there.

Nutze momentarily The RS232 normal with nem Atmel Microcontroler in the Verbindungs- pipeline.(should but only Notlösung his).

Hello
Georg
 
Windows7 Xprofan 8,9,10 [...]  [...] 
05/24/06  
 




Ragnar
Rehbein
these accuracy is with XProfan well you don't say so his.
through the interpretermodus (too one kompiliertes prg becomes interprets) is the abarbeitung in profane too slow.
evtl. would it possible Profan2C++ To benefit.
otherwise remaining only assambler.

r.r.
 
05/29/06  
 



Answer


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.996 Views

Untitledvor 0 min.
Langer04/06/18
dr.dirk09/17/13

Themeninformationen

this Topic has 2 subscriber:

GDL (5x)
Ragnar Rehbein (4x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie