Crates.io | servicepoint2 |
lib.rs | servicepoint2 |
version | 0.4.3 |
source | src |
created_at | 2024-05-11 22:15:04.287038 |
updated_at | 2024-05-26 14:44:27.501881 |
description | A rust library for the CCCB Service Point Display. |
homepage | https://docs.rs/crate/servicepoint2 |
repository | https://github.com/kaesaecracker/servicepoint |
max_upload_size | |
id | 1237095 |
size | 80,939 |
This fork will no longer be the repository where releases are published.
Please switch to the upstreamed version with the following changes in your Cargo.toml:
[dependencies]
- servicepoint2 = "0.4.2"
+ servicepoint = "0.5.0"
The new crate is also published on crates.io.
In CCCB, there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display". This repository contains a library for parsing, encoding and sending packets to this display via UDP.
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.
Expect bugs and/or missing features in the language bindings for now. If you need something specific, open an issue or a pull request.
This is where the library works the best. Any API usage accepted by the compiler in a safe context is either safe or buggy (issues welcome)
cargo add servicepoint2
fn main() {
// establish connection
let connection = servicepoint2::Connection::open("172.23.42.29:2342")
.expect("connection failed");
// clear screen content
connection.send(servicepoint2::Command::Clear.into())
.expect("send failed");
}
More examples are available in the repository folder and in the Projects using the library section
The lowest common denominator. Things to keep in mind:
sp2_
<struct_name> <rust name>.#include <stdio.h>
#include "servicepoint2.h"
int main(void) {
sp2_Connection *connection = sp2_connection_open("localhost:2342");
if (connection == NULL)
return 1;
sp2_PixelGrid *pixels = sp2_pixel_grid_new(sp2_PIXEL_WIDTH, sp2_PIXEL_HEIGHT);
sp2_pixel_grid_fill(pixels, true);
sp2_Command *command = sp2_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
sp2_Packet *packet = sp2_packet_from_command(command);
if (!sp2_connection_send(connection, packet))
return 1;
sp2_connection_dealloc(connection);
return 0;
}
Uses C bindings internally to provide a similar API to rust. Things to keep in mind:
NullPointerException
when trying to call a method where the native instance has been consumed already (e.g. when Send
ing a command instance twice). Send a clone instead of the original if you want to keep using it.Span<byte>
of an object after freeing the instance.using ServicePoint2;
// using statement calls Dispose() on scope exit, which frees unmanaged instances
using var connection = Connection.Open("127.0.0.1:2342");
using var pixels = PixelGrid.New(Constants.PixelWidth, Constants.PixelHeight);
while (true)
{
pixels.Fill(true);
connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone()));
Thread.Sleep(5000);
pixels.Fill(false);
connection.Send(Command.BitmapLinearWin(0, 0, pixels.Clone()));
Thread.Sleep(5000);
}
NuGet packages are not a good way to distribute native projects (relevant issue). Because of that, there is no NuGet package you can use directly. Including this repository as a submodule and building from source is the recommended way of using the library.
git submodule add https://github.com/kaesaecracker/servicepoint.git
git commit -m "add servicepoint submodule"
You can now reference servicepoint2-bindings-cs/src/ServicePoint2.csproj
in your project.
The rust library will automatically be built.
Please provide more information in the form of an issue if you need the build to copy a different library file for your platform.
Copy the header to your project and compile against.
You have the choice of linking statically (recommended) or dynamically.
staticlib
variant.cdylib
at runtime in the same version, as there are no API/ABI guarantees yet.This library has multiple compression libraries as optional dependencies. If you do not need compression/decompression support you can disable those features. In the likely case you only need one of them, you can include that one specifically.
[dependencies.servicepoint2]
git = "https://github.com/kaesaecracker/servicepoint.git"
default-features = false
features = ["compression-bz"]
Language bindings will not know which features are available and may fail at runtime. It is recommended to include all features for builds used outside of rust.
To add yourself to the list, open a pull request.
This library is a spiritual mix of a not-yet-working rust library called servicepoint
and a bunch of working but also unfinished C# code. Because most of the API concept and a bunch of code is taken from the rust library, the result is called servicepoint2
.
Contributions are accepted in any form (issues, documentation, feature requests, code, review, ...).
All creatures welcome.