Skip to content

tweichselbaumer/LinkUp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LinkUp

About

LinkUp is a cross platform lightweight communication library. The framework is able to transmit data between different microcontrollers, mobile devices and computers.

Build

Build status

Installation

The current version of the library is released on nuget.

Arduino/C/C++

If you use Visual Studio for developing your Arduino/C/C++ Project, you can install the nessesary files by adding a nuget package with the nuget packages manager.

Alternatively, download the package from nuget, unzip the file and extract the files from content\native. Add these files to your project.

C#/.net/Xamarin/Portable

The C# version of the library can be installed by the nuget package manager. If you create a portable library, make sure to use this LinkUp nuget package also at the nativ project to support the full functionality.

Architecture

The LinkUp protocol is splitted into several layer. The LinkUpRaw layer which provides a communication protocol between two endpoints. The LinkUpLogic organizes nodes in a hirachical tree. Each node can provide there one labels. Labels represents different kinds of functionalties and are accessable from there node and all it's parent nodes.

LinkUpRaw Layer

LinkUpRaw provides basic data transmissions between two endpoints. It encapsulats binary data into a header with preamble, length, data, CRC16 and EOP(end of packet). It has the capability to detect bit errors. The m Bytes with the value of preamble, EOP, skip pattern are replaced by the skip pattern and the actual value XOR 0x20.

LinkUpPacket

Name Size (Byte) Offset (Byte)
Preamble 1 0
Length 4 1
Data n (max 2^32) 5
CRC16 2 n + 5
EOP 1 n + 7

Get Started

C# - LinkUpRaw (single process)

In this sample the basic usage of LinkUpRaw will be demonstrated. In this case we use the LinkUpMemoryConnector which only provieds communication in the same programm. This code is mostly useful for testing purpose.

Code

Initialisation

BlockingCollection<byte[]> col1 = new BlockingCollection<byte[]>();
BlockingCollection<byte[]> col2 = new BlockingCollection<byte[]>();

LinkUpMemoryConnector slaveToMaster = new LinkUpMemoryConnector(col1, col2);
LinkUpMemoryConnector masterToSlave = new LinkUpMemoryConnector(col2, col1);

Send Packet

slaveToMaster.SendPacket(new LinkUpPacket() { Data = data });

Receive Packet

masterToSlave.ReveivedPacket += MasterToSlave_ReveivedPacket;

C#/Arduino - LinkUpRaw (Serial Port)

The next example will show a basic communication between a C# programm and an Arduino microcontroller.

Code

Initialisation

C# Program
LinkUpSerialPortConnector dataPort = new LinkUpSerialPortConnector(portName, baudRate);
Arduino
LinkUpRaw connector;

Send Packet

C# Program
dataPort.SendPacket(new LinkUpPacket() { Data = data });
Arduino
LinkUpPacket packet;
connector.send(packet);
nBytesToSend = connector.getRaw(pBuffer, BUFFER_SIZE);

Receive Packet

C# Program
dataPort.ReveivedPacket += DataPort_ReveivedPacket;
Arduino
connector.progress(pBuffer, nBytesRead);

if (connector.hasNext())
{
    LinkUpPacket packet = connector.next();
}

C#/C# - LinkUpRaw (UDP)

The next example will show a basic communication between a C# programm and an other C# programm over UDP.

Code

Initialisation

C# Program
LinkUpUdpConnector connector = new LinkUpUdpConnector(sourceIp, destinationIp, sourcePort, destinationPort);

Send Packet

C# Program
connector.SendPacket(new LinkUpPacket() { Data = data });

Receive Packet

C# Program
connector.ReveivedPacket += DataPort_ReveivedPacket;