1. Dashboard
  2. Mitglieder
    1. Letzte Aktivitäten
    2. Benutzer online
    3. Team
    4. Mitgliedersuche
  3. Forenregeln
  4. Forum
    1. Unerledigte Themen
  • Anmelden
  • Registrieren
  • Suche
Alles
  • Alles
  • Artikel
  • Seiten
  • Forum
  • Erweiterte Suche
  1. AutoIt.de - Das deutschsprachige Forum.
  2. Mitglieder
  3. vivus

Beiträge von vivus

  • Befehle an COM 1 senden

    • vivus
    • 24. Juni 2010 um 13:06
    Zitat von Schnitzel

    Der thread ist über ein Jahr als-->Leichenschänder :D

    und bitte so lange Quelltexte Spoilern

    ;) besser spät als nie ... und wir wollen ja alle, dass die suche in AutoIt weiter so gut funktioniert, damit nicht immer die gleichen fragen beantwortet werden müssen ..

    globales wachsen des kollektiven Wissens ;)

    PS: hab gedacht, wenn ich auf "AutoIt-Quellcode gehe, dass er automatisch gespoilert wird .. tüt mich sorryyy !!


    .. hier aber noch n paar beispiele ..

    Spoiler anzeigen

    ;Example program showing how to use some of the commMg3.au3 UDF functions
    ;this example is a very simple terminal
    ;Version 2 26th July 2006
    ;changes-
    ;change flow control checkbox to combo and add NONE
    ;correct error in call to _CommSetPort - stop bits were missing which meant th eflow control was used for stop bits

    #include <GUIConstants.au3>
    #include 'CommMG.au3';or if you save the commMg.dll in the @scripdir use #include @SciptDir & '\commmg.dll'
    #include <GuiEdit.au3>
    #include <GuiComboBox.au3>
    #include <windowsconstants.au3>
    #include <buttonconstants.au3>

    Opt("WINTITLEMATCHMODE", 3)
    OnAutoItExitRegister("alldone")
    HotKeySet("{ESC}", "alldone")

    $result = '';used for any returned error message setting port
    Const $settitle = "COMMG Example - set Port", $maintitle = "COMMG Example"
    $setflow = 2;default to no flow control
    Dim $FlowType[3] = ["XOnXoff", "Hardware (RTS, CTS)", "NONE"]
    #Region main program

    #Region ### START Koda GUI section ### Form=d:\my documents\miscdelphi\commg\ExampleComm.kxf
    $Form2 = GUICreate("COMMG Example", 473, 349, 339, 333, BitOR($WS_MAXIMIZEBOX, $WS_MINIMIZEBOX, $WS_SIZEBOX, $WS_THICKFRAME, $WS_SYSMENU, $WS_CAPTION, $WS_OVERLAPPEDWINDOW, $WS_TILEDWINDOW, $WS_POPUP, $WS_POPUPWINDOW, $WS_GROUP, $WS_TABSTOP, $WS_BORDER, $WS_CLIPSIBLINGS))
    $Edit1 = GUICtrlCreateEdit("", 10, 25, 449, 223, BitOR($ES_AUTOVSCROLL, $ES_AUTOHSCROLL, $ES_READONLY, $ES_WANTRETURN, $WS_HSCROLL, $WS_VSCROLL))
    $BtnSend = GUICtrlCreateButton("Send", 380, 273, 53, 30, $BS_FLAT)
    $Input1 = GUICtrlCreateInput("", 18, 279, 361, 21)
    $Checkbox1 = GUICtrlCreateCheckbox("Add LF to incomming CR", 273, 4, 145, 17)
    GUICtrlSetState(-1, $GUI_CHECKED)
    GUICtrlSetResizing(-1, $GUI_DOCKAUTO)
    $Label11 = GUICtrlCreateLabel("Text to send", 24, 261, 63, 17)
    $BtnSetPort = GUICtrlCreateButton("Set Port", 16, 312, 73, 30, $BS_FLAT)
    $Label21 = GUICtrlCreateLabel("Received text", 34, 6, 70, 17)
    $Label31 = GUICtrlCreateLabel("commg.dll version unknown", 272, 328, 135, 17)
    GUICtrlSetColor(-1, 0x008080)
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###
    WinSetTitle($Form2, "", $maintitle & " UDF = " & _CommGetVersion(1))

    While setport(0) = -1
    If MsgBox(4, 'Port not set', 'Do you want to quite the program?') = 6 Then Exit
    WEnd


    #cs
    _CommSwitch(2)
    MsgBox(0,'set com11 res = ',_CommSetport(11,$result,9600,8,'none',1,1))
    MsgBox(0,'set port 11 gives',$result)
    _CommSendString("It's Monday" & @CR)
    _CommSwitch(1)
    AdlibEnable("port11",500)
    #ce


    ;GUISwitch($Form2)
    ConsoleWrite("stage 1" & @CRLF)
    GUICtrlSetData($Label31, 'using ' & _CommGetVersion(1))
    ConsoleWrite("stage 2" & @CRLF)
    Events()

    GUICtrlSetState($Edit1, $GUI_FOCUS)

    While 1

    ;gets characters received returning when one of these conditions is met:
    ;receive @CR, received 20 characters or 200ms has elapsed
    $instr = _CommGetString()

    If $instr <> '' Then;if we got something

    If GUICtrlRead($Checkbox1) = $GUI_CHECKED Then $instr = StringReplace($instr,@CR,@CRLF)
    GUICtrlSetData($Edit1, $instr,1)

    EndIf

    WEnd

    Alldone()


    Func port11()
    ;MsgBox(0,'now set to channel',_CommSwitch(2))
    _commSwitch(2)
    $s2 = "1 2 3 4";_CommGetString()
    ConsoleWrite("comm1 gets " & $s2 & @CRLF)
    _CommSendString($s2)
    _CommSwitch(1)

    EndFunc ;==>port11

    #EndRegion main program
    Func Events()
    Opt("GUIOnEventMode", 1)
    GUISetOnEvent($GUI_EVENT_CLOSE, "justgo")
    GUICtrlSetOnEvent($BtnSend, "SendEvent")
    GUICtrlSetOnEvent($BtnSetPort, "SetPortEvent")
    EndFunc ;==>Events

    Func SetPortEvent()
    setport();needed because a parameter is optional for setport so we can't use "setport" for the event
    GUICtrlSetState($Edit1, $GUI_FOCUS)
    EndFunc ;==>SetPortEvent

    Func justgo()
    Exit
    EndFunc ;==>justgo

    Func SendEvent();send the text in the inputand append CR
    _CommSendstring(GUICtrlRead($Input1) & @CR)
    GUICtrlSetData($Input1, '');clear the input
    ;GUICtrlSetState($edit1,$GUI_FOCUS);sets the caret back in the terminal screen
    EndFunc ;==>SendEvent


    Func AllDone()
    ;MsgBox(0,'will close ports','')
    _Commcloseport()
    ;MsgBox(0,'port closed','')
    Exit
    EndFunc ;==>AllDone


    ; Function SetPort($mode=1)
    ; Creates a form for the port settings
    ;Parameter $mode sets the return value depending on whether the port was set
    ;Returns 0 if $mode <> 1
    ; -1 If` the port not set and $mode is 1
    Func SetPort($mode = 1);if $mode = 1 then returns -1 if settings not made

    Opt("GUIOnEventMode", 0);keep events for $Form2, use GuiGetMsg for $Form3

    #Region ### START Koda GUI section ### Form=d:\my documents\miscdelphi\commg\examplecommsetport.kxf
    $Form3 = GUICreate("COMMG Example - set Port", 422, 279, 329, 268, BitOR($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_GROUP, $WS_BORDER, $WS_CLIPSIBLINGS, $DS_MODALFRAME), BitOR($WS_EX_TOPMOST, $WS_EX_WINDOWEDGE))
    $Group1 = GUICtrlCreateGroup("Set COM Port", 18, 8, 288, 252)
    $CmboPortsAvailable = GUICtrlCreateCombo("", 127, 28, 145, 25)
    $CmBoBaud = GUICtrlCreateCombo("9600", 127, 66, 145, 25, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL, $CBS_SORT, $WS_VSCROLL))
    GUICtrlSetData(-1, "10400|110|115200|1200|128000|14400|150|15625|1800|19200|2000|2400|256000|28800|3600|38400|4800|50|56000|57600|600|7200|75")
    $CmBoStop = GUICtrlCreateCombo("1", 127, 141, 145, 25)
    GUICtrlSetData(-1, "1|2|1.5")
    $CmBoParity = GUICtrlCreateCombo("none", 127, 178, 145, 25)
    GUICtrlSetData(-1, "odd|even|none")
    $Label2 = GUICtrlCreateLabel("Port", 94, 32, 23, 17)
    $Label3 = GUICtrlCreateLabel("baud", 89, 70, 28, 17)
    $Label4 = GUICtrlCreateLabel("No. Stop bits", 52, 145, 65, 17)
    $Label5 = GUICtrlCreateLabel("parity", 88, 182, 29, 17)
    $CmboDataBits = GUICtrlCreateCombo("8", 127, 103, 145, 25)
    GUICtrlSetData(-1, "7|8")
    $Label7 = GUICtrlCreateLabel("No. of Data Bits", 38, 107, 79, 17)
    $ComboFlow = GUICtrlCreateCombo("NONE", 127, 216, 145, 25)
    GUICtrlSetData(-1, "NONE|XOnXOff|Hardware (RTS, CTS)")
    $Label1 = GUICtrlCreateLabel("flow control", 59, 220, 58, 17)
    GUICtrlCreateGroup("", -99, -99, 1, 1)
    $BtnApply = GUICtrlCreateButton("Apply", 315, 95, 75, 35, $BS_FLAT)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    $BtnCancel = GUICtrlCreateButton("Cancel", 316, 147, 76, 35, $BS_FLAT)
    GUICtrlSetFont(-1, 12, 400, 0, "MS Sans Serif")
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###


    WinSetTitle($Form3, "", $settitle);ensure a change to Koda design doesn't stop script working
    $mainxy = WinGetPos($Form2)
    WinMove($Form3, "", $mainxy[0] + 20, $mainxy[1] + 20)
    ;$set = _CommSetport(1,$result,9600,8,0,1,0)
    ;help
    ;send /rcv
    ;
    $portlist = _CommListPorts(0);find the available COM ports and write them into the ports combo
    If @error = 1 Then
    MsgBox(0, 'trouble getting portlist', 'Program will terminate!')
    Exit
    EndIf


    For $pl = 1 To $portlist[0]
    GUICtrlSetData($CmboPortsAvailable, $portlist[$pl]);_CommListPorts())
    Next
    GUICtrlSetData($CmboPortsAvailable, $portlist[1]);show the first port found
    GUICtrlSetData($ComboFlow, $FlowType[$setflow])
    _GUICtrlComboBox_SetMinVisible($CmBoBaud, 10);restrict the length of the drop-down list

    $retval = 0

    While 1
    $msg = GUIGetMsg()
    If $msg = $BtnCancel Then
    If Not $mode Then $retval = -1
    ExitLoop
    EndIf


    If $msg = $BtnApply Then
    Local $sportSetError
    $comboflowsel = GUICtrlRead($ComboFlow)
    For $n = 0 To 2
    If $comboflowsel = $FlowType[$n] Then
    $setflow = $n
    ConsoleWrite("flow = " & $setflow & @CRLF)
    ExitLoop
    EndIf

    Next
    $setport = StringReplace(GUICtrlRead($CmboPortsAvailable), 'COM', '')
    _CommSetPort($setport, $sportSetError, GUICtrlRead($CmBoBaud), GUICtrlRead($CmboDataBits), GUICtrlRead($CmBoParity), GUICtrlRead($CmBoStop), $setflow)
    if $sportSetError = '' Then
    MsgBox(262144, 'Connected ','to COM' & $setport)
    Else
    MsgBox(262144, 'Setport error = ', $sportSetError)
    EndIf
    $mode = 1;
    ExitLoop
    EndIf

    ;stop user switching back to $form2
    If WinActive($maintitle) Then
    ConsoleWrite('main is active' & @CRLF)
    If WinActivate($settitle) = 0 Then MsgBox(0, 'not found', $settitle)
    EndIf


    WEnd
    GUIDelete($Form3)
    WinActivate($maintitle)
    Events()
    Return $retval


    EndFunc ;==>SetPort

  • Befehle an COM 1 senden

    • vivus
    • 24. Juni 2010 um 11:52

    hab mal die neuste Version gegoogelt ;)

    hier der LINK
    http://www.mosaiccgl.co.uk/AutoItDownload…get=COMMGv2.zip

  • Befehle an COM 1 senden

    • vivus
    • 24. Juni 2010 um 11:48

    hab hier die elegantere Lösung

    commg.dll

    lässt sich mit

    Spoiler anzeigen
    [autoit]

    ;Opt("mustdeclarevars",1) testing only
    #cs
    UDF for commg.dll
    V1.0 Replaces mgcomm.au3
    #ce
    Const $sUDFVersion = 'CommMG.au3 V2.1 '
    #cs
    Version 2.1.1 Added missing declarations which caused problems in scripts using Opt("MustDeclareVars",1) - thanks to Hannes
    Version 2.1 Thanks to jps1x2 for the read/send bte array incentive and testing.
    Version 2.0.2 beta changed readbytearray so returns no of bytes read
    Version 2.0.1 beta
    added _CommSendByteArray and _CommReadByteArray
    Version 2.0 - added _CommSwitch. Can now use up to 4 ports.
    added option for flow control = NONE to _CommSetPort

    AutoIt Version: 3.2.3++
    Language: English

    Description: Functions for serial comms using commg.dll
    Works with COM ports, USB to Serial converters, Serial to RS424 etc

    Functions available:
    _CommGetVersion
    _CommListPorts
    _CommSetPort
    _CommPortConnection
    _CommClearOutputBuffer
    _CommClearInputBuffer
    _CommGetInputcount
    _CommGetOutputcount
    _CommSendString
    _CommGetString
    _CommGetLine
    _CommReadByte
    _CommReadChar
    _CommSendByte
    _CommSendBreak; not tested!!!!!!!!!!
    _CommCloseport
    _CommSwitch
    _CommSendByteArray
    _CommReadByteArray

    Author: Martin Gibson
    #ce
    #include-once

    [/autoit] [autoit][/autoit] [autoit]

    Global $fPortOpen = False
    Global $hDll

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _CommListPorts($iReturnType=1)
    ; Description: Gets the list of available ports seperated by '|' or as an array
    ;
    ; Parameters: $iReturnType - integer:if $iReturnType = 1 then return a string with the list of COM ports seperated by '|'
    ; if $iReturnType <> 1 then return an array of strings, with element [0] holding the number of COM ports
    ; Returns; on success - a string eg 'COM1|COM8', or array eg ['2','COM1','COM2']
    ; on failure - an empty string and @error set to 1 if dll could not list any ports
    ; @error set to 2 id dll not open and couldn't be opened

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    Func _CommListPorts($iReturnType = 1)
    Local $vDllAns, $lpres
    If Not $fPortOpen Then
    $hDll = DllOpen('commg.dll')
    If $hDll = -1 Then
    SetError(2)
    ;$sErr = 'Failed to open commg.dll'
    Return 0;failed
    EndIf
    $fPortOpen = True
    EndIf
    If $fPortOpen Then
    $vDllAns = DllCall($hDll, 'str', 'ListPorts')
    If @error = 1 Then
    SetError(1)
    Return ''
    Else

    ;ConsoleWrite($vDllAns[0] & @CRLF)
    If $iReturnType = 1 Then
    Return $vDllAns[0]
    Else
    Return StringSplit($vDllAns[0], '|')
    EndIf


    EndIf
    Else
    SetError(1)
    Return ''
    EndIf

    [/autoit] [autoit][/autoit] [autoit]


    EndFunc ;==>_CommListPorts

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _Commgetversion($iType = 1)
    ; Description: Gets the version of the dll if $iType = 1
    ; Or the version of this UDF if $iType = 2
    ; Parameters: $iType - integer: = 1 to reurn the commg.dll version
    ; = 2 to return the UDF version
    ; Returns; on success - a string eg 'V1.3'
    ; on failure - an empty string and @error set to 1

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Func _CommGetVersion($iType = 1)
    Local $vDllAns
    If $iType = 2 Then Return $sUDFVersion

    If $fPortOpen Then
    $vDllAns = DllCall($hDll, 'str', 'Version')

    If @error = 1 Then
    SetError(1)
    ConsoleWrite('error in get version' & @CRLF)
    Return ''
    Else
    ;ConsoleWrite('length of version is ' & stringlen($vDllAns[0]) & @CRLF)
    Return $vDllAns[0]

    EndIf
    Else
    $vDllAns = DllCall('commg.dll', 'str', 'Version')
    If @error = 1 Then
    SetError(1)
    ConsoleWrite('error in get version' & @CRLF)
    Return ''
    Else
    ;ConsoleWrite('length of version is ' & stringlen($vDllAns[0]) & @CRLF)
    Return $vDllAns[0]
    EndIf
    EndIf

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_CommGetVersion

    [/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ;
    ; Function Name: _CommSwitch($channel)
    ;switches functions to operate on channel 1, 2, 3 or 4
    ;if $channel > 4 then switches to 1
    ;returns on succes the channel switched to ie 1 or 2
    ; on failure -1
    ;Remarks on start up of script channel 1 is selected, so if you only need one COM port
    ; you don't need to use _CommSwitch
    ; each channel needs to be set up with _CommSetPort
    ; The same COM port cannot be used on more than one channel.
    ; The channel number is not related to the COM port number, so channel 1 can
    ; be set to use COM2 and channel 4 can be set to use COM1 or any available port.
    ;======================================================================================
    Func _CommSwitch($channel)
    Local $vDllAns

    [/autoit] [autoit][/autoit] [autoit]

    $vDllAns = DllCall($hDll, 'int', 'switch', 'int', $channel)
    If @error <> 0 Then
    SetError(1)
    Return -1
    Else
    Return $vDllAns[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_CommSwitch

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===========================================================================================================
    ;
    ; Function Name: _CommSetport($iPort,ByRef $sErr,$iBaud=9600,$iBits=8,$vDllAnsar=0,$iStop=1,$iFlow=0)
    ; Description: Initialises the port and sets the parameters
    ; Parameters: $iPort - integer = the port or COM number to set. Allowed values are 1 or higher.
    ; NB WIndows refers To COM10 Or higher`as \\.\com10 but only use the number 10, 11 etc
    ; $sErr - string: the string to hold an error message if func fails.
    ; $iBaud - integer: the baud rate required. allowed values are one of
    ; 50, 75, 110, 150, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600, 10400,
    ; 14400, 15625, 19200, 28800, 38400, 56000, 57600, 115200, 128000, 256000
    ; $iBits - integer: number of bits in code to be transmitted
    ; $iParity - integer: 0=None,1=Odd,2=Even,3=Mark,4=Space
    ; $iStop - integer: number of stop bits, 1=1 stop bit 2 = 2 stop bits, 15 = 1.5 stop bits
    ; $iFlow - integer: 0 sets hardware flow control,
    ; 1 sets XON XOFF control,
    ; 2 sets NONE i.e. no flow control.
    ; Returns; on success - returns 1 and sets $sErr to ''
    ; on failure - returns 0 and with the error message in $sErr, and sets @error as follows
    ; @error meaning error with
    ; 1 dll call failed
    ; 2 dll was not open and could not be opened
    ; -1 $iBaud
    ; -2 $iStop
    ; -4 $iBits
    ; -8 $iPort = 0 not allowed
    ; -16 $iPort not found
    ; -32 $iPort access denied (in use?)
    ; -64 unknown error
    ;Remarks You cannot set the same COM port on more than one channel
    ;===========================================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommSetPort($iPort, ByRef $sErr, $iBaud = 9600, $iBits = 8, $iPar = 0, $iStop = 1, $iFlow = 0)
    Local $vDllAns
    Local $sMGBuffer = ''
    $sErr = ''
    If Not $fPortOpen Then
    $hDll = DllOpen('commg.dll')
    If $hDll = -1 Then
    SetError(2)
    $sErr = 'Failed to open commg.dll'
    Return 0;failed
    EndIf
    $fPortOpen = True
    EndIf
    ConsoleWrite('port = ' & $iPort & ', baud = ' & $iBaud & ', bits = ' & $iBits & ', par = ' & $iPar & ', stop = ' & $iStop & ', flow = ' & $iFlow & @CRLF)

    $vDllAns = DllCall($hDll, 'int', 'SetPort', 'int', $iPort, 'int', $iBaud, 'int', $iBits, 'int', $iPar, 'int', $iStop, 'int', $iFlow)
    If @error <> 0 Then
    $sErr = 'dll SetPort call failed'
    SetError(1)
    Return 0
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    If $vDllAns[0] < 0 Then
    SetError($vDllAns[0])
    Switch $vDllAns[0]
    Case - 1
    $sErr = 'undefined baud rate'
    Case - 2
    $sErr = 'undefined stop bit number'
    Case - 4
    $sErr = 'undefined data size'
    Case - 8
    $sErr = 'port 0 not allowed'
    Case - 16
    $sErr = 'port does not exist'
    Case - 32
    $sErr = 'access denied, maybe port already in use'
    Case - 64
    $sErr = 'unknown error accessing port'
    EndSwitch
    Return 0
    Else
    Return 1
    EndIf

    EndFunc ;==>_CommSetPort

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===================================================================================
    ;
    ; Function Name: _CommPortConnection()
    ; Description: Gets the port connected to the selected channel - see _CommSwitch
    ; Parameters: None
    ; Returns; on success - a string eg 'COM5'
    ; on failure - an empty string and @error set to the rerror set by DllCall
    ; Remarks - Can be used to verify the port is connected

    [/autoit] [autoit][/autoit] [autoit]

    ;====================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommPortConnection()
    Local $vDllAns
    $vDllAns = DllCall($hDll, 'str', 'Connection');reply is port eg COM8

    [/autoit] [autoit][/autoit] [autoit]

    If @error <> 0 Then
    SetError(@error)
    Return ''
    Else
    Return $vDllAns[0]
    EndIf


    EndFunc ;==>_CommPortConnection

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;=====================================================================================
    ;
    ; Function Name: _CommSendString($sMGString,$iWaitComplete=0)
    ; Description: Sends a string to the connected port on the currently selected channel
    ; Parameters: $sMGString: the string to send sent without any extra CR or LF added.
    ; $iWaitComplete- integer:0 = do not wait till string sent
    ; 1 = wait till sent
    ; Returns: always 1
    ; on success- @error set to 0
    ; on failure - @error set to the error returned from DllCall
    ;======================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommSendString($sMGString, $iWaitComplete = 0)
    ;sends $sMGString on the currently open port
    ;returns 1 if ok, returns 0 if port not open/active
    Local $vDllAns
    $vDllAns = DllCall($hDll, 'int', 'SendString', 'str', $sMGString, 'int', $iWaitComplete)
    If @error <> 0 Then
    SetError(@error)
    Return ''
    Else
    Return $vDllAns[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]

    EndFunc ;==>_CommSendString

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;================================================================================
    ;
    ; Function Name: _CommGetstring()
    ; Description: Get whatever characters are available received by the port for the selected channel
    ; Parameters: none
    ; Returns: on success the string and @error is 0
    ; if input buffer empty then empty string returned
    ; on failure an empty string and @error set to the error set by DllCall
    ; Notes: Use GetLIne to get a whole line treminated by @CR or a defined character.
    ;=================================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _Commgetstring()
    ;get a string NB could be part of a line depending on what is in buffer
    Local $vDllAns
    ;$sStr1 = ''
    ;$vDllAns = DllCall($hDll,'str','GetByte')
    $vDllAns = DllCall($hDll, 'str', 'GetString')

    If @error <> 0 Then
    SetError(1)
    ConsoleWrite('error in _commgetstring' & @CRLF)
    Return ''
    EndIf
    Return $vDllAns[0]
    EndFunc ;==>_Commgetstring

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;====================================================================================
    ;
    ; Function Name: _CommGetLine($EndChar = @CR,$maxlen = 10000, $maxtime = 10000)
    ; Description: Get a string ending in $lineEnd
    ; Parameters: $lineEnd the character to indicate the end of the string to return.
    ; The $lineEnd character is included in the return string.
    ; $MaxLen - integer: the maximum length of a string before
    ; returning even if $linEnd not received
    ; If $maxlen is 0 then there is no number of characters
    ; $maxtime - integer:the maximum time in mS to wait for the $EndChar before
    ; returning even if $linEnd not received.
    ; If $maxtime is 0 then there is no max time to wait
    ;
    ; Returns: on success the string and @error is 0
    ; If $maxlen characters received without the $lineEnd character, then these
    ; characters are returned and @error is set To -1.
    ; If $maxtime passes without receiving the $lineEnd character, then the characters
    ; received so far are returned and @error is set To -2.
    ; on failure areturns any characters reeived and sets @error to 1
    ;======================================================================================
    Func _CommGetLine($sEndChar = @CR, $maxlen = 0, $maxtime = 0)
    Local $vDllAns, $sLineRet, $sStr1, $waited, $sNextChar, $iSaveErr

    [/autoit] [autoit][/autoit] [autoit]

    $sStr1 = ''; $sMGBuffer
    $waited = TimerInit()

    While 1;stringinstr($sStr1,$EndChar) = 0
    If TimerDiff($waited) > $maxtime And $maxtime > 0 Then
    SetError(-2)
    Return $sStr1
    EndIf


    If StringLen($sStr1) >= $maxlen And $maxlen > 0 Then
    SetError(-1)
    Return $sStr1
    EndIf
    ;$ic = _CommGetInputCount()
    $sNextChar = _CommReadChar()
    $iSaveErr = @error
    If $iSaveErr = 0 And $sNextChar <> '' Then

    $sStr1 = $sStr1 & $sNextChar
    ;ConsoleWrite($sStr1 & @CRLF)
    If $sNextChar = $sEndChar Then ExitLoop

    EndIf

    If $iSaveErr <> 0 Then
    SetError(1)
    Return $sStr1
    EndIf

    WEnd

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    Return $sStr1
    EndFunc ;==>_CommGetLine

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;============================================================================
    ;
    ; Function Name: _CommGetInputCount()
    ; Description: Get the number of characters available to be read from the port.
    ; Parameters: none
    ; Returns: on success a string conversion of the number of characters.(eg '0', '26')
    ; on failure returns an empty string and sets @error to 1
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommGetInputCount()
    Local $vDllAns
    $vDllAns = DllCall($hDll, 'str', 'GetInputCount')

    If @error <> 0 Then
    SetError(1)
    Return 0
    Else
    Return $vDllAns[0]

    EndIf

    [/autoit] [autoit][/autoit] [autoit]


    EndFunc ;==>_CommGetInputCount

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;============================================================================
    ;
    ; Function Name: _CommGetOutputCount()
    ; Description: Get the number of characters waiting to be sent from the port.
    ; Parameters: none
    ; Returns: on success a string conversion of the number of characters.(eg '0', '26')
    ; on failure returns an empty string and sets @error to 1
    ;===============================================================================
    Func _CommGetOutputCount()
    Local $vDllAns

    [/autoit] [autoit][/autoit] [autoit]

    $vDllAns = DllCall($hDll, 'str', 'GetOutputCount')

    If @error <> 0 Then
    SetError(1)
    Return ''
    Else
    Return $vDllAns[0]
    EndIf

    [/autoit] [autoit][/autoit] [autoit]


    EndFunc ;==>_CommGetOutputCount

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;================================================================================================
    ;
    ; Function Name: _CommReadByte($wait = 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: Reads the byte as a string
    ; Parameters: $wait:integer if 0 then if no data to read then return -1 and set @error to 1
    ; if <> 0 then does not return untill a byte has been read
    ; Returns: on success a string conversion of the value of the byte read.(eg '0', '20')
    ; on failure returns empty string and sets @error to 1 if no data to read and $wait is 0
    ; Returns empty string and sets @error to 2 ifDllCall failed
    ;
    ;;NB could hang if nothing rec'd when wait is <> 0
    ;==================================================================================================
    Func _CommReadByte($wait = 0)
    Local $iCount, $vDllAns
    If Not $wait Then
    $iCount = _CommGetInputCount()
    If $iCount = 0 Then
    SetError(1)
    Return ''
    EndIf
    EndIf

    $vDllAns = DllCall($hDll, 'str', 'GetByte')

    If @error <> 0 Then
    SetError(2)
    Return ''
    EndIf
    ;ConsoleWrite('byte read was ' & $vDllAns[0] & @CRLF)
    Return $vDllAns[0]

    EndFunc ;==>_CommReadByte

    [/autoit] [autoit][/autoit] [autoit]

    ;============================================================================
    ;
    ; Function Name: _CommReadChar($wait = 0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: Reads the next Character as a string
    ; Parameters: $wait:integer if 0 then if no data to read then return -1 and set @error to 1
    ; if <> 0 then does not return untill a byte has been read
    ; Returns: on success a string of 1 character
    ; on failure returns empty string and sets @error to 1
    ;
    ;
    ;;NB could hang if nothing rec'd when wait is <> 0
    ;===============================================================================

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommReadChar($wait = 0)
    Local $sChar, $iErr

    [/autoit] [autoit][/autoit] [autoit]

    $sChar = _CommReadByte($wait)
    $iErr = @error
    If $iErr > 2 Then
    SetError(1)
    Return ''
    EndIf
    If $iErr == 0 Then Return Chr(Execute($sChar))
    EndFunc ;==>_CommReadChar

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;============================================================================
    ; Function Name: SendByte($byte,$iWaitComplete=0)

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: Sends the byte value of $byte. $byte must be in range 0 to 255
    ; Parameters: $byte the byte to send.
    ; $iWaitComplete - integer: if 0 then functions returns without
    ; waiting for byte to be sent
    ; If <> 0 then waits till byte sent.
    ; Returns: on success returns 1
    ; on failure returns -1 and sets @error to 1
    ;
    ;;NB could hang if byte cannot be sent and $iWaitComplete <> 0
    ;===============================================================================
    Func _CommSendByte($byte, $iWaitComplete = 0)
    Local $vDllAns

    [/autoit] [autoit][/autoit] [autoit]

    $vDllAns = DllCall($hDll, 'int', 'SendByte', 'int', $byte, 'int', $iWaitComplete)
    If @error <> 0 Then
    SetError(1)
    Return -1
    Else
    Return $vDllAns[0]
    EndIf

    EndFunc ;==>_CommSendByte

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: _CommSendByteArray($pAddr,$iNum,$iWait)

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: Sends the bytes from address $pAddress
    ; Parameters: $iNum the number of bytes to send.
    ; $iWaitComplete - integer: if 0 then functions returns without
    ; waiting for bytes to be sent
    ; if <> 0 then waits untill all bytes are sent.
    ; Returns: on success returns 1
    ; on failure returns -1 and sets @error to 1
    ;
    ;;NB could hang if byte cannot be sent and $iWaitComplete <> 0
    ; could lose data if you send more bytes than the size of the outbuffer.
    ; the output buffer size is 2048
    ;===============================================================================
    Func _CommSendByteArray($pAddr, $iNum, $iWait)
    Local $vDllAns = DllCall($hDll, 'int', 'SendByteArray', 'ptr', $pAddr, 'int', $iNum, 'int', $iWait)
    If @error <> 0 Or $vDllAns[0] = -1 Then
    SetError(1)
    Return -1
    Else
    Return $vDllAns[0]
    EndIf

    EndFunc ;==>_CommSendByteArray

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;====================================================================================
    ; Function Name: _CommReadByteArray($pAddr,$iNum,$iWait)
    ;
    ; Description: Reads bytes and writes them to memory starting at address $pAddress
    ; Parameters: $iNum the number of bytes to read.
    ; $iWaitComplete - integer: if 0 and then the functions returns
    ; with the available bytes up to $iNum.
    ; if 1 then waits untill the $iNum bytes received.
    ; Returns: on success returns the Number of bytes read.
    ; on failure returns -1 and sets @error to 1
    ;
    ;;NB could hang if bytes are not received and $iWaitComplete <> 0
    ; the input buffer size is 4096
    ;====================================================================================
    Func _CommReadByteArray($pAddr, $iNum, $iWait)
    Local $vDllAns = DllCall($hDll, 'int', 'ReadByteArray', 'ptr', $pAddr, 'int', $iNum, 'int', $iWait)
    If @error <> 0 Or $vDllAns[0] = -1 Then
    SetError(1)
    Return -1
    Else
    Return $vDllAns[0]
    EndIf


    EndFunc ;==>_CommReadByteArray

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: ClearOutputBuffer()

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: Clears any characters in the out put queue5
    ; Parameters: none
    ; Returns: on success returns 1
    ; on failure returns -1 and sets @error to 1
    ;
    ;===============================================================================
    Func _CommClearOutputBuffer()

    Local $vDllAns = DllCall($hDll, 'int', 'ClearOutputBuffer')

    EndFunc ;==>_CommClearOutputBuffer

    [/autoit] [autoit][/autoit] [autoit]

    Func _CommClearInputBuffer()
    Local $sMGBuffer = ''
    Local $vDllAns = DllCall($hDll, 'int', 'ClearInputBuffer')
    If @error <> 0 Then
    Return -1
    Else
    Return 1
    EndIf

    EndFunc ;==>_CommClearInputBuffer

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;===============================================================================
    ; Function Name: ClosePort()

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: closes the port

    [/autoit] [autoit][/autoit] [autoit]

    ; Parameters: none

    [/autoit] [autoit][/autoit] [autoit]

    ; Returns: no return value
    ;===============================================================================
    Func _CommClosePort()
    ;_CommClearOutputBuffer()
    ;_CommClearInputBuffer()
    DllCall($hDll, 'int', 'CloseDown')
    DllClose($hDll)
    $fPortOpen = False
    EndFunc ;==>_CommClosePort

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    ;================================================================================================
    ; Function Name: SendBreak($iDowTime,$iUpTime)
    ; NB Simulates the break signal used by some equipment to indicate the start of a sequence
    ; Not tested so might Not work. Any feedback welcome - PM martin on Autoit forum

    [/autoit] [autoit][/autoit] [autoit]

    ; Description: sets the TX line low for $iDowTime, then sets it high for $iUpTime

    [/autoit] [autoit][/autoit] [autoit]

    ; Parameters: $iDowTime - integer: the number of ms to hold the TX line down
    ; $iUpTime - integer: the number of ms to hold the line up for before returning
    ; if $iDowTime or $iUpTime is zero then does nothing and returns
    ; Returns: on success returns 1
    ; on failure returns 0 and sets @error to
    ; = 1 if one of params is zero
    ; = 2 1 unable to use the DLL file,
    ; = 3 unknown "return type" from dll
    ; = 4 "function" not found in the DLL file.

    [/autoit] [autoit][/autoit] [autoit]

    ; Notes : Not tested!
    ;================================================================================================
    Func _CommSendBreak($iDowTime, $iUpTime);requires commg.dll v2.0 or later
    Local $vDllAns
    If $iDowTime = 0 Or $iUpTime = 0 Then
    SetError(1)
    Return 0
    EndIf

    If Not $fPortOpen Then
    SetError(1)
    Return 0
    EndIf
    $vDllAns = DllCall($hDll, 'int', 'SendBreak', 'int', $iDowTime, 'int', $iUpTime)
    If @error <> 0 Then
    SetError(@error + 1)
    Return 0
    Else
    ;ConsoleWrite('done setbreak' & @CRLF)
    Return 1;success
    EndIf

    EndFunc ;==>_CommSendBreak

    [/autoit]

    wunder bar bearbeiten ... ;)

    somit kann man auf die MSCOMMLib.MsComm verzichten ..

    bye

    Edit BugFix:
    Die Benutzung des Spoilers ist nicht nur möglich, sondern ausdrücklich erwünscht. (Tags gesetzt)

  • Toleranz

    • vivus
    • 3. Dezember 2009 um 16:05

    JAA !! LECK !! der GAIT !!

    s ganze Wochenende !! n schwarzer Bildschirm .. *g*


    und jetzt geht's !!

    jjuuhuuu !! DANKE !!

    jetzt nur noch die Frage .. WARUM ?!

    also dass ich den String in eine numerische Entsprechung umwandeln muss is mir jetzt klar..

    aber warum funktioniert das nicht . mit dem normalen string ?!

    warum numerisch ?!

  • Toleranz

    • vivus
    • 3. Dezember 2009 um 15:38

    Hi @ all

    bin schon ewig am tüfteln .. bekomm's aber einfach nicht hin.

    mein Zeil : eine Toleranzbereichs Abfrage.

    d.h. ich habe 3 Werte , $min , $messwert, $max und will am ende einen gut ( 1 ) oder schlecht (0) Ergebniss.

    z.B.

    $min / $messwert / $max / = $ergebniss

    1 / 2 / 3 / = 1

    -1 / 2 / 3 / = 1

    -3 / -2 / -1 / = 1

    -2 / -1 / 3 / = 1

    .. so sollte es sein. ist ja auch logisch ..
    alle anderen Messungen oder halt Möglichkeiten, sollten ja mit 0 zum Ergebnis führen.

    bekomme es aber absolut nicht hin.

    Problem macht mir das negative Vorzeichen.

    hier meine Ansätze: aber nicht wirklich brauch bahr.... ;(

    [autoit]


    While 1

    $min = InputBox("min", "min toleranz eingeben")
    $messwert = InputBox("messwert", "messwert eingeben")
    $max = InputBox("max", "maxtoleranz eingeben")

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    MsgBox(0, "ergebniss", _toleranzcheck($min, $messwert, $max))

    [/autoit][autoit][/autoit][autoit]

    WEnd

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    Func _toleranzcheck($min, $messwert, $max)

    [/autoit][autoit][/autoit][autoit]

    $messwert = StringReplace($messwert, "+", "")
    $max = StringReplace($max, "+", "")
    $min = StringReplace($min, "+", "")

    [/autoit][autoit][/autoit][autoit]

    ; werte sind negativ oder normal .. aber alle ohne + zeichen

    [/autoit][autoit][/autoit][autoit]

    ;if StringInStr($min, "-") = "1" Then Return 0
    ;if StringInStr($messwert, "-") = "1" Then Return 0
    ;if StringInStr($max, "-") = "1" Then Return 0

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    If $min < $messwert And $messwert < $max Then
    Return "1"

    [/autoit][autoit][/autoit][autoit]

    Else
    Return "0"

    [/autoit][autoit][/autoit][autoit]

    EndIf

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]

    EndFunc ;==>_toleranzcheck

    [/autoit][autoit][/autoit][autoit]

    #cs
    Func _toleranzcheck($messwert, $max, $min)

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,"übergabe",$min & " " &$messwert&" "& $max)

    [/autoit][autoit][/autoit][autoit]

    $messwert = StringReplace($messwert, "+", "")
    $max = StringReplace($max, "+", "")
    $min = StringReplace($min, "+", "")

    [/autoit][autoit][/autoit][autoit]

    MsgBox(0,"nach umwandlung in reele zahlen",$min & " " &$messwert&" "& $max)

    [/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit][/autoit][autoit]

    $x = _Max(25, 10) ; Gibt 25 zurück

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    $ergebniss_max= StringCompare($max, $messwert)
    $ergebniss_min= StringCompare($messwert,$min)

    [/autoit][autoit][/autoit][autoit]

    Return $ergebniss_max &" "& $ergebniss_min

    [/autoit][autoit][/autoit][autoit]

    EndFunc

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    #ce

    [/autoit][autoit][/autoit][autoit]

    #cs

    [/autoit][autoit][/autoit][autoit]

    Func _toleranzcheck($messwert, $max, $min)

    [/autoit][autoit][/autoit][autoit]

    $messwert_nativ = StringReplace($messwert, "+", "")
    $messwert_nativ = StringReplace($messwert, "-", "")

    [/autoit][autoit][/autoit][autoit]

    If StringInStr($messwert, "+") = "1" Then
    ;MsgBox(0,"","wert = positiv")

    [/autoit][autoit][/autoit][autoit]

    If StringInStr($max, "+") = "1" And StringInStr($min, "+") = "1" Then
    $max = StringReplace($max, "+", "")
    $min = StringReplace($min, "+", "")
    If $messwert_nativ > $min And $messwert_nativ < $max Then
    ;MsgBox(0,"","und im tolleranz bereich")
    Return "pg"
    EndIf
    ElseIf StringInStr($max, "+") = "1" And StringInStr($min, "-") = "1" Then
    $max = StringReplace($max, "+", "")
    $min = StringReplace($min, "-", "")
    If $messwert_nativ > $min And $messwert_nativ < $max Then
    ;MsgBox(0,"","und im tolleranz bereich")
    Return "pg"
    EndIf

    [/autoit][autoit][/autoit][autoit]

    ElseIf StringInStr($messwert, "-") = "1" Then
    ;MsgBox(0,"","wert = negativ" & StringReplace($parameter[2], "-", ""))
    If StringReplace($messwert, "-", "") > "0.0" And StringReplace($messwert, "-", "") < $min Then
    ;MsgBox(0,"","und im tolleranz bereich")
    Return "ng"
    EndIf

    [/autoit][autoit][/autoit][autoit]

    Else
    ;MsgBox(0,"","wert = error ")
    Return "error"
    EndIf
    EndIf
    EndFunc ;==>_toleranzcheck

    [/autoit][autoit][/autoit][autoit][/autoit][autoit]

    #ce

    [/autoit]
  • Win 7 AUTOIT

    • vivus
    • 12. November 2009 um 08:00

    also geht immer noch nicht ...

    zuerst hab ich mal die dateiendungen aktiviert, damit man überhaupt irgend was mit win 7 anstellen kann ..
    dann habe ich den regeditor aktiviert, damit man ihn überhaupt erst mal benutzen kann ..

    .. komisches windows ...

    danach die Einträge so geändert wie in den oberen links beschrieben ...
    was auch immer das gebracht haben soll ...

    aber funktionieren tut die hilfe immer noch nicht ..

    .. ich probiers auf jeden fall mal weiter ..

  • befehle am ende meines programms werden nicht ausgeführt.

    • vivus
    • 12. November 2009 um 00:12

    kannst du mal den ganzen code posten ?!

    hab grad probleme mich da einzudenken, wenn ich den rest nicht kenn ..

    mich wundert noch die while schleife .. am ende ..

  • DLL Open / Call zu langsam

    • vivus
    • 11. November 2009 um 17:18

    wrapper-dll in Freebasic .. hört sich doch jetzt mal sehr interessant an !!

    werd ich mich jetzt mal einlesen ..

  • Kann es sein, das Autoit WinClose manchmal einfach nicht funktioniert? wie debuggen?

    • vivus
    • 11. November 2009 um 17:12

    hast du mal winkill versucht =?!

    hat bei mir mal bei so einem problem geholfen ...

  • Filename welcher in einer (autoit) variablen steht an ein Excel makro übergeben ..

    • vivus
    • 11. November 2009 um 17:08

    mmm .. also direkt übergeben geht nicht ..

    soweit ich weis .. aber mit UMWEG ..

    was hällst du von einer *.ini ..

    welche du mit auto It beschreibst .. ( alle datei namen )

    und dann mit VBS wieder ausließt ?!

    .. oder mit einem REG Eintrag ?

    hab ich bein n paar skripten drinne, welche mit anderen kommunizieren sollten bzw müssen ..

    ist in auto it nur eine zeile .. und funktioniert absolut SUPER !!

    muste halt nur manchmal mit m timing aufpassen .. eventuell handshakes einrichten ..

    .. oder auf irgend welche acknowledge warten ..

    aber bei deinen fsten datei namen .. seh ich da jetzt mal gar kein problem ..

    rein schreiben .. dann vbs starten .. .. und dass liest dann als erstes mal die reg aus .. die werte in variablen ..

    fertig ..

    dürfte nix schief gehen .. denke ich jetzt mal ..

  • ANSI C in AutoIt

    • vivus
    • 11. November 2009 um 17:01

    ALSO :

    ziel ist es eine National Instrument USB i/o card an zu sprechen .. ..

    Handelt sich um die USB 6501 ( 24 I/O )

    natürlich habe ich diese karte gewählt, weil sie die billigste, dieser USB Familie ist.

    mit der " NIDAQmx.h " sollte es aber möglich sein, jede Karte an zu sprechen.

    deshalb glaube ich, ist dieses file auch soooo groß !!

    wirklich brauchn tut man ja glaube ich "nur" 5 befehle für dieses USB-Board.

    1) verbindung aufbauen ..

    2) setup

    3) ports lesen

    4) ports schreiben

    5) verbindung trennen

    .. alles andere wäre für mich jetzt mal zweitrangig ..

    wichtig ist erst mal, dass überhaupt irgend etwas blinkt !! und ich einen wert oder einen zustand einlesen kann ..

    hab auch schon jedes auffindbare Forum durchforstet. das einzige was man zum Thema Ni und AutoIt findet ist das VISA udf.

    .. was auch sicher irgend wie funktioniert.. aber ich glaube nicht, mit dem USB board.

    zumindest laut NI-HP..

    .. oojee .. wird ne ggaannz harte NUSS !!

  • ANSI C in AutoIt

    • vivus
    • 11. November 2009 um 15:40

    danke ! für die Antwort !!

    .. also wie mache ich weiter ..

    hab jetzt mir mal des komplette *.h file durchgelesen .. ( überflogen )

    aber keinen verweis auf eine DLL gefunden ..

    müsste ja dann irgend wo dort drin stehen.. ? oder ..

    des meiste sind einfache Zuweisungen ..

    würde mir ja wirklich die mühe machen es um zu schreiben, wenn ich danach wüste, dass es funktioniert ..

    ..

    geschweige denn sollte ich erst wissen , ob ich es überhaupt richtig übersetze..

  • ANSI C in AutoIt

    • vivus
    • 11. November 2009 um 14:21

    kann man nicht aus der "NIDAQmx.h" .. irgend wie ne dll compilieren ?!

    die ich dann mit dll open ( dll call ) ansprechen kann ?!

    hab mir mal die "NIDAQmx.h" angeschaut .. ist ja ne halbe biebel ..

    .. krieg ich nie hin ..

  • ANSI C in AutoIt

    • vivus
    • 11. November 2009 um 14:03

    Hi @ all

    brauch mal n paar Profis hier !!

    sollte diesen Ansi C Code in Auto It zum laufen kriegen.

    Spoiler anzeigen

    /*********************************************************************
    *
    * ANSI C Example program:
    * ReadDigPort.c
    *
    * Example Category:
    * DI
    *
    * Description:
    * This example demonstrates how to read values from a digital
    * input port.
    *
    * Instructions for Running:
    * 1. Select the digital port on the DAQ device to be read.
    * Note: The Data Read indicator is in hexadecimal.
    *
    * Steps:
    * 1. Create a task.
    * 2. Create a Digital Input channel. Use one channel for all
    * lines. In this case, the port itself acts as an individual
    * channel.
    * 3. Call the Start function to start the task.
    * 4. Read the digital data. This read function reads a single
    * sample of digital data on demand, so no timeout is necessary.
    * 5. Call the Clear Task function to clear the Task.
    * 6. Display an error if any.
    *
    * I/O Connections Overview:
    * Make sure your signal input terminals match the Port I/O
    * Control. In this case wire your digital signals to the first N
    * digital lines on your DAQ Device.
    *
    *********************************************************************/

    #include <stdio.h>
    #include <NIDAQmx.h>

    #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

    int main(void)
    {
    int32 error=0;
    TaskHandle taskHandle=0;
    uInt32 data;
    char errBuff[2048]={'\0'};
    int32 read;

    /*********************************************/
    // DAQmx Configure Code
    /*********************************************/
    DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxCreateDIChan(taskHandle,"Dev1/port0","",DAQmx_Val_ChanForAllLines));

    /*********************************************/
    // DAQmx Start Code
    /*********************************************/
    DAQmxErrChk (DAQmxStartTask(taskHandle));

    /*********************************************/
    // DAQmx Read Code
    /*********************************************/
    DAQmxErrChk (DAQmxReadDigitalU32(taskHandle,1,10.0,DAQmx_Val_GroupByChannel,&data,1,&read,NULL));

    printf("Data acquired: 0x%X\n",data);

    Error:
    if( DAQmxFailed(error) )
    DAQmxGetExtendedErrorInfo(errBuff,2048);
    if( taskHandle!=0 ) {
    /*********************************************/
    // DAQmx Stop Code
    /*********************************************/
    DAQmxStopTask(taskHandle);
    DAQmxClearTask(taskHandle);
    }
    if( DAQmxFailed(error) )
    printf("DAQmx Error: %s\n",errBuff);
    printf("End of program, press Enter key to quit\n");
    getchar();
    return 0;
    }

    hab schon mal angefangen aber sehe kaum chancen, weil ich ANSI C nicht kenne

    Spoiler anzeigen

    #cs ----------------------------------------------------------------------------


    ANSI C Example program:
    ReadDigPort.c

    Example Category:
    DI

    Description:
    This example demonstrates how to read values from a digital
    input port.

    Instructions for Running:
    1. Select the digital port on the DAQ device to be read.
    Note: The Data Read indicator is in hexadecimal.

    Steps:
    1. Create a task.
    2. Create a Digital Input channel. Use one channel for all
    lines. In this case, the port itself acts as an individual
    channel.
    3. Call the Start function to start the task.
    4. Read the digital data. This read function reads a single
    sample of digital data on demand, so no timeout is necessary.
    5. Call the Clear Task function to clear the Task.
    6. Display an error if any.

    I/O Connections Overview:
    Make sure your signal input terminals match the Port I/O
    Control. In this case wire your digital signals to the first N
    digital lines on your DAQ Device.

    #ce ----------------------------------------------------------------------------

    ;#include <stdio.h> ; fällt glaube ich weg, da nicht benötigt in autoit
    #include <NIDAQmx.h> !! ?? kenn ich nicht .. scheint aber wichtig zu sein ..

    #define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) then _Error(); else ; ?? absolut keine ahnung ..

    ; main

    Global $error = 0 ; int32
    Global $taskHandle = 0 ; TaskHandle
    Global $data ; uInt32
    Global $errBuff[2048] = '\0'; char
    Global $read ; int32

    ;----------------------------------------------

    ; DAQmx Configure Code

    DAQmxErrChk(DAQmxCreateTask("", &taskHandle));
    DAQmxErrChk(DAQmxCreateDIChan(taskHandle, "Dev1/port0", "", DAQmx_Val_ChanForAllLines));

    ;----------------------------------------------

    ; DAQmx Start Code

    DAQmxErrChk(DAQmxStartTask(taskHandle));

    ;----------------------------------------------

    ; DAQmx Read Code

    DAQmxErrChk(DAQmxReadDigitalU32(taskHandle, 1, 10.0, DAQmx_Val_GroupByChannel, &data, 1, &read, NULL));

    ;----------------------------------------------


    MsgBox(0, "", "Data acquired: 0x%X\n" & $data);


    Exit


    Func _Error()

    If DAQmxFailed($error) Then
    DAQmxGetExtendedErrorInfo($errBuff, 2048);

    ElseIf $taskHandle = 0 Then

    ;----------------------------------------------

    ; DAQmx Stop Code

    DAQmxStopTask($taskHandle);
    DAQmxClearTask($taskHandle);

    ;----------------------------------------------

    ;### Tidy Error: If/ElseIf statement without a then..
    ElseIf DAQmxFailed($error)
    MsgBox(0, "DAQmx Error: %s\n", $errBuff);


    EndIf


    ;printf("End of program, press Enter key to quit\n");
    ;getchar();

    Return 0;

    EndFunc ;==>_Error

    ich denke mal dass die include zwingend erforderlich ist, kann ich diese auch in autoit anbinden =?
    oder muss ich die dann auch neu schreiben ?

    quelle folgt ... http://www.fileuploadx.de/282213

    .. vielleicht kann mir ja jemand helfen ..

    danke !!

  • Win 7 AUTOIT

    • vivus
    • 11. November 2009 um 09:17

    HI @ all

    Hab da n kleines Problem mit AutoIT unter Win 7 ....

    Und zwar, funktioniert die Hilfe nicht ..

    Kann zwar geöffnet werden, zeigt aber nicht's an.

    Jemand n TIP ?!

    bye

    PS: handelt sich um die aktuelle Version von AutoIT

  • Hibernate

    • vivus
    • 3. November 2009 um 14:40

    @ nuts

    hätte mich vorhin genauer ausdrücken sollen ..

    sind nur 2 sachen die mich total iritieren .. der rest ist sonnenklar ..

    1 ) GUIRegisterMsg($WM_POWERBROADCAST, "Standby")
    ; woher kommt der register handler .. was kann er noch , und woher kennst du den Wert 536 .. Wo kann ich ihn finden.

    2) Func Standby($hWnd, $Msg, $wParam, $lParam)
    ; woher kommen die ganzen variablen ?! warum geht das ?! was machen sie hier ?!
    ; kann mir nicht erklären warum da autoit nicht streigt !!!
    ; sind ja gar nicht definiert .. und werden auch nicht in irgend einer weise übergeben .. ...

    diese zeile widerstrebt allem, was ich bisher gelernt habe... :cursing:

    der rest ist eigentlich wirklich sehr einfach ..


    @ schnitzel ..
    SORRY !! :) .. trotzdem danke für deinen link .. wollte die sache aber in autoit lösen ... und nicht noch ne andere software einbinden ..
    DANKE !


    ###
    .. versuche gerade das ganze ohne die GUI in eine Unterfunktion zu pressen ..

  • Hibernate

    • vivus
    • 3. November 2009 um 13:54

    @ schnitzel

    *g* .. klar frag ich immer sachen .. die keiner weis .. sonnst würde ich sie ja in google finden ..
    frage nicht gerne .. .. nur wenn ich wirklich nicht weiter weis ..


    @ nuts

    DANKE !! voll geil !! funktioniert ..

    jetzt muss ich nur noch raus finden .. WARUM !!!

    sorry .. aber blick dein skript .... jetzt grad überhaupt noch nicht ..

    werd mich da jetzt mal dran setzen !

    DANKE !! wirklich wirklich GEIL !!

    ==> GELÖST <== !!

  • Hibernate

    • vivus
    • 3. November 2009 um 10:20

    Hi @ all

    Wir kennen ja alle das gute alte Autostart ..

    Funktioniert ja auch toll ...

    Was ist aber, wenn ich aus dem " Hibernate " also Ruhezustand komme ?

    bisher hab ich mir abgeholfen mit nem Überwachungsscript.

    Zählt Sekunden .. und überwacht ob wirklich die Sekunden vergangen sind .. bei Abweichung wird dann angenommen , das der PC im Hibernate war.

    find die Lösung aber nicht wirklich gut.

    gibt's da noch was anderes ?!

  • USB RESET ?!

    • vivus
    • 3. November 2009 um 07:37

    neues STATUS ::

    also am USB Device kanns nicht liegen.

    Wenn ich den PC in den "Ruhezustand" fahre, bleib der USB-Device lauffähig ..

    beim Neustarten NICHT ..


    Gibt es eine Möglichkeit, die " treiber und zugehörige windows Einstellungen " auszulesen .. und wieder nach systemstart einzulesen ?

    im prinzip, dass nach einem neustart, die funktionierenden treiber und alles was dazu gehört, in das System geladen wird ?!

  • _arraytostring geht nicht !?

    • vivus
    • 3. November 2009 um 07:32

    ==> GELÖST !! <==

Spenden

Jeder Euro hilft uns, Euch zu helfen.

Download

AutoIt Tutorial
AutoIt Buch
Onlinehilfe
AutoIt Entwickler
  1. Datenschutzerklärung
  2. Impressum
  3. Shoutbox-Archiv
Community-Software: WoltLab Suite™