#points #display #pixel #bindings #packet #send #servicepoint

sys servicepoint_binding_c

C bindings for the servicepoint crate

3 releases (breaking)

new 0.7.0 Jun 27, 2024
0.6.0 Jun 5, 2024
0.5.1 May 28, 2024

#29 in #points

Download history 125/week @ 2024-05-25 152/week @ 2024-06-01 14/week @ 2024-06-08 1/week @ 2024-06-15 127/week @ 2024-06-22

301 downloads per month

GPL-3.0-or-later

120KB
2K SLoC

servicepoint_binding_c

crates.io Crates.io Total Downloads docs.rs GPLv3 licensed

In CCCB, there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display".

This crate contains C bindings for the servicepoint library, enabling users to parse, encode and send packets to this display via UDP.

Examples

#include <stdio.h>
#include "servicepoint.h"

int main(void) {
    sp_Connection *connection = sp_connection_open("localhost:2342");
    if (connection == NULL)
        return 1;

    sp_PixelGrid *pixels = sp_pixel_grid_new(sp_PIXEL_WIDTH, sp_PIXEL_HEIGHT);
    sp_pixel_grid_fill(pixels, true);

    sp_Command *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
    sp_Packet *packet = sp_packet_from_command(command);
    if (!sp_connection_send(connection, packet))
        return 1;

    sp_connection_dealloc(connection);
    return 0;
}

A full example including Makefile is available as part of this crate.

Note on stability

This library is still in early development. You can absolutely use it, and it works, but expect minor breaking changes with every version bump. Please specify the full version including patch in your Cargo.toml until 1.0 is released.

Installation

Copy the header to your project and compile against.

You have the choice of linking statically (recommended) or dynamically.

  • The C example shows how to link statically against the staticlib variant.
  • When linked dynamically, you have to provide the cdylib at runtime in the same version, as there are no API/ABI guarantees yet.

Notes on differences to rust library

  • function names are: sp_ <struct_name> <rust name>.
  • Instances get consumed in the same way they do when writing rust / C# code. Do not use an instance after an (implicit!) free.
  • Option or Result<T, E> turn into nullable return values - check for NULL!
  • There are no specifics for C++ here yet. You might get a nicer header when generating directly for C++, but it should be usable.
  • Reading and writing to instances concurrently is not safe. Only reading concurrently is safe.
  • documentation is included in the header and available online

Everything else

Look at the main project README for further information.

Dependencies

~1–2.5MB
~44K SLoC