markus5766h Posted October 19, 2015 at 03:59 PM Posted October 19, 2015 at 03:59 PM Moin aus Hamburg. Ich habe folgendes Problem : ich erstelle Objekte vom Typ TBrickMaster, TBrickAnalogOut, AnalogIn ... im Ereignis On Create des Formulars var HOST : String; PORT : Word; EnumBrick : array[1..128] of TEnumerateB; EnumCount : Word; ipcon : TIPConnection; ma : array[1..8] of TBrickMaster; mb : array[1..8] of TBrickDC; aa : array[1..8] of TBrickletAnalogIn; ab : array[1..8] of TBrickletAnalogInV2; ac : array[1..8] of TBrickletAnalogOut; ad : array[1..8] of TBrickletAnalogOutV2; ae : array[1..8] of TBrickletIndustrialDual020mA; da : array[1..8] of TBrickletIO4; db : array[1..8] of TBrickletIO16; procedure TfrmMain.FormCreate(Sender: TObject); var i : Integer; begin frmMain.ClientWidth := 1008; frmMain.ClientHeight := 730; Log := TStringList.Create; Log.Add(DateTimeToStr(Now) + ' Programm started'); HOST := 'localhost'; PORT := 4223; EnumCount := 0; ipcon := TIPConnection.Create; ma[1] := TBrickMaster.Create('6qY3SC', ipcon); ma[2] := TBrickMaster.Create('6JKRPw', ipcon); ab[1] := TBrickletAnalogInV2.Create('vfA', ipcon); ac[1] := TBrickletAnalogOut.Create('hPy', ipcon); ac[2] := TBrickletAnalogOut.Create('ikS', ipcon); ad[1] := TBrickletAnalogOutV2.Create('vn2', ipcon); ae[1] := TBrickletIndustrialDual020mA.Create('saE', ipcon); db[1] := TBrickletIO16.Create('snY', ipcon); ipcon.Connect('localhost', 4223); soweit so gut. Im Ereignis OnClose setze ich einige Einstellungen zurück und gebe die Objekte wieder frei : procedure TfrmMain.FormClose(Sender: TObject; var Action: TCloseAction); begin SetIO16PortsToZero(1); // alle Ausgänge auf HIGH SetAnalogesToZero; // Analog Ausgänge auf 0V ab[1].Free; ac[2].Free; ac[1].Free; ad[1].Free; ae[1].Free; db[1].Free; ma[2].Free; ma[1].Free; Delay(100); ipcon.Destroy; Delay(100); Log.Free; end; dies funktioniert auch einwandfrei, solange ich von einem Bricklet-Typ nur ein Objekt erzeuge. benutze ich zwei Objekte vom z.B. Typ TBrickletAnalogOut gibt's eine Exception bei der Freigabe bzw. Destroy von ipcon an folgender Stelle : Unit IPConnection procedure TIPConnection.Disconnect; var callback_: PCallbackContext; meta: TByteArray; begin callback_ := nil; socketMutex.Acquire; try autoReconnectAllowed := false; if (autoReconnectPending) then begin { Abort pending auto-reconnect } autoReconnectPending := false; end else begin if (not IsConnected) then begin raise ENotConnectedException.Create('Not connected'); end; DisconnectUnlocked; SetLength(pendingData, 0); end; { Destroy callback thread } callback_ := callback; callback := nil; finally socketMutex.Release; end; if (callback_ <> nil) then begin { Do this outside of socketMutex to allow calling (dis-)connect from the callbacks while blocking on the WaitFor call here } SetLength(meta, 2); meta[0] := IPCON_CALLBACK_DISCONNECTED; meta[1] := IPCON_DISCONNECT_REASON_REQUEST; callback_^.queue.Enqueue(IPCON_QUEUE_KIND_META, meta); if (not callback_^.thread.IsCurrent) then begin callback_^.queue.Enqueue(IPCON_QUEUE_KIND_EXIT, nil); callback_^.thread.WaitFor; callback_^.thread.Destroy; <-------------- hier tritt der Fehler auf end else begin callback_^.queue.Enqueue(IPCON_QUEUE_KIND_DESTROY_AND_EXIT, nil); end; end; end; kennt jemand das Problem bzw. hat eine Lösung ? Quote
photron Posted October 20, 2015 at 12:01 PM Posted October 20, 2015 at 12:01 PM Teste mal bitte diese Version von IPConnetion.pas: https://raw.githubusercontent.com/Tinkerforge/generators/ebe8892f231c431f50c72b069bfb60d4c2ec17a9/delphi/IPConnection.pas Quote
markus5766h Posted October 20, 2015 at 03:30 PM Author Posted October 20, 2015 at 03:30 PM jupp, läuft und auch ein ipcon.Disconnect - was eigentlich vor das ipcon.Destroy gehört - wird akzeptiert. Danke Quote
photron Posted October 21, 2015 at 04:15 PM Posted October 21, 2015 at 04:15 PM Okay, von dem git Stand habe ich jetzt Version 2.1.7 der Delphi Bindings released. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.