P7_INIT(3) ========== Thomas "Cakeisalie5" Touhey :Email: thomas@touhey.fr :man source: libp7 :man manual: libp7 manual NAME ---- p7_init, p7_cominit, p7_finit, p7_exit - initialize and quit/terminate libp7 and communication SYNOPSIS -------- [source,c] ---- #include int p7_init(p7_handle_t **handle, unsigned int flags); int p7_cominit(p7_handle_t **handle, unsigned int flags, int port); int p7_finit(p7_handle_t **handle, unsigned int flags, FILE *rstream, FILE *wstream); void p7_exit(p7_handle_t *handle); p7_handle_t *handle = NULL; int err = p7_init(&handle, 1, 1); if (err) printf("Couldn't initialize libp7/communication: %s\n", p7_strerror(err)); /* make miracles */ p7_exit(handle, 1); ---- WARNING ------- Before sending a pointer to the handle, if you want libp7 to allocate it, it must be *NULL*! Otherwise, it will try to use the existing one! DESCRIPTION ----------- All initialization functions will create a handle that other functions will use to communicate with the calculator - one of them has to be called before any other function from libp7. They will also initiate communication and detect the environment - what *p7_start* used to do in previous versions of the library. *p7_init* will try to find a USB device, while *p7_cominit* will try to communicate with a USB-serial device with the *port* port number. *p7_finit* will use the libc filestreams you give to it as the calculator, it is mainly there for testing. *p7_exit* will terminate communication (if active) and free the handle. It will also close the given stream. The *flags* of the initialization functions are the following: *P7_ACTIVE*:: Start as the active side (not passive). The active side is useful for sending commands and files (*client*), where the passive side receives straight away commands (and files), and screenstreaming (*server*). Your application will most likely start in *active* mode. *P7_CHECK*:: If the previous flag is on, initialize the communication. If this flag is not set, the communication is supposed to be already initialized, likely because the last communication using *libp7* did not use the next flag. *P7_TERM*:: If this flag is on, the communication will be terminated. Not putting this flag is generally useful when you want another process to use the same communication channel as you. RETURN VALUE ------------ All functions return zero if everything went well, and the error code otherwise. ERRORS ------ See *p7_error*(3). SEE ALSO -------- *libp7*(3), *p7_error*(3)