Compare commits
	
		
			2 commits
		
	
	
		
			ff9b0a9dc8
			...
			90f1edb2c1
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
							 | 
						90f1edb2c1 | ||
| 
							 | 
						0344c0bdcf | 
					 9 changed files with 62 additions and 31 deletions
				
			
		
							
								
								
									
										16
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							
							
						
						
									
										16
									
								
								Cargo.lock
									
										
									
										generated
									
									
									
								
							| 
						 | 
					@ -187,17 +187,6 @@ dependencies = [
 | 
				
			||||||
 "wasi",
 | 
					 "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]]
 | 
					[[package]]
 | 
				
			||||||
name = "is_terminal_polyfill"
 | 
					name = "is_terminal_polyfill"
 | 
				
			||||||
version = "1.70.1"
 | 
					version = "1.70.1"
 | 
				
			||||||
| 
						 | 
					@ -395,14 +384,13 @@ dependencies = [
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[[package]]
 | 
					[[package]]
 | 
				
			||||||
name = "servicepoint"
 | 
					name = "servicepoint"
 | 
				
			||||||
version = "0.15.1"
 | 
					version = "0.16.0"
 | 
				
			||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
					source = "registry+https://github.com/rust-lang/crates.io-index"
 | 
				
			||||||
checksum = "2800caad491cb44f67e5dd5b8c61ece368eecfe588155d03c7d9864acbad6919"
 | 
					checksum = "9b04582e916474f1bc1605cad3773262c425d9062b487e49a0df59662f2cca8d"
 | 
				
			||||||
dependencies = [
 | 
					dependencies = [
 | 
				
			||||||
 "bitvec",
 | 
					 "bitvec",
 | 
				
			||||||
 "bzip2",
 | 
					 "bzip2",
 | 
				
			||||||
 "flate2",
 | 
					 "flate2",
 | 
				
			||||||
 "inherent",
 | 
					 | 
				
			||||||
 "log",
 | 
					 "log",
 | 
				
			||||||
 "once_cell",
 | 
					 "once_cell",
 | 
				
			||||||
 "rust-lzma",
 | 
					 "rust-lzma",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ keywords = ["cccb", "cccb-servicepoint", "cbindgen"]
 | 
				
			||||||
crate-type = ["staticlib", "cdylib", "rlib"]
 | 
					crate-type = ["staticlib", "cdylib", "rlib"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies.servicepoint]
 | 
					[dependencies.servicepoint]
 | 
				
			||||||
version = "0.15.1"
 | 
					version = "0.16.0"
 | 
				
			||||||
default-features = false
 | 
					default-features = false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[dependencies.env_logger]
 | 
					[dependencies.env_logger]
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										27
									
								
								README.md
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								README.md
									
										
									
									
									
								
							| 
						 | 
					@ -1,11 +1,11 @@
 | 
				
			||||||
# servicepoint_binding_c
 | 
					# servicepoint_binding_c
 | 
				
			||||||
 | 
					
 | 
				
			||||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c/releases)
 | 
					[](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/releases)
 | 
				
			||||||
[](https://crates.io/crates/servicepoint)
 | 
					[](https://crates.io/crates/servicepoint)
 | 
				
			||||||
[](https://crates.io/crates/servicepoint)
 | 
					[](https://crates.io/crates/servicepoint)
 | 
				
			||||||
[](https://docs.rs/servicepoint/latest/servicepoint/)
 | 
					[](https://docs.rs/servicepoint/latest/servicepoint/)
 | 
				
			||||||
[](./LICENSE)
 | 
					[](./LICENSE)
 | 
				
			||||||
[](https://git.berlin.ccc.de/servicepoint/servicepoint_binding_c)
 | 
					[](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.
 | 
					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".
 | 
					It is called  "Service Point Display" or "Airport Display".
 | 
				
			||||||
| 
						 | 
					@ -19,18 +19,22 @@ This crate contains C bindings for the [servicepoint](https://git.berlin.ccc.de/
 | 
				
			||||||
#include "servicepoint.h"
 | 
					#include "servicepoint.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int main(void) {
 | 
					int main(void) {
 | 
				
			||||||
    SPConnection *connection = sp_connection_open("172.23.42.29:2342");
 | 
					    UdpSocket *connection = sp_udp_socket_open("172.23.42.29:2342");
 | 
				
			||||||
    if (connection == NULL)
 | 
					    if (connection == NULL)
 | 
				
			||||||
        return 1;
 | 
					        return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SPBitmap *pixels = sp_bitmap_new(SP_PIXEL_WIDTH, SP_PIXEL_HEIGHT);
 | 
					    Bitmap *pixels = sp_bitmap_new(PIXEL_WIDTH, PIXEL_HEIGHT);
 | 
				
			||||||
    sp_bitmap_fill(pixels, true);
 | 
					    sp_bitmap_fill(pixels, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SPCommand *command = sp_command_bitmap_linear_win(0, 0, pixels, Uncompressed);
 | 
					    BitmapCommand *command = sp_bitmap_command_new(pixels, 0, 0, COMPRESSION_CODE_LZMA);
 | 
				
			||||||
    while (sp_connection_send_command(connection, sp_command_clone(command)));
 | 
					    Packet *packet = sp_bitmap_command_try_into_packet(command);
 | 
				
			||||||
 | 
					    if (packet == NULL)
 | 
				
			||||||
 | 
					      return 1;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    if (!sp_udp_socket_send_packet(connection, packet))
 | 
				
			||||||
 | 
					      return 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    sp_command_free(command);
 | 
					    sp_udp_socket_free(connection);
 | 
				
			||||||
    sp_connection_free(connection);
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
| 
						 | 
					@ -41,7 +45,9 @@ A full example including Makefile is available as part of this crate.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
This library is still in early development.
 | 
					This library is still in early development.
 | 
				
			||||||
You can absolutely use it, and it works, but expect minor breaking changes with every version bump.
 | 
					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.
 | 
					Pin a specific version until 1.0 is released.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					Release notes are published [here](https://git.berlin.ccc.de/servicepoint/servicepoint-binding-c/releases).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Installation
 | 
					## Installation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -77,6 +83,9 @@ When linked dynamically, you have to provide the `cdylib` at runtime in the _sam
 | 
				
			||||||
  guarantees yet.
 | 
					  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 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
 | 
					## Notes on differences to rust library
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- function names are: `sp_` \<struct_name\> \<rust name\>.
 | 
					- function names are: `sp_` \<struct_name\> \<rust name\>.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -96,7 +96,7 @@ endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# ADD NEW EXAMPLES HERE
 | 
					# ADD NEW EXAMPLES HERE
 | 
				
			||||||
_c_src := src/announce.c src/brightness_tester.c src/header_logger.c \
 | 
					_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/moving_line.c src/random_stuff.c src/wiping_clear.c src/undefined.c src/flut.c
 | 
				
			||||||
_programs := $(basename $(notdir $(_c_src)))
 | 
					_programs := $(basename $(notdir $(_c_src)))
 | 
				
			||||||
_bins := $(_programs)
 | 
					_bins := $(_programs)
 | 
				
			||||||
_unstripped_bins := $(addsuffix _unstripped, $(_bins))
 | 
					_unstripped_bins := $(addsuffix _unstripped, $(_bins))
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										33
									
								
								example/src/flut.c
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								example/src/flut.c
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,33 @@
 | 
				
			||||||
 | 
					#include <stdio.h>
 | 
				
			||||||
 | 
					#include <signal.h>
 | 
				
			||||||
 | 
					#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;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
use crate::{containers::ByteSlice, macros::wrap};
 | 
					use crate::{containers::ByteSlice, macros::wrap};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
    Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
 | 
					    Bitmap, BitmapCommand, CompressionCode, DataRef, DisplayBitVec, Grid,
 | 
				
			||||||
    Origin, Packet,
 | 
					    GridMut, Origin, Packet,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,7 +1,7 @@
 | 
				
			||||||
use crate::{containers::ByteSlice, macros::wrap};
 | 
					use crate::{containers::ByteSlice, macros::wrap};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
    Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
 | 
					    Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, DataRef, Grid,
 | 
				
			||||||
    Origin, Packet,
 | 
					    GridMut, Origin, Packet,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::{mem::transmute, ptr::NonNull};
 | 
					use std::{mem::transmute, ptr::NonNull};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,5 +1,5 @@
 | 
				
			||||||
use crate::{containers::ByteSlice, macros::wrap};
 | 
					use crate::{containers::ByteSlice, macros::wrap};
 | 
				
			||||||
use servicepoint::{CharGrid, CharGridCommand, Grid, Origin, Packet};
 | 
					use servicepoint::{CharGrid, CharGridCommand, Grid, GridMut, Origin, Packet};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
wrap! {
 | 
					wrap! {
 | 
				
			||||||
| 
						 | 
					@ -25,8 +25,9 @@ wrap! {
 | 
				
			||||||
        /// Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
					        /// Loads a [CharGrid] with the specified dimensions from the provided data.
 | 
				
			||||||
        ///
 | 
					        ///
 | 
				
			||||||
        /// returns: new CharGrid or NULL in case of an error
 | 
					        /// returns: new CharGrid or NULL in case of an error
 | 
				
			||||||
        fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_ok *mut CharGrid {
 | 
					        fn load(width: val usize, height: val usize, data: slice ByteSlice) -> move_some *mut CharGrid {
 | 
				
			||||||
            CharGrid::load_utf8(width, height, data.to_vec())
 | 
					            String::from_utf8(data.to_vec()).ok()
 | 
				
			||||||
 | 
					                .and_then(|s| CharGrid::load(width, height, &*s.chars().collect::<Vec<_>>()))
 | 
				
			||||||
        };
 | 
					        };
 | 
				
			||||||
    methods:
 | 
					    methods:
 | 
				
			||||||
        /// Returns the current value at the specified position.
 | 
					        /// Returns the current value at the specified position.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
use crate::{containers::ByteSlice, macros::wrap};
 | 
					use crate::{containers::ByteSlice, macros::wrap};
 | 
				
			||||||
use servicepoint::{
 | 
					use servicepoint::{
 | 
				
			||||||
    Cp437Grid, Cp437GridCommand, DataRef, Grid, Origin, Packet,
 | 
					    Cp437Grid, Cp437GridCommand, DataRef, Grid, GridMut, Origin, Packet,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
use std::ptr::NonNull;
 | 
					use std::ptr::NonNull;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue