Hi all,
i’ve developed an application with K8061 in C#. It seems that DLL is not compatible with Microsoft Charts components.
Just for a test i’ve reduced application to a simple call to OpenDevice and an Emply Charts.
As soon as OpenDevice is called application quit with this error:
The program ‘[3292] Thermostate.vshost.exe: Managed’ has exited with code -1073741819 (0xc0000005).
Obviously as soon as one component (board initialization or Chart) is removed application runs fine.
Any suggestion?
This is k8061.cs lib:
[i]using System;
using System.Runtime.InteropServices;
namespace Thermostate
{
///
/// Summary description for k8061.
///
public class k8061
{
/*
Result
Longint: If succeeded the return value will be the card address read from the K8061 hardware. The
card address is value between 0 and 7 which corresponds to the jumper (A1, A2, A3) setting on the
K8061 card. Use this value in the next function calls to access this card.
If more K8061 cards are connected to the PC, repeat this function call until all the cards are opened.
Return value -1 indicates that all K8061 cards are opened.
Return value -2 indicates that no card was found.
/
[DllImport(“k8061.dll”)]
public static extern int OpenDevice();
/
Description
Unloads the communication routines for K8061 cards and unloads the driver needed to communicate
via the USB port. This is the last action of the application program before termination.
*/
[DllImport(“k8061.dll”)]
public static extern void CloseDevices();
[DllImport("k8061.dll")]
public static extern int ReadAnalogChannel(int CardAddress, int Channell );
[DllImport("k8061.dll")]
public static extern void ReadAllAnalog(int CardAddress, ref int[] data);
[DllImport("k8061.dll")]
public static extern void OutputAnalogChannel (int CardAddress, int Channel, int Data);
[DllImport("k8061.dll")]
public static extern void OutputAllAnalog(int CardAddress, ref int[] data);
[DllImport("k8061.dll")]
public static extern void ClearAnalogChannel(int CardAddress,int Channel);
[DllImport("k8061.dll")]
public static extern void ClearAllAnalog(int CardAddress);
[DllImport("k8061.dll")]
public static extern void SetAnalogChannel(int CardAddres, int Channel);
[DllImport("k8061.dll")]
public static extern void SetAllAnalog(int CardAddress);
[DllImport("k8061.dll")]
public static extern void OutputAllDigital(int CardAddress, int data);
[DllImport("k8061.dll")]
public static extern void ClearDigitalChannel(int CardAddress, int Channel);
[DllImport("k8061.dll")]
public static extern void ClearAllDigital(int CardAddress);
[DllImport("k8061.dll")]
public static extern void SetDigitalChannel(int CardAddress, int Channel);
[DllImport("k8061.dll")]
public static extern void SetAllDigital(int CardAddress);
[DllImport("k8061.dll")]
public static extern bool ReadDigitalChannel(int CardAddress, int Channel);
[DllImport("k8061.dll")]
public static extern int ReadAllDigital(int CardAddress);
[DllImport("k8061.dll")]
public static extern void OutputPWM(int CardAddress,int Data);
[DllImport("k8061.dll")]
public static extern bool PowerGood(int CardAddress);
[DllImport("k8061.dll")]
public static extern bool Connected(int CardAddress);
[DllImport("k8061.dll")]
public static extern void ReadVersion(int CardAddress,ref int[] Buffer);
private int _cardaddress;
public bool _K8061_InitCard()
{
_cardaddress = OpenDevice();
if (_cardaddress == -2)
{
return (false);
}
else
{
return (true);
}
}
}
}[/i]
Application code:
public ThermoState()
{
InitializeComponent();
iface._K8061_InitCard();
}