seit kurzem bin ich stolzer Besitzer eines IO-Warrior56-Kits. Schnell zusammengelötet, gings auch schon gleich ans Eingemachte. Ich habe leider nicht viel Programmiererfahrung und so hapert es auch schon ziemlich am Anfang. Ich habs mittlerweile hinbekommen, beliebige Ausgänge zu schalten (*STOLZ*), jedoch klappt das Einlesen irgendwie nicht. Mein "Programm" liefert nur Nullen. Vielleicht sei noch erwähnt, dass ich mit C# programmiere. Hier mein Code:
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace ConsoleApplication1
{
class Program
{
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitOpenDevice();
[DllImport("iowkit", SetLastError = true)]
public static extern void IowKitCloseDevice(int iowHandle);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitWrite(int iowHandle, int numPipe, ref byte buffer, int length);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitRead(int iowHandle, int numPipe, ref byte buffer, int length);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitReadNonBlocking(int iowHandle, int numPipe, ref byte buffer, int length);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitGetNumDevs();
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitGetDeviceHandle(int numDevice);
[DllImport("iowkit", SetLastError = true)]
public static extern short IowKitGetProductId(int iowHandle);
[DllImport("iowkit", SetLastError = true)]
public static extern bool IowKitGetSerialNumber(int iowHandle, ref short serialNumber);
[DllImport("iowkit", SetLastError = true)]
public static extern bool IowKitSetTimeout(int iowHandle, int timeout);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitCancelIo(int iowHandle, int numPipe);
[DllImport("iowkit", SetLastError = true)]
public static extern int IowKitReadImmediate(int iowHandle, int value);
static void Main(string[] args)
{
byte[] empfangen = new byte[8];
empfangen[0] = 0;
empfangen[1] = 0;
empfangen[2] = 0;
empfangen[3] = 0;
empfangen[4] = 0;
empfangen[5] = 0;
empfangen[6] = 0;
empfangen[7] = 0;
int handle = IowKitOpenDevice();
IowKitReadNonBlocking(handle, 0, ref empfangen[0], 8);
Console.Write(empfangen[1] + "\t" + empfangen[2] + "\t" + empfangen[3] + "\t" + empfangen[4] + "\t" + empfangen[5] + "\t" + empfangen[6] + "\t" + empfangen[7]);
IowKitCloseDevice(handle);
Console.ReadLine();
}
}
}