Quantcast
Channel: LabVIEW topics
Viewing all articles
Browse latest Browse all 69326

eventhandler and event call back from .net dll doesn't work.

$
0
0

Hello,

 

I have a .net dll that was written in C#.  This .dll called nalusb.dll is also used in a usb tester program that is also written in C# and I am trying to do something similar in labview which will connect to the device, write data to the device and read the results.  In the usb tester program that was written in C#, nalusb.dll calls an event to read the data.  There is a public event in nalusb.dll that is called PacketReadCompleted and there is also a public delegate called PacketReadCompletedEventHandler.  I am able to connect to the device and write data to the device but after I register the callback event to PacketReadCompleted, the read event doesn't get handled after data is written to the device.  Do I need to do something with the PacketReadCompletedEventHandler?  This is a delegate which requires two inputs of type object and method but I have no idea what to wire into those........ I've included a snippit of the C# code of the usb tester.  I think I am stuck on the line I highlighted in red.  I've also included what I have so far in labview.  The section in purple is what I would like to do.   Any suggestions or help will be greatly appreciated!

 

public CentralForm()
{
this.InitializeComponent();

this.nalUsb = new NalUsb();
this.nalUsb.PacketReadCompleted += new PacketReadCompletedEventHandler(this.OnNalUsbPacketReadCompleted);
this.nalUsb.ConnectionLost += new EventHandler(this.OnNalUsbConnectionLost);

this.UpdateDevicePresentStatus(NalUsb.DevicePresent());
}

private void OnNalUsbPacketReadCompleted(object sender, PacketReadCompletedEventArgs e)

{
string eventDescription = "Packet Read - ";

if (e.Type == PacketType.Data)
{
eventDescription += e.Data.Length + " Bytes";
this.receivedTextBox.Text += Encoding.GetEncoding(1252).GetString(e.Data);
}
else if (e.Type == PacketType.FlowControlValues)
{
eventDescription += "Flow Control Values";
this.dsrCheckBox.Checked = e.Dsr;
this.ctsCheckBox.Checked = e.Cts;
this.dcdCheckBox.Checked = e.Dcd;
this.riCheckBox.Checked = e.Ring;
}

this.eventsTextBox.AppendText(eventDescription + "\r\n");
}


Viewing all articles
Browse latest Browse all 69326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>