Member of:

Kithara »Serial Toolkit«

The »Serial Toolkit« allows programming for different communication exercises—especially in the industrial field.

It provides two modes: Either the use of operating system functions, therefore all known COM interfaces will be supported. Or the activation of UART Hardware, which enables the real-time handling of all interface events. The API of both of these modes is nearly the same.

The »Serial Toolkit« is employed if it is necessary to develop communication protocols for serial interfaces of PCs. For simplicity of use is it possible to work with the different scenarios in a short training period. It allows the programming of individual solutions if they are needed for hardware oriented or time critical applications.

To obtain the real-time ability, the whole communication carried on the kernel level, which means that it is possible to have time exact reactions to all interface events and you can influence the hardware.

In order to carry this out, the programmer accesses the kernel level. But they are still in the developing environment they used to, such as C/C++ or Delphi to carry out industrial communication protocols.

  • Fast and flexible reactions on incoming data or events
  • Direct control of handshake preformance
  • Handler for all events, e.g. Byte Handler, LSR, MSR-Change, Break, Error
  • All interfaces are usable with operating system support.
  • Recognition of "transmit empty" (e.g. for RS485 change direction)
  • Automatic RS485-Change direction programmable
  • Endless mode for direct emitting from user puffer and other special scenarios
  • Timeout monitoring automatically
  • Dynamic initialization including baud rate - switching
  • Emitting and receiving on application or kernel level
  • Real-time reactions possible to each character
  • Information about transmit errors, timeout, abortion etc.
  • Information about modem state or line state change
  • UART hardware support from 16550 to 16950
  • C/C++ or Delphi (Win32 native) are supporting usage on kernel level
  • Supports the following operating systems: Windows 7, Vista, Server 2003, XP, 2000 and NT
  • Description
  • Features
  • Examples
  • FAQ
  • Hardware
Base Module

Basic functions to open the kernel, shared memory, events, callbacks, threads, priorities, pipes

The Base Module is the foundation of the whole »RealTime Suite«.

Create all needed resources, that enable for example the communication between application and kernel level!

The Base Module provides functions to administer the kernel driver. Therefore »RealTime Suite« can be used by several programs at the same time.

The Base Module contains functions to create and administer the following resources:

  • Shared Memory
  • Data and message pipes for quick data exchange
  • Event objects
  • CallBack functions
  • Threads
  • Fast mutex objects

Furthermore, the Base Module contains additional functions to deliver information to the »Kernel Tracer«. This allows to make debugging and problem-solving more comfortable.


Pay attention to the Kernel Module, that provides more universal functions and is essential to access the kernel level.

The Base Module is always required.

General functions
Open/close the kernel
Version control, driver configuration
Threads
Creating threads
Determine/set desired values of absolute thread priority
Shared memory
Shared memory especially for data exchange
Protected from swapping to hard disk (memory will be fixed in memory)
Multiple memory blocks with up to 60 MByte each
Pipes
Lock-free and fast data pipes and message pipes
Enables comfortable and synchronized data exchange in desired direction between kernel and application
Needs no additional synchronisation (supports multi-core CPUs)
Signalizing
Event objects: set, reset and pulse to activate an application thread
Callback execution of user code on kernel or application level
Sending Windows messages
Fast mutex objects
Fast synchronisation ("Mutex" = Mutual Exclusion)
Multi-processor suitable
Device information
Detection of device information of PCI-, USB-, COM-, HID-Devices etc.
Debug support
Sending formatted text messages from kernel level
Compatible to »Kernel Tracer« for profiling and debugging

The Base Module provides multiple functions, e.g. shared memory for data exchange between application and kernel:

err = KS_createSharedMem(
&pAppPtr, // Application address
&pSysPtr, // System address of memory
"MySharedMem", // Globally valid name
40 * MegaBytes, // Length in bytes
0); // Flags, here 0

For the simplification of periodical data exchange is it ideal to use a data pipe, which is also based on shared memory:

err = KS_createPipe(
&hPipe, // Address of pipe handle
"MyValuePipe", // Name of pipe
2, // Data size (e.g. measurement values)
1000000, // max. number of data elements
NULL, // reserved
0); // Flags, here 0

Now you can deposit the measured values in the pipe:

err = KS_putPipe(
hPipe, // Pipe handle
valueBuffer, // Pointer to data buffer
valueCount, // Number of values
NULL, // Not used here
0); // Flags, here 0

Application can read measured values from the pipe:

err = KS_getPipe(
hPipe, // Pipe handle
buffer, // Pointer to data buffer
bufferSize, // max. number of values
&filledSize, // How many values read?
0); // Flags, here 0

Variable-length data (e.g. messages) can be best handled with a message pipe. The usage is similar to the above mentioned way.

Required qualifications
Support of single or dual-core, multi-core CPUs, Hyperthreading, SMP etc.
Support of standard PIC or APIC, ACPI
Best platform would be a dual-/quad-core PC (with APIC + ACPI)
Support of Windows Vista (x86), Windows Server 2003, Windows XP (Embedded), Windows 2000, Windows 7
Programming on kernel level in C/C++ and Delphi (Win32)
What are the special characteristics of shared memory?
No hard-disk storage, thats means it is always available (also in real-time settings)
Accessible from application and also from kernel level
It exists exactly once, thats means it can also be used for data exchange between different applications (but in each program KS_createSharedMem has to be called)
The memory is initialized with 0—a counter is checking, if the the memory is used from an other program
Access to memory is not automatically synchonized (for synchonized access we recommend data pipes and message pipes)

There is no special hardware needed.

Kernel Module

Source code on the kernel level

Real-time capability can only be achieved on the kernel level.

Bring your application code to the kernel level and gain access to the real-time world under Windows!

C/C++ compilers or the development environment Delphi (Win32) is required to generate native x86 code. Please consider that the .NET environment with C# is generally also supported, while only a native C++ or Delphi DLL can be used for kernel execution. Appropriate projects which are immediately compileable are provided in every software delivery.

There are two different ways to bring your source code to the kernel level:

  • Instruction-wise relocation of a callback function and its sub-routines into the kernel address space
  • Loading a DLL directly to the kernel level

Whereas the first method can have more advantages for short projects, the second option provides even more opportunities and allows for instance a simple creation of debug messages, which can be used in the »Kernel Tracer« for a solving problems.

Furthermore, you can realize complex control applications with a graphical interface which was created in e.g. Java or C#.NET, while only the time critical code parts are running in kernel mode.


The Kernel Module is required to execute application code on the kernel level.

Tracing callback functions and their sub routines
Direct loading of a DLL on the kernel level
DLL can be created with C/C++ or Delphi (Win32)
Callback functions will be directly executed in the interrupt service routine (ISR) or in real-time timer context
All important functions of the »RealTime Suite« are also executable on kernel level, e.g.:
I/O port access
Access to physical memory
Measuring system time and precise short-time delays
Data communication over data- and message-pipes
Sending and receiving over serial interfaces
Sending and receiving over Ethernet network connections
EtherCAT process data exchange in automation solutions
Setting events (also reset, pulse)
Events from kernel level: events and Windows messages
Faster data-exchange between application and kernel via shared memory or lock-free data and message pipes

Assuming that your callback-function for the real-time timer looks like that:

int __stdcall myTimerCallback(
void* pArgs, // Address of reference data
void* pContext); // Address of context data

There are two ways to get the user code to the kernel level:

err = KS_createCallBack(
&hCallBack, // Address of handle
myTimerCallback, // Address of function
pSysAddrOfMyData, // Reference parameter
KSF_KERNEL_EXEC, // on the kernel level!
0); // Application priority, here 0

This way a function is loaded into the kernel memory.

Alternativly, you load a whole DDL into the kernel:

err = KS_loadKernel(
&hKernel, // Address of handle
"mykernel.dll", // File name of kernel DLL
"myInitFunction", // Name of init routine
pArgs, // Reference parameter
KSF_KERNEL_EXEC); // Flags, load into kernel

If it is once loaded in the kernel, you can create a kernel callback:

err = KS_createKernelCallBack(
&hCallBack, // Address of handle
hKernel, // Kernel Handle
"myTimerCallback", // Name of function
pSysAddrOfMyData, // Reference parameter
KSF_KERNEL_EXEC, // on the kernel level!
0); // Application priority, here 0

The callback handles can now be used as timer or interrupt handlers or to a real-time signalization for incoming Ethernet frames.

Hint:Complete Projects, for applications in languages like C++, C# or Delphi and also DDLs, which are loaded into kernel in C++ or Delphi, are components of every software delivery.

How can kernel communicate with the application?
Shared memory areas for not synchronizied data exchange
Data and message pipes based on shared memory (lock-free, therefore are the reading and the writing site synchronizied against each other)
Kernel can set event objects to activate application threads
The application level can trigger a execution of function in kernel
Windows messages
How to debug code for the kernel level?
User code can be debuged in the developing area:
Callback function will be executed on the application level by a special flag
Kernel DLL will be loaded on the application level by a special flag
Shared memory, events, access to I/O ports and physical memory etc. are available for both contexts

There is no special hardware needed.

IoPort Module

Access to the physical memory

The IoPort Module enables access to the I/O register of computers.

Get directly access to the I/O ports of the computer with the IoPort Module from the application!

Implemented hardware assemblies/mezzanine and PC cards can be controlled by controllers with a access to the I/O register. Therefore are functions for 8, 16 and 32 bit access available.

The IoPort Module is also required to trace the hardware resources (e.g. memory address or interrupt lines), which were dynamical allocated by Plug&Play-Manager from Windows.

The term "I/O Ports" does not mean COM ports or LPT ports, but rather the altogether 65536 I/O machine commands for all available I/O addresses of the system. Therewith you can control the I/O register of COM and LPT-controllers.


Add the Memory Module to your Custom Driver, if the hardware you want to use provides memory access.

I/O port access
Enable direct access to I/O ports
I/O access from application program without context change possible
Access protection for operating system, for all unenabled address still intact und active
Only own application gets access to addresses
No limitaions for the system
Functions for direct and indirect I/O access
8, 16 and 32bit access, reading or writing
Functions compatible to (under DOS) known C Makros
Resource tracing
Tracing of allocated rescoures from Plug&Play-Manager (Basis addresses, IRQs)
Reading and writing of PCI configuration block

If you want to use direct I/O port access, you have to enable the I/O area for the direct access:

err = KS_enableIoRange(
myBaseAddress, // Basis addresses of hardware
8, // Number of I/O register
KSF_SIZE_8_BIT); // Flags, here byte-wise

Now, you can address the enabled hardware-register:

byte value = KS_inpb(
myBaseAddress + 2); // Address, 1 byte read
... // Byte analyse
KS_outpb(
myBaseAddress + 4, // Address, 1 byte write
value); // Byte write

If the I/O basis address of a PCI card is dynamical allocated from the Plug&Play-Manager, is it easy to trace by either all PCI assemblies will be browsed till the the vendor and device id is founded:

err = KS_getBusData(
&pciData, // Address of PCI-structure
busNumber, // Bus-number
slotNumber, // Device number and function
0); // Flags, here 0
if (pciData.vendorID == XXXX && pciData.deviceID == YYYY)
...

Or immediatly browsed by the desired id combination:

err = KS_getRessourceInfo(
"PCI\\VENxxxx&DEVyyyy", // ID combination
&resourceInfo); // Address of resource info

The received data structures containing all necessary information about interrupt lines and used I/O or memory basis addresses.

How to trace the rescources, which were dynamical allocated by the PCI Plug&Play ?
Either with 'KS_getBusData': Iterate all PCI devices in system until the searched parameter (vendor id, device id, etc.)is founded
or with 'KS_getResourceInfoEx': Delivering parameter of the searched device and result of described data structure
with 'KS_getResourceInfo' you can data from other interfaces like serical (COM) or parallel (LPT) or from network cards (NET) for the Packet Module and USB devices

There is no special hardware needed.

Serial Module

Serial communication in real-time

The Serial Module provides serial communication in real-time.

Realize extensive serial communication protocols under Windows!

The Serial Module supports two different modes: either serial communication via all COM interfaces of the PC without real-time or serial communication in real-time und direct hardware controlling via UART 16550 and higher.

The Serial Module allows to realize communication application for serial COM interfaces in a simlpy way. It is simpler to difference between the two different kinds of signalization than it is for the Windows API: blocking the call until the send or receive order has finished, signalization by callback or event – which can be found in all other modules.

The Serial Module allows the realization of almost all individual and complex industrial communication protocols in its real-time mode. By a reason of a efficient kernel driver is it possible to get timed high precision reactions on all interface events and to influence directly the hardware on kernel level. The API in both modi is the same.


For an addition of "virtual COM ports", please note Device Module

Requires the Kernel Module.

Serial communication via all COM interfaces of the pc on Windows mechanisms or in real-time by UART hardware support from 16450 to 16950
Flexible reaction on incoming data and events by blocking, callback or event
Listing of all COM interfaces in PC (Base Module)
Fast reaction on incoming data and events
Direct controlling of handshake line
Handler for all events, e.g. byte handler, LSR, MSR Change, Break, Error
Detection of "transmit empty" (e.g. for RS485-Richtungsumschaltung or 9-bit-Modus)
Automatical RS485-Richtungsumschaltung programmable
Unending-mode for direct sending from user puffer and other special scenarios
Automatical timeout monitoring connectable
Automatical performance error monitoring programmable
Maximal baud rate detectable
Send and receive are undependent to each other
Received data will be automatically puffered in the background
Bridgeover of receive in multiple seconds
List of all supporting cards
Supporting of further cards affordable to implement

Use the following function to list up all COM ports:

err = KS_enumDevices(
"COM", // Searching COM ports
i, // Counter, strating with 0
portNameBuf, // Puffer for COM port names
0); // Flags, here 0

The interfaces can be opened like the following:

KSResourceInfoEx info;
err = KS_openSerialPort(
&hPort, // Address of handle
portNameBuf, // Name of ports (e.g. "COM1")
"9600,n,8,1", // Initialising
KSF_KERNEL_EXEC); // Kernel implementation

Thats how we send data, e.g. a measuring request to a device:

err = KS_xmitPort(
hPort, // Port handle
NULL, // Signalisation (Post Mode)
message, // Puffer address
0, // Length, to send (auto)
NULL, // Length, sent
KSF_DONT_WAIT); // Flags: without blocking

Anytime, you can detect the number of received characters:

err = KS_getPortState(
hPort, // Port handle
&state, // Address of state structure
0); // Flags: here 0
printf("%d characters received.\n", state.recvAvail);

The receiving looks like the following (in Wait Mode on application level):

err = KS_recvPort(
hPort, // Port handle
NULL, // Signalisation (Wait Mode)
pBuffer, // Address of data puffer
state.recvAvail, // Length, to receive
&received, // Length, received
KSF_USE_TIMEOUTS); // Flags: time out monitoring
What is the "normal" mode of Serial Module?
Flag KSF_USER_EXEC for opening the port
Based on Windows driver mechanisms
Supports all COM interfaces in system (also "virtual interfaces", e.g. USB to COM adapter)
no real-time
What marks the kernel mode?
Flag KSF_KERNEL_EXEC for opening the port
Hardware is directly controlled by a special driver
Requires UART 16550 compatable hardware
Reaction to all interface events within the Interrupt Service Routine
What are the qualifications for the kernel-mode?
Interface-hardware compatable to UART-16550
Resourcen (Interrupt and I/O-Basis address) detectable
Either implemented COM ports orsupported cards
Support of furhter cards to implement is affordable
Is it possible to support higher baud rates?
Yes, higher standart baud rates will be automatically identified
Special baud rates can be predefined
We would like to realize an enhancement of a driver in your order

The Serial Module requires special hardware in kernel mode.

To get high reaction ability is it necessary to replace the slow Windos driver on the serial interface. In order that is it only possible to support determined serial interface assemblies. This limitation is takes only effect in kernel mode, because UART 16550 compatable hardware has to be used. Belonging to this:

Standart interfaces

  • All in PC implemented RS232 interfaces, on ISA PnP cards, PC card module (PCMCIA 16 bit)

PCI bus

  • MOXA: IndustIo CP 132 (2xSER, RS -422/485)
  • MOXA: IndustIo CP 114 (4xSER, RS 422/485)
  • MOXA: SmartIo C104H/PCI (4xSER)
  • MOXA: SmartIo C168H/PCI (8xSER)
  • ADDI-DATA: APCI 73xx (1xSER)
  • ADDI-DATA: APCI 74xx (2xSER)
  • ADDI-DATA: APCI 75xx (4xSER)
  • Brainboxes: PCI 4 Port Serial Card (z.B. CC- 68) (4xSER)
  • TCL: DataBooster (4xSER/8xSER) (via IoPort access)
  • SUNIX: 4088A/4089A (2xSER,2xPAR)
  • LINDY: 70585 (2xSER)
  • LINDY: 70616 (2xSER,2xPAR)
  • EXSYS: EX-41051 (1xSER)
  • EXSYS: EX-41052 (2xSER)
  • Wiesemann & Theis: 13812 (2*SER, RS-232, 1kV isolated)

CardBus 32-Bit

  • QUATECH: Serial I/O PC Card SSP 100 (1xSER)
  • SOCKET: Serial I/O PC Card (1xSER)

If you have some questions to the hardware support, please contact us! The support of other external interfaces is easy to add in the majority of cases. If you have tested the functionality with other implementation cards, we would like to get informed about it.

Platforms

Real-time capability can only be achieved on the kernel level. Therefore C/C++ or Delphi (Win32) is needed. Nevertheless the »RealTime Suite« supports different platforms, like e.g. the .NET environment:

  • C++Builder 2007 (CodeGear) with VCL interface
  • C++Builder 5 (Borland) with VCL interface
  • Microsoft Visual C++ 6 with MFC interface
  • Visual Studio 2005/2008 C++ with MFC interface
  • Delphi (Object Pascal) Win32 with VCL interface
  • Visual Studio 2005 C# with WPF interface

The solution is reached by storing time-critical code in DLL with all functions of the »RealTime Suite« and loading directly on the kernel level to get in real-time context.

Immediately, you can use program frames for the mentioned platforms and they are integrated in every software delivery.

System Requirements

The products of the »RealTime Suite« support a broad range of hardware and software combinations:

  • CPU: AMD (Athlon and above) or Intel (Pentium 2 and above)
  • Single or multi-core, Hyperthreading, SMP with altogether up to 8 CPU cores (more on request)
  • ACPI (Advanced Control and Power Interface) supported, (A)PIC (Advanced Programmable Interrupt Controller) supported (some of the functions require APIC PC)
  • Operating system: Windows 2000 (up to SP4), Windows XP (up to SP3), Windows Server 2003 (up to SP1), Windows Vista (x86, up to SP1), no guarantee for the usage together with newer service packs
  • Compiler for the kernel level: Microsoft: Visual C++/Visual Studio, CodeGear (Borland): C++Builder, Delphi Win32

If you have questions about the support of your system, please contact us!