AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi AccessViolation beim öffnen einer Com Verbindung
Thema durchsuchen
Ansicht
Themen-Optionen

AccessViolation beim öffnen einer Com Verbindung

Ein Thema von EDatabaseError · begonnen am 2. Jan 2007 · letzter Beitrag vom 2. Jan 2007
 
EDatabaseError

Registriert seit: 11. Mai 2005
Ort: Göppingen
1.238 Beiträge
 
Delphi 2007 Professional
 
#1

AccessViolation beim öffnen einer Com Verbindung

  Alt 2. Jan 2007, 15:01
Wenn ich mit diesem Code:

Delphi-Quellcode:
procedure TfComm.Button1Click(Sender: TObject);
begin
 GroupBox1.Enabled := false;
 Combobox1.Enabled := false;

 
 rs2321 := trs232.create(self);

 with rs2321 do begin
  ComPortSpeed := br19200;
  ComPortDatabits := db8bits;
  ComPortHwHandshaking := hhNone;
  ComPortParity := ptNone;
  ComPortStopBits := sb1bits;
  ComPortSwHandshaking := shnone;
  TimeOut := -1;
  TimeOutException := false;
 end;

 case combobox1.ItemIndex of
  0: rs2321.ComPort := pnCom1;
  1: rs2321.ComPort := pnCom2;
  2: rs2321.ComPort := pnCom3;
  3: rs2321.ComPort := pnCom4;
 end;

 RS2321.Connect;

 if RS2321.Connected then
  begin
   (Sender as tbutton).Caption := 'Verbindung erfolgreich!';

   GroupBox2.Enabled := false;
   Button1.Enabled := false;
   GroupBox3.Enabled := true;
   Button2.Enabled := true;
  end
 else
  messagedlg('Fehler bei dem Herstellen der Verbindung!'+#13+#10+'Bitte das Kabel nochmals überprüfen.', mtError, [mbOK], 0);
end;
...versuche eine RS232 Verbindung herstellen knallts in der Zeile : RS2321.Connect;

Die Connect Funktion sieht folgendermaßen aus:

Delphi-Quellcode:
function TCommPortDriver.Connect: boolean;
var comName: array[0..4] of char;
    tms: TCOMMTIMEOUTS;
begin
  FDatainbuffer('A');
  // Do nothing if already connected
  Result := Connected;
  if Result then exit;
  // Open the COM port
  StrPCopy( comName, 'COM' );
  comName[3] := chr( ord('1') + ord(FComPort) );
  comName[4] := #0;
  FComPortHandle := CreateFile(
                                comName,
                                GENERIC_READ or GENERIC_WRITE,
                                0, // Not shared
                                nil, // No security attributes
                                OPEN_EXISTING,
                                FILE_ATTRIBUTE_NORMAL,
                                0 // No template
                              ) ;
  Result := Connected;
  if not Result then exit;
  // Apply settings
  ApplyCOMSettings;
  // Setup timeouts: we disable timeouts because we are polling the com port!
  tms.ReadIntervalTimeout := 1; // Specifies the maximum time, in milliseconds,
                                // allowed to elapse between the arrival of two
                                // characters on the communications line
  tms.ReadTotalTimeoutMultiplier := 0; // Specifies the multiplier, in
                                       // milliseconds, used to calculate
                                       // the total time-out period
                                       // for read operations.
  tms.ReadTotalTimeoutConstant := 1; // Specifies the constant, in milliseconds,
                                     // used to calculate the total time-out
                                     // period for read operations.
  tms.WriteTotalTimeoutMultiplier := 0; // Specifies the multiplier, in
                                        // milliseconds, used to calculate
                                        // the total time-out period
                                        // for write operations.
  tms.WriteTotalTimeoutConstant := 0; // Specifies the constant, in
                                      // milliseconds, used to calculate
                                      // the total time-out period
                                      // for write operations.
  SetCommTimeOuts( FComPortHandle, tms );

  Sleep(1000); // to avoid timing problems, wait until the Comm-Port is opened
end;
(Für die die es wissen wollen die Exception tritt genau bei pop esi auf)

In einer anderen Anwendung funktioniert alles...ohne Exception.


Hoffe ihr könnt mir helfen.



Mfg
Tobi
Tobias
It's not a bug, it's a feature.
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:41 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz