LinkUp is a cross platform lightweight communication library. The framework is able to transmit data between different microcontrollers, mobile devices and computers.
The current version of the library is released on nuget.
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.
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.
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 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.
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 |
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.
BlockingCollection<byte[]> col1 = new BlockingCollection<byte[]>();
BlockingCollection<byte[]> col2 = new BlockingCollection<byte[]>();
LinkUpMemoryConnector slaveToMaster = new LinkUpMemoryConnector(col1, col2);
LinkUpMemoryConnector masterToSlave = new LinkUpMemoryConnector(col2, col1);
slaveToMaster.SendPacket(new LinkUpPacket() { Data = data });
masterToSlave.ReveivedPacket += MasterToSlave_ReveivedPacket;
The next example will show a basic communication between a C# programm and an Arduino microcontroller.
LinkUpSerialPortConnector dataPort = new LinkUpSerialPortConnector(portName, baudRate);
LinkUpRaw connector;
dataPort.SendPacket(new LinkUpPacket() { Data = data });
LinkUpPacket packet;
connector.send(packet);
nBytesToSend = connector.getRaw(pBuffer, BUFFER_SIZE);
dataPort.ReveivedPacket += DataPort_ReveivedPacket;
connector.progress(pBuffer, nBytesRead);
if (connector.hasNext())
{
LinkUpPacket packet = connector.next();
}
The next example will show a basic communication between a C# programm and an other C# programm over UDP.
LinkUpUdpConnector connector = new LinkUpUdpConnector(sourceIp, destinationIp, sourcePort, destinationPort);
connector.SendPacket(new LinkUpPacket() { Data = data });
connector.ReveivedPacket += DataPort_ReveivedPacket;