To Use the API
C++ Includes Example
VB6 Includes Example
C# Includes Example
Create New DLL
Serial to USB Adapter
Hints
To Use the API
-
Include the CS460.dll and CS460.lib files in the debug directory or wherever the exe is located
-
In the code, reference the needed functions from the dll
C++ Includes Example
-
HANDLE _stdcall kr_OpenPort(char *port);
-
void _stdcall kr_ClosePort(HANDLE com);
-
int _stdcall kr_Read(HANDLE com, unsigned char * msg, int NumBytesToRead);
-
int _stdcall kr_Write(HANDLE com, unsigned char * msg, int NumBytesTorRead);
VB6 Includes Example
-
Public Declare Function kr_OpenPort Lib "CS460.dll" (ByVal port As String) As Long
-
Public Declare Function kr_ClosePort Lib "CS460.dll" (ByVal handle As Long) As Long
-
Public Declare Function kr_Read Lib "CS460.dll" (ByVal handle As Long, ByRef ByteArr As Byte, ByVal Num As Long) As Long
-
Public Declare Function kr_Write Lib "CS460.dll" (ByVal handle As Long, ByteArr As Byte, ByVal Num As Long) As Long
C# Includes Example
-
[DllImport("CS460.dll", EntryPoint = "kr_OpenPort", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern IntPtr kr_OpenPort(string port);
-
[DllImport("CS460.dll", EntryPoint = "kr_ClosePort", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)
]
public static extern void kr_ClosePort(IntPtr comm);
-
[DllImport("CS460.dll", EntryPoint = "kr_Read", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int kr_Read(IntPtr comm, ref byte msg, int num);
-
[DllImport("CS460.dll", EntryPoint = "kr_Write", ExactSpelling = true, CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int kr_Write(IntPtr comm, ref byte input, int num);
To Create New DLL
-
Create a new dll project in C++
-
Insert the CS460.c and CS460.def files into the project
-
Create the dll by pressing F7
-
The dll and lib files will be in the debug folder
To Use the Serial to USB Adapter
-
Insert the disk into the drive
-
Plug in the USB end into a port
-
Load driver from the disk
-
Adapter should then be usable
Hints
-
Use a long as the comm port handle in VB
-
Use a System.IntPtr as the comm port handle in .NET
-
Save often when using VB6 and dlls. An improper call will cause an error and the whole VB6 program will shut down.
-
If more resources are needed on the comm port, go to http://msdn.microsoft.com for all of Microsoft's documentation.