Files
bds.mr.devmgr/src.devmgr/dev/usb/trinity/modules/cfg/m.cfg.pas
T
2026-01-03 18:53:14 +01:00

206 lines
5.9 KiB
ObjectPascal

unit m.cfg;
interface
uses
m.base,
m.cfg.types;
type
TmodCFG = class( TmodBase, ICFG)
// ------------------------------------------------------------
// ICFG
// ------------------------------------------------------------
protected
function GetCapabilities: Int64;
function GetSerialNumber: AnsiString;
function GetIdentifier : AnsiString;
procedure SetSerialNumber( value: AnsiString);
procedure SetIdentifier( value: AnsiString);
end;
implementation
{ TmodCFG }
// @@@: ICFG ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// ICFG
//
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// ================================================================================================
// get capabilities
// ================================================================================================
function TmodCFG.GetCapabilities: Int64;
var
buf : array[0..7] of AnsiChar;
cnt : cardinal;
begin
result := 1;
if Assigned(fDevice) then
begin
with fDevice do
begin
Open;
if (VendorID = $16d0) and (ProductID = $0712) then
begin
cnt := 0;
if Pipe0.Transfer( $80, // IN
$E0, // Get Serial
$00, // Value (not used)
$00, // Index (not used)
$08, // Length
@buf, // Buffer to receive data
8, // Length of buffer
cnt, // Transferred bytes
nil) then // Overlapped (not used)
begin
Result := PInt64(@buf)^;
end
end;
Close;
end
end
else
// raise
end;
// ================================================================================================
// get serial number
// ================================================================================================
function TmodCFG.GetSerialNumber: AnsiString;
var
buf : array[0..7] of AnsiChar;
cnt : cardinal;
i : integer;
begin
result := '';
if Assigned(fDevice) then
begin
with fDevice do
begin
Open;
if (VendorID = $16d0) and (ProductID = $0712) then
begin
cnt := 0;
if Pipe0.Transfer( $80, // IN
$E1, // Get Serial
$00, // Value (not used)
$00, // Index (not used)
$08, // Length
@buf, // Buffer to receive data
8, // Length of buffer
cnt, // Transferred bytes
nil) then // Overlapped (not used)
begin
for i:=0 to 7 do
if buf[i] in ['a'..'z','A'..'Z','0'..'9','$','.','_','-']
then Result := Result + buf[i]
else break
end
end;
Close;
end
end
else
// raise
end;
// ================================================================================================
// set serial number
// ================================================================================================
procedure TmodCFG.SetSerialNumber(value: AnsiString);
begin
if Assigned(fDevice) then
begin
end
else
// raise
end;
// ================================================================================================
// get identifier
// ================================================================================================
function TmodCFG.GetIdentifier: AnsiString;
var
buf : array[0..7] of AnsiChar;
cnt : cardinal;
i : integer;
begin
result := '';
if Assigned(fDevice) then
begin
with fDevice do
begin
Open;
if (VendorID = $16d0) and (ProductID = $0712) then
begin
cnt := 0;
if Pipe0.Transfer( $80, // IN
$E2, // Get Serial
$00, // Value (not used)
$00, // Index (not used)
$08, // Length
@buf, // Buffer to receive data
8, // Length of buffer
cnt, // Transferred bytes
nil) then // Overlapped (not used)
begin
for i:=0 to 7 do
if buf[i] in ['a'..'z','A'..'Z','0'..'9','$','.','_','-']
then Result := Result + buf[i]
else break
end
end;
Close;
end
end
else
// raise
end;
// ================================================================================================
// set identifier
// ================================================================================================
procedure TmodCFG.SetIdentifier(value: AnsiString);
begin
if Assigned(fDevice) then
begin
end
else
// raise
end;
end.