K8090 Source code for Velleman.Kits.dll

Here’s the source code for the Velleman.Kits assembly
velleman.eu/downloads/files/ … DotNet.zip

It uses the native K8090 DLL to communicate with the board, but in your case you could easily write something that simply uses the .NET SerialPort class instead, which would be a better solution since using unmanaged code is generally not recommended. We could not do that because we needed to demonstrate how to use the native DLL. Just review the protocol to know what to send and what to expect.

How does the current solution work?
The native DLL uses a window handle to send asynchronous events (in the form of windows messages) back to an application when a packet is received. So what the .NET class does is create a message-only window which it passes to the native DLL to be able to capture those events. This solution also solves threading issues, because the native DLL uses a separate reader thread, and since the message will be received in the thread that created the window, this problem automagically solves itself.