OpenCores
URL https://opencores.org/ocsvn/cheap_ethernet/cheap_ethernet/trunk

Subversion Repositories cheap_ethernet

[/] [cheap_ethernet/] [trunk/] [FPGAUDP/] [main.pas] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 graver
unit main;
2
 
3
interface
4
 
5
uses
6
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
7
  Dialogs, StdCtrls, IdUDPClient, IdBaseComponent, IdComponent, IdUDPBase,
8
  IdUDPServer, IdSocketHandle, Math, IdTCPServer, IdTCPConnection,
9
  IdTCPClient;
10
 
11
type
12
  TForm1 = class(TForm)
13
    IdUDPServer1: TIdUDPServer;
14
    Memo1: TMemo;
15
    IdUDPClient1: TIdUDPClient;
16
    Button1: TButton;
17
    Edit1: TEdit;
18
    Label1: TLabel;
19
    Button2: TButton;
20
    Button3: TButton;
21
    Button5: TButton;
22
    Button4: TButton;
23
    Button6: TButton;
24
    procedure IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
25
      ABinding: TIdSocketHandle);
26
    procedure ButtonsClick(Sender: TObject);
27
    procedure FormShow(Sender: TObject);
28
  private
29
    { Private declarations }
30
  public
31
    { Public declarations }
32
  end;
33
 
34
var
35
  Form1: TForm1;
36
 
37
implementation
38
 
39
{$R *.dfm}
40
 
41
var
42
  cnt: Integer = 0;
43
 
44
const
45
  CmdDone             = 0;
46
  CmdStatus                     = 1;
47
  CmdLEDCtrl            = 2;
48
  CmdSetConfig  = 3;
49
  CmdSwChanged  = 4;
50
  CmdDataEcho           = 5;
51
 
52
 
53
procedure TForm1.IdUDPServer1UDPRead(Sender: TObject; AData: TStream;
54
  ABinding: TIdSocketHandle);
55
var
56
  S, T: String;
57
  i, l: Integer;
58
begin
59
  Memo1.Lines.Add(IntToStr (cnt) + ') Received ' + IntToStr (AData.Size) + ' bytes:');
60
  cnt := cnt + 1;
61
  l := min (AData.Size, 32);
62
  SetLength (S, l);
63
  AData.Read (S[1], l);
64
  T := '';
65
  for i := 0 to l - 1 do
66
    T := T + IntToHex (Ord (S[i + 1]), 2) + ' ';
67
  Memo1.Lines.Add (T + #13#10);
68
end;
69
 
70
procedure TForm1.FormShow(Sender: TObject);
71
begin
72
  IdUDPServer1.Active := True;
73
end;
74
 
75
procedure TForm1.ButtonsClick(Sender: TObject);
76
var
77
  S, T: String;
78
  i: Integer;
79
begin
80
  cnt := cnt + 1;
81
  IdUDPClient1.Host := Edit1.Text;
82
  case (TButton(Sender).Tag) of
83
    0: S := Chr(CmdLEDCtrl) + #1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
84
    1: S := Chr(CmdLEDCtrl) + #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
85
    2: S := Chr(CmdSetConfig) + #1#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
86
    3: S := Chr(CmdSetConfig) + #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
87
    4: S := Chr(CmdStatus) + #0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0;
88
    5: S := Chr(CmdDataEcho) + #1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17;
89
  end;
90
  for i := 0 to Length (S) - 1 do
91
    T := T + IntToHex (Ord (S[i + 1]), 2) + ' ';
92
  Memo1.Lines.Add(IntToStr (cnt) + ') Sending ' + IntToStr (Length (S)) + ' bytes:');
93
  Memo1.Lines.Add (T);
94
  IdUDPClient1.Send (S);
95
end;
96
 
97
end.

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.