diff --git a/Cargo.lock b/Cargo.lock index 41db3cd..63012a0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,6 +187,17 @@ dependencies = [ "wasi", ] +[[package]] +name = "inherent" +version = "1.0.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c38228f24186d9cc68c729accb4d413be9eaed6ad07ff79e0270d9e56f3de13" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "is_terminal_polyfill" version = "1.70.1" @@ -384,13 +395,14 @@ dependencies = [ [[package]] name = "servicepoint" -version = "0.16.0" +version = "0.15.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b04582e916474f1bc1605cad3773262c425d9062b487e49a0df59662f2cca8d" +checksum = "2800caad491cb44f67e5dd5b8c61ece368eecfe588155d03c7d9864acbad6919" dependencies = [ "bitvec", "bzip2", "flate2", + "inherent", "log", "once_cell", "rust-lzma", diff --git a/Cargo.toml b/Cargo.toml index cd9619c..f6bef14 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["cccb", "cccb-servicepoint", "cbindgen"] crate-type = ["staticlib", "cdylib", "rlib"] [dependencies.servicepoint] -version = "0.16.0" +version = "0.15.1" default-features = false [dependencies.env_logger] diff --git a/README.md b/README.md index 10f3193..fa0a49b 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # servicepoint_binding_c -[![Release](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/badges/release.svg)](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/releases) +[![Release](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c/badges/release.svg)](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c/releases) [![crates.io](https://img.shields.io/crates/v/servicepoint_binding_c.svg)](https://crates.io/crates/servicepoint) [![Crates.io Total Downloads](https://img.shields.io/crates/d/servicepoint_binding_c)](https://crates.io/crates/servicepoint) [![docs.rs](https://img.shields.io/docsrs/servicepoint_binding_c)](https://docs.rs/servicepoint/latest/servicepoint/) [![GPLv3 licensed](https://img.shields.io/crates/l/servicepoint_binding_c)](./LICENSE) -[![CI](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/badges/workflows/rust.yml/badge.svg)](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c) +[![CI](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c/badges/workflows/rust.yml/badge.svg)](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c) In [CCCB](https://berlin.ccc.de/), there is a big pixel matrix hanging on the wall. It is called "Service Point Display" or "Airport Display". @@ -19,22 +19,18 @@ This crate contains C bindings for the [servicepoint](https://git.berlin.ccc.de/ #include "servicepoint.h" int main(void) { - UdpSocket *connection = sp_udp_socket_open("172.23.42.29:2342"); + SPConnection *connection = sp_connection_open("172.23.42.29:2342"); if (connection == NULL) return 1; - Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT); + SPBitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT); sp_bitmap_fill(pixels, true); - BitmapCommand *command = sp_bitmap_command_new(pixels, 0, 0, COMPRESSION_CODE_LZMA); - Packet *packet = sp_bitmap_command_try_into_packet(command); - if (packet == NULL) - return 1; - - if (!sp_udp_socket_send_packet(connection, packet)) - return 1; + SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed); + while (sp_connection_send_command(connection, sp_command_clone(command))); - sp_udp_socket_free(connection); + sp_command_free(command); + sp_connection_free(connection); return 0; } ``` @@ -45,9 +41,7 @@ A full example including Makefile is available as part of this crate. This library is still in early development. You can absolutely use it, and it works, but expect minor breaking changes with every version bump. -Pin a specific version until 1.0 is released. - -Release notes are published [here](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/releases). +Please specify the full version including patch in your Cargo.toml until 1.0 is released. ## Installation @@ -83,9 +77,6 @@ When linked dynamically, you have to provide the `cdylib` at runtime in the _sam guarantees yet. The Makefile in the example directory contains a bunch of additional compiler flags you might want to add depending on your use case. -The nix flake provides a package for referencing in your flake. -The package provides a pkg-config file for automatic linking. - ## Notes on differences to rust library - function names are: `sp_` \ \. diff --git a/example/Makefile b/example/Makefile index a3c0df4..15e53d1 100644 --- a/example/Makefile +++ b/example/Makefile @@ -96,7 +96,7 @@ endif # ADD NEW EXAMPLES HERE _c_src := src/announce.c src/brightness_tester.c src/header_logger.c \ - src/moving_line.c src/random_stuff.c src/wiping_clear.c src/undefined.c src/flut.c + src/moving_line.c src/random_stuff.c src/wiping_clear.c src/undefined.c _programs := $(basename $(notdir $(_c_src))) _bins := $(_programs) _unstripped_bins := $(addsuffix _unstripped, $(_bins)) diff --git a/example/src/flut.c b/example/src/flut.c deleted file mode 100644 index 9f7534f..0000000 --- a/example/src/flut.c +++ /dev/null @@ -1,33 +0,0 @@ -#include -#include -#include "servicepoint.h" - -volatile bool aborted = false; - -void handle_sigint(int sig) { - (void)sig; // suppress unused warning - aborted = true; -} - -int main(void) { - UdpSocket *connection = sp_udp_socket_open("172.23.42.29:2342"); - if (connection == NULL) - return 1; - - Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT); - sp_bitmap_fill(pixels, true); - - BitmapCommand *command = sp_bitmap_command_new(pixels, 0, 0, COMPRESSION_CODE_LZMA); - Packet *packet = sp_bitmap_command_try_into_packet(command); - - signal(SIGINT, handle_sigint); - size_t packets_sent = 0; - while (!aborted && sp_udp_socket_send_packet(connection, sp_packet_clone(packet))) { - ++packets_sent; - } - - printf("packets sent: %zu\n", packets_sent); - sp_packet_free(packet); - sp_udp_socket_free(connection); - return 0; -} diff --git a/src/containers/bitmap.rs b/src/containers/bitmap.rs index 8bfb6eb..5974016 100644 --- a/src/containers/bitmap.rs +++ b/src/containers/bitmap.rs @@ -1,7 +1,7 @@ use crate::{containers::ByteSlice, macros::wrap}; use servicepoint::{ Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid, - GridMut, Origin, Packet, + Origin, Packet, }; use std::ptr::NonNull; diff --git a/src/containers/brightness_grid.rs b/src/containers/brightness_grid.rs index e269ced..3b3fabb 100644 --- a/src/containers/brightness_grid.rs +++ b/src/containers/brightness_grid.rs @@ -1,7 +1,7 @@ use crate::{containers::ByteSlice, macros::wrap}; use servicepoint::{ Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid, - GridMut, Origin, Packet, + Origin, Packet, }; use std::{mem::transmute, ptr::NonNull}; diff --git a/src/containers/char_grid.rs b/src/containers/char_grid.rs index bfc3119..8946b50 100644 --- a/src/containers/char_grid.rs +++ b/src/containers/char_grid.rs @@ -1,5 +1,5 @@ use crate::{containers::ByteSlice, macros::wrap}; -use servicepoint::{CharGrid, CharGridCommand, Grid, GridMut, Origin, Packet}; +use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet}; use std::ptr::NonNull; wrap! { @@ -25,9 +25,8 @@ wrap! { /// Loads a [CharGrid] with the specified dimensions from the provided data. /// /// returns: new CharGrid or NULL in case of an error - fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_some *mut CharGrid { - String::from_utf8(data.to_vec()).ok() - .and_then(|s| CharGrid::load(width, height, &*s.chars().collect::>())) + fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_ok *mut CharGrid { + CharGrid::load_utf8(width, height, data.to_vec()) }; methods: /// Returns the current value at the specified position. diff --git a/src/containers/cp437_grid.rs b/src/containers/cp437_grid.rs index 1c4e729..b67d1ae 100644 --- a/src/containers/cp437_grid.rs +++ b/src/containers/cp437_grid.rs @@ -1,6 +1,6 @@ use crate::{containers::ByteSlice, macros::wrap}; use servicepoint::{ - Cp437Grid, Cp437GridCommand, DataRef, Grid, GridMut, Origin, Packet, + Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet, }; use std::ptr::NonNull;