IOWarrior mit FreePascal (Lazarus)

Dies ist das deutsche Forum für alle Themen um den IO-Warrior. Beiträge bitte nur in Deutsch.

Moderator: Guido Körber

Post Reply
adlerauge
Posts: 1
Joined: Fri Oct 07, 2005 2:18 pm
Location: Germany

IOWarrior mit FreePascal (Lazarus)

Post by adlerauge »

Hi Forum,
gibt es jemanden, der den IOW 40 unter Linux ( SUSE 9.3 ) mit
FreePascal zum laufen gebracht hat ?

Bei mir funtioniert nur das Blinkbeispiel in C (iowblink) .
Leider habe ich mit C keine Erfahrung, ich programmiere nur in
Pascal und VB ( FreePascal / Gambas in Linux oder Delphi in Windows ). Der IOW40 soll aber mit einem Linux-Rechner laufen.

Oder hat jemand ein kleines Programm, das die 4 Byte vom IOW40
liest, bzw. schreibt ?

Würde mich über Infos freuen .
Robert Marquardt
Posts: 543
Joined: Mon Dec 01, 2003 6:09 pm

Post by Robert Marquardt »

Da sollte es eigentlich keine groesseren Probleme geben.
Die iowkit.pas sollte nach kleiner Anpassung des DLL Namens funktionieren.
l_netwalker
Posts: 35
Joined: Mon Oct 17, 2005 9:51 am
Location: Aachen, Germany
Contact:

Post by l_netwalker »

In meinem Projekt SPS4Linux habe ich nun auch den IO Warrior 40
eingebaut. Beispielcode findest Du hier:
http://www.eilers.net/sps/
in der download section den Entwicklersnapshot runterladen.
in iow_io_access.pas findest Du alles was Du brauchst.

Gruss Hartmut
l_netwalker
Posts: 35
Joined: Mon Oct 17, 2005 9:51 am
Location: Aachen, Germany
Contact:

Post by l_netwalker »

Hallo,

mein voriger Post bezog sich auf das alte SDK für 2.4 Kernel.
Mit dem aktuellen SDK ist das noch viel einfacher:

1. SDK installieren ( Full SDK )
2. aus den Delphi Beispielen im Windows Teil des SDK
die iowkit.pas Datei wie folgt anpassen:

Code: Select all

//
// IO-Warrior kit library V1.4 include file
//

unit iowkit;

interface

uses
  oldlinux;

const
  // IoWarrior vendor & product IDs
  IOWKIT_VENDOR_ID        = $07c0;
  IOWKIT_VID              = IOWKIT_VENDOR_ID;

  // IO-Warrior 40
  IOWKIT_PRODUCT_ID_IOW40 = $1500;
  IOWKIT_PID_IOW40        = IOWKIT_PRODUCT_ID_IOW40;

  // IO-Warrior 24
  IOWKIT_PRODUCT_ID_IOW24 = $1501;
  IOWKIT_PID_IOW24        = IOWKIT_PRODUCT_ID_IOW24;

  // Max number of pipes per IOW device
  IOWKIT_MAX_PIPES   = 2;

  // pipe names
  IOW_PIPE_IO_PINS      = 0;
  IOW_PIPE_SPECIAL_MODE = 1;

  // Max number of IOW devices in system
  IOWKIT_MAX_DEVICES = 16;

  // IOW Legacy devices open modes
  IOW_OPEN_SIMPLE    = 1;
  IOW_OPEN_COMPLEX   = 2;

  // first IO-Warrior revision with serial numbers
  IOW_NON_LEGACY_REVISION = $1010;

type
  PIOWKIT_REPORT = ^IOWKIT_REPORT;
  IOWKIT_REPORT = packed record
    ReportID: Byte;
  case Boolean of
    False: (Value: DWORD;);
    True: (Bytes: array [0..3] of Byte;);
  end;

  PIOWKIT40_IO_REPORT = ^IOWKIT40_IO_REPORT;
  IOWKIT40_IO_REPORT = packed record
    ReportID: Byte;
  case Boolean of
    False: (Value: DWORD;);
    True: (Bytes: array [0..3] of Byte;);
  end;

  PIOWKIT24_IO_REPORT = ^IOWKIT24_IO_REPORT;
  IOWKIT24_IO_REPORT = packed record
    ReportID: Byte;
  case Boolean of
    False: (Value: WORD;);
    True: (Bytes: array [0..1] of Byte;);
  end;

  PIOWKIT_SPECIAL_REPORT = ^IOWKIT_SPECIAL_REPORT;
  IOWKIT_SPECIAL_REPORT = packed record
    ReportID: Byte;
    Bytes: array [0..6] of Byte;
  end;

const
  IOWKIT_REPORT_SIZE = SizeOf(IOWKIT_REPORT);
  IOWKIT40_IO_REPORT_SIZE = SizeOf(IOWKIT40_IO_REPORT);
  IOWKIT24_IO_REPORT_SIZE = SizeOf(IOWKIT24_IO_REPORT);
  IOWKIT_SPECIAL_REPORT_SIZE = SizeOf(IOWKIT_SPECIAL_REPORT);

type
  // Opaque IO-Warrior handle
  IOWKIT_HANDLE = Pointer;

function IowKitOpenDevice: IOWKIT_HANDLE; stdcall;
procedure IowKitCloseDevice(devHandle: IOWKIT_HANDLE); stdcall;
function IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: Cardinal;
  buffer: PChar; length: Cardinal): Cardinal; stdcall;
function IowKitRead(devHandle: IOWKIT_HANDLE; numPipe: Cardinal;
  buffer: PChar; length: Cardinal): Cardinal; stdcall;
function IowKitReadImmediate(devHandle: IOWKIT_HANDLE; var value: DWORD): LongBool; stdcall;
function IowKitGetNumDevs: Cardinal; stdcall;
function IowKitGetDeviceHandle(numDevice: Cardinal): IOWKIT_HANDLE; stdcall;
function IowKitSetLegacyOpenMode(legacyOpenMode: Cardinal): LongBool; stdcall;
function IowKitGetProductId(devHandle: IOWKIT_HANDLE): Cardinal; stdcall;
function IowKitGetRevision(devHandle: IOWKIT_HANDLE): Cardinal; stdcall;
function IowKitGetThreadHandle(devHandle: IOWKIT_HANDLE): THandle; stdcall;
function IowKitGetSerialNumber(devHandle: IOWKIT_HANDLE; serialNumber: PWideChar): LongBool; stdcall;
function IowKitSetTimeout(devHandle: IOWKIT_HANDLE; timeout: Cardinal): LongBool; stdcall;
function IowKitSetWriteTimeout(devHandle: IOWKIT_HANDLE; timeout: Cardinal): LongBool; stdcall;
function IowKitCancelIo(devHandle: IOWKIT_HANDLE; numPipe: Cardinal): LongBool; stdcall;
function IowKitVersion: PChar; stdcall;

implementation

const
  IOWKITDllName = 'iowkit';

function IowKitOpenDevice: IOWKIT_HANDLE; stdcall; external IOWKITDllName name 'IowKitOpenDevice';
procedure IowKitCloseDevice(devHandle: IOWKIT_HANDLE); stdcall; external IOWKITDllName name 'IowKitCloseDevice';
function IowKitWrite(devHandle: IOWKIT_HANDLE; numPipe: Cardinal; buffer: PChar; length: Cardinal): Cardinal; stdcall; external IOWKITDllName name 'IowKitWrite';
function IowKitRead(devHandle: IOWKIT_HANDLE; numPipe: Cardinal;buffer: PChar; length: Cardinal): Cardinal; stdcall; external IOWKITDllName name 'IowKitRead';
function IowKitReadImmediate(devHandle: IOWKIT_HANDLE; var value: DWORD): LongBool; stdcall; external IOWKITDllName name 'IowKitReadImmediate';
function IowKitGetNumDevs: Cardinal; stdcall; external IOWKITDllName name 'IowKitGetNumDevs';
function IowKitGetDeviceHandle(numDevice: Cardinal): IOWKIT_HANDLE; stdcall; external IOWKITDllName name 'IowKitGetDeviceHandle';
function IowKitSetLegacyOpenMode(legacyOpenMode: Cardinal): LongBool; stdcall; external IOWKITDllName name 'IowKitSetLegacyOpenMode';
function IowKitGetProductId(devHandle: IOWKIT_HANDLE): Cardinal; stdcall; external IOWKITDllName name 'IowKitGetProductId';
function IowKitGetRevision(devHandle: IOWKIT_HANDLE): Cardinal; stdcall; external IOWKITDllName name 'IowKitGetRevision';
function IowKitGetThreadHandle(devHandle: IOWKIT_HANDLE): THandle; stdcall; external IOWKITDllName name 'IowKitGetThreadHandle';
function IowKitGetSerialNumber(devHandle: IOWKIT_HANDLE; serialNumber: PWideChar): LongBool; stdcall; external IOWKITDllName name 'IowKitGetSerialNumber';
function IowKitSetTimeout(devHandle: IOWKIT_HANDLE; timeout: Cardinal): LongBool; stdcall; external IOWKITDllName name 'IowKitSetTimeout';
function IowKitSetWriteTimeout(devHandle: IOWKIT_HANDLE; timeout: Cardinal): LongBool; stdcall; external IOWKITDllName name 'IowKitSetWriteTimeout';
function IowKitCancelIo(devHandle: IOWKIT_HANDLE; numPipe: Cardinal): LongBool; stdcall; external IOWKITDllName name 'IowKitCancelIo';
function IowKitVersion: PChar; stdcall; external IOWKITDllName name 'IowKitVersion';

end.


Dazu noch libiowkit.so in /usr/lib/ und Du kannst z.B. das kleine
Beispiel übersetzen:

Code: Select all

program iownew;

uses oldlinux,iowkit;

var 
        ioHandle: IOWKIT_HANDLE;
        serNum: array [0..8] of WideChar;
        i       : byte; 
begin
writeln (IowKitVersion);
ioHandle:=IowKitOpenDevice;
writeln ('found ',IowKitGetNumDevs,' Devices');
IowKitGetSerialNumber(ioHandle,@serNum[0]);
write ('serial #: ');
for i :=0 to 8 do 
        write(serNum[i]);
writeln;
writeln('Firmware Version of first IO Warrior: ', IowKitGetRevision(ioHandle));
end.


Das funktioniert bei mir hervorragend.
Ich bin gerade dabei meine unit iow_io_access.pas
aus dem SPS4Linux Projekt entsprechend umzubauen.
Sobald ich fertig bin kann ich Sie ja bei Bedarf posten.

Fragen ? nur zu...
Gruss
Hartmut
Post Reply