diff options
Diffstat (limited to 'proto')
-rw-r--r-- | proto/.gitignore | 1 | ||||
-rw-r--r-- | proto/include.cmake | 12 | ||||
l--------- | proto/lib | 1 | ||||
-rw-r--r-- | proto/makefile | 7 | ||||
-rw-r--r-- | proto/puzbusv1.c | 13 | ||||
-rw-r--r-- | proto/puzbusv1.h | 22 | ||||
-rw-r--r-- | proto/puzbusv1.proto | 12 |
7 files changed, 48 insertions, 20 deletions
diff --git a/proto/.gitignore b/proto/.gitignore deleted file mode 100644 index 75feca5..0000000 --- a/proto/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*.pb.* diff --git a/proto/include.cmake b/proto/include.cmake index d5beaef..c8a90b6 100644 --- a/proto/include.cmake +++ b/proto/include.cmake @@ -1 +1,13 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}) + +# mpack +include_directories(${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack) +add_library(mpack STATIC + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-common.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-expect.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-node.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-platform.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-reader.c + ${CMAKE_CURRENT_LIST_DIR}/lib/mpack/src/mpack/mpack-writer.c + ) + diff --git a/proto/lib b/proto/lib new file mode 120000 index 0000000..dc598c5 --- /dev/null +++ b/proto/lib @@ -0,0 +1 @@ +../lib
\ No newline at end of file diff --git a/proto/makefile b/proto/makefile deleted file mode 100644 index 3bc4ca4..0000000 --- a/proto/makefile +++ /dev/null @@ -1,7 +0,0 @@ -PROTOCARGS += --cpp_out . - -all: puzbusv1.pb.cc puzbusv1.pb.h - -%.pb.cc %.pb.h &: %.proto - protoc $(PROTOCARGS) $< - diff --git a/proto/puzbusv1.c b/proto/puzbusv1.c new file mode 100644 index 0000000..9d1335e --- /dev/null +++ b/proto/puzbusv1.c @@ -0,0 +1,13 @@ +#include <mpack.h> + +#include "puzbusv1.h" + +int pb_read(struct pb_msg* target, char* buf, size_t buf_sz) { + mpack_reader_t reader; + + return 0; +} + +void pb_free(struct pb_msg* msg); + + diff --git a/proto/puzbusv1.h b/proto/puzbusv1.h new file mode 100644 index 0000000..071c887 --- /dev/null +++ b/proto/puzbusv1.h @@ -0,0 +1,22 @@ +#pragma once + +#include <stddef.h> +#include <stdint.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct pb_msg { + uint16_t addr; + char* data; + size_t length; +}; + +int pb_read(struct pb_msg* target, char* buf, size_t buf_sz); +void pb_free(struct pb_msg* msg); + +#ifdef __cplusplus +} +#endif + diff --git a/proto/puzbusv1.proto b/proto/puzbusv1.proto deleted file mode 100644 index 6b4fa52..0000000 --- a/proto/puzbusv1.proto +++ /dev/null @@ -1,12 +0,0 @@ -syntax = "proto2"; - -package puzbus; - -message I2CMsg { - // 32-bit is the smallest integer format supported by protobuf, even though - // we only need 7-10 bits for the I2C address. - required uint32 address = 1; - - optional bytes data = 2; -} - |