feat: add FFI layer, protocol tests, mock transport, README

- FFI: eskin_open/close/read_register/write_register for C/C++/Python
- Protocol: encode/decode tests with golden bytes verification
- Stream: implement PollingSampleCollector producing FingerSample
- Register: add parse_combined_forces/parse_module_errors
- Transport: add MockSerialTransport for testing
- Include: add C header file eskin_ffi.h
- Examples: C++ and Python usage examples
- README: full usage guide for Rust/C++/Python
- Exclude docs/ from repo (internal only)
This commit is contained in:
lenn
2026-05-06 00:54:44 +08:00
parent 60f9ad15e7
commit a7b7192341
13 changed files with 721 additions and 1915 deletions

67
include/eskin_ffi.h Normal file
View File

@@ -0,0 +1,67 @@
#ifndef ESkin_FFI_H
#define ESkin_FFI_H
#include <cstdint>
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef void* EskinDeviceHandle;
typedef struct {
uint16_t major;
uint16_t minor;
uint16_t patch;
} EskinSdkVersion;
typedef enum {
ESkinSuccess = 0,
ESkinInvalidPointer = 1,
ESkinDeviceNotFound = 2,
ESkinDeviceAlreadyOpen = 3,
ESkinNotInitialized = 4,
ESkinAlreadyStreaming = 5,
ESkinNotStreaming = 6,
ESkinConfigError = 7,
ESkinIoError = 8,
ESkinTimeout = 9,
ESkinChannelClosed = 10,
ESkinInternalError = 11,
ESkinBufferOverflow = 12,
ESkinInvalidParameter = 13,
ESkinCrcError = 14,
ESkinFrameError = 15,
ESkinProtocolError = 16,
ESkinDeviceError = 17,
} EskinSdkErrorCode;
EskinSdkVersion eskin_version(void);
EskinDeviceHandle eskin_open(const char* path, const void* config);
EskinSdkErrorCode eskin_close(EskinDeviceHandle handle);
EskinSdkErrorCode eskin_read_register(
EskinDeviceHandle handle,
uint32_t addr,
uint16_t length,
uint8_t* buf,
uint32_t buf_len,
uint32_t* actual_len
);
EskinSdkErrorCode eskin_write_register(
EskinDeviceHandle handle,
uint32_t addr,
const uint8_t* data,
uint16_t data_len,
uint16_t* return_count
);
#ifdef __cplusplus
}
#endif
#endif