AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Netzwerke Daten aus TClientSocket verarbeiten

Daten aus TClientSocket verarbeiten

Ein Thema von js747a · begonnen am 19. Jan 2021 · letzter Beitrag vom 20. Jan 2021
Antwort Antwort
Seite 2 von 2     12
Benutzerbild von jaenicke
jaenicke

Registriert seit: 10. Jun 2003
Ort: Berlin
9.288 Beiträge
 
Delphi 11 Alexandria
 
#11

AW: Daten aus TClientSocket verarbeiten

  Alt 20. Jan 2021, 21:02
Hier mal ein Beispiel mit Indy und ohne dieses ganze String-Gehampel:
Delphi-Quellcode:
procedure TFormX.SendCommand(
  const APrio: Byte; //Priorität des befehls
  const ACommand: Byte; // unser Befehl, 8 Bits
  const ASubCommand: Byte; // unser Unterbefehl, 8 Bits
  const AHash: SmallInt; // unser Hash, 16 Bits
  const ADLC: Byte; //Anzahl der Datenbytes im CAN-Paket, 1 Byte
  const AUID: Integer; // Zieladresse des Objektes auf dem CAN, 32 Bits
  const AResponseBit: Byte); // wenn wir als PC-Programm senden, ist dieses Bit immer 0
var
  StartWord: SmallInt; // die Kombination aus Prio, Command und Responsebit
  CommandBytes: TIdBytes;
begin
  SetLength(CommandBytes, 13);
  StartWord := ( ((APrio SHL 12) + (ACommand SHL 1) + (AResponseBit AND 1)) AND 255 );
  CommandBytes[0] := (StartWord SHR 8) AND 255;
  CommandBytes[1] := StartWord AND 255;
  CommandBytes[2] := (AHash SHR 8) AND 255;
  CommandBytes[3] := AHash AND 255;
  CommandBytes[4] := ADLC AND 255;
  CommandBytes[5] := ((AUID SHR 24) AND 255); // Big Endian encoding
  CommandBytes[6] := ((AUID SHR 16) AND 255);
  CommandBytes[7] := ((AUID SHR 8) AND 255);
  CommandBytes[8] := (AUID AND 255);
  CommandBytes[9] := ASubCommand;
  CommandBytes[10] := 0;
  CommandBytes[11] := 0;
  CommandBytes[12] := 0;

  IdTCPClient.IOHandler.Write(CommandBytes);
end;

// Aufruf:
  SendCommand(0, // Byte - wir haben keine Priorität immer 0
    0, // Byte - 0x00 = 0 Systembefehl
    1, // Power ON - System Go (0x01)
    18193, // SmallInt - wie im Beispiel, kann aber auch &h0300 sein (als Minimum)
    5, // Byte
    0, // Integer - UID = 0 bedeutet: sende den Befehl an alle
    0);
Sebastian Jänicke
Alle eigenen Projekte sind eingestellt, ebenso meine Homepage, Downloadlinks usw. im Forum bleiben aktiv!
  Mit Zitat antworten Zitat
Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

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:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz