2017-02-07 16:25:48 +01:00
|
|
|
# Porting libp7 to a new platform
|
|
|
|
Basically, the two things you will have to do to port libp7 to a new platform
|
|
|
|
is making macros for non-standard but required functionnalities from your
|
|
|
|
platform's libc, such as endianness correcting or sleeping, in the internal
|
|
|
|
headers located in `include/libp7/internals/`, and make a custom stream adapted
|
|
|
|
for your platform and prototype it.
|
|
|
|
|
2017-02-07 17:54:11 +01:00
|
|
|
libp7 streams are the libp7 abstraction between it and the calculator device.
|
2017-02-07 16:25:48 +01:00
|
|
|
You can check out the current streams in `src/stream/`. Currently supported
|
|
|
|
streams are libc FILEs, Unix-like streams (with file descriptors), Microsoft
|
|
|
|
Windows's libc streams (`HANDLE`s) and libusb streams (which can be disabled
|
|
|
|
by passing `--no-libusb` to the configure script). Each stream must implement
|
|
|
|
a function to connect to the device using `p7_sinit`, and functions to read
|
|
|
|
and write, and eventually one to set communication settings from cross-platform
|
|
|
|
values defined by libp7. You should really check out `p7_sinit`'s manpage.
|
2017-02-07 17:54:11 +01:00
|
|
|
|
|
|
|
You should as well make up a constant like `P7_DISABLED_<your type of stream>`
|
|
|
|
(e.g. `P7_DISABLED_LIBUSB`, `P7_DISABLED_STREAMS`, `P7_DISABLED_WINDOWS`),
|
|
|
|
and define it in `libp7/stream.h` aside with the prototypes of your functions.
|
2017-02-07 16:25:48 +01:00
|
|
|
|
|
|
|
Once this is done, you will want to hook your stream to one of the libp7
|
|
|
|
standard initialization functions: `p7_init` or `p7_cominit`. In order to do
|
2017-02-07 17:54:11 +01:00
|
|
|
this, you should add it your functions to the content of at least one of these
|
|
|
|
two functions. Platform-specific things are preferred in your stream's source
|
|
|
|
file.
|