summaryrefslogtreecommitdiff
path: root/irdecoderunit.pas
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2015-10-19 16:30:48 +0200
committerErich Eckner <git@eckner.net>2015-10-19 16:30:48 +0200
commitb336784693af5b73d1c9855ba6a43ee530a13b4b (patch)
tree8984c2fa0f2fb4cfa1a6e3a3f7776641c1f07ef5 /irdecoderunit.pas
parenta4c860b8898cc35690347fa8391485e37ef9ce15 (diff)
downloadunits-b336784693af5b73d1c9855ba6a43ee530a13b4b.tar.xz
neue Datei: irdecoderunit.pas
Diffstat (limited to 'irdecoderunit.pas')
-rw-r--r--irdecoderunit.pas62
1 files changed, 62 insertions, 0 deletions
diff --git a/irdecoderunit.pas b/irdecoderunit.pas
new file mode 100644
index 0000000..1234678
--- /dev/null
+++ b/irdecoderunit.pas
@@ -0,0 +1,62 @@
+unit irdecoderunit;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+ Classes, SysUtils, lesethreadunit, lowlevelunit;
+
+type
+ tIRDecoder = class
+ private
+ ttySLeser: tLeseProzess;
+ public
+ constructor create(inputName: string);
+ destructor destroy; override;
+ function zeileVerarbeitet: boolean;
+ end;
+
+implementation
+
+// tIRDecoder ******************************************************************
+
+constructor tIRDecoder.create(inputName: string);
+begin
+ inherited create;
+ ttySLeser:=tLeseProzess.create(inputName,1);
+end;
+
+destructor tIRDecoder.destroy;
+begin
+ ttySLeser.free;
+ inherited destroy;
+end;
+
+function tIRDecoder.zeileVerarbeitet: boolean;
+var
+ s: string;
+ inByte: longint;
+begin
+ result:=ttySLeser.gibZeile(s);
+ if not result then exit;
+
+ if s='Ha!' then begin // Startzeichen
+ writeln('Empfänger hat sich gemeldet!');
+ exit;
+ end;
+
+ if (length(s)=3) and base64Decode(s,inByte) then begin
+ if not base64ToBin(s) then
+ raise exception.create('interner Fehler: base64ToBin meckert, base64Decode aber nicht!');
+
+ writeln('Bits: '+s+' '+hexDump(@inByte,sizeof(inByte)));
+ // verarbeiten!
+ exit;
+ end;
+
+ writeln('Warnung: Kenne Kommando '''+s+''' nicht - komisch formatiert!');
+end;
+
+end.
+