SWIG: test callback & output grabbing

This commit is contained in:
Philippe Teuwen
2020-12-13 23:43:03 +01:00
parent c7e5648164
commit 39710c5fdf
26 changed files with 8332 additions and 6950 deletions

View File

@@ -1,11 +1,26 @@
#ifndef LIBPM3_H
#define LIBPM3_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct pm3_device pm3;
pm3 *pm3_open(char *port);
// not catching output
int pm3_console(pm3 *dev, char *cmd);
// catching output as it comes
int pm3_console_async(pm3 *dev, char *cmd, int (*callback)(char* s));
// catching output at the end
//int pm3_console_sync(pm3 *dev, char *cmd, char* outbuf, int outbufsize);
const char *pm3_name_get(pm3 *dev);
void pm3_close(pm3 *dev);
pm3 *pm3_get_current_dev(void);
#ifdef __cplusplus
}
#endif
#endif // LIBPM3_H

8
client/include/pm3.hpp Normal file
View File

@@ -0,0 +1,8 @@
#ifndef LIBPM3PP_H
#define LIBPM3PP_H
#include "pm3.h"
#include "pm3_helper.hpp"
int pm3_console_async_wrapper(pm3 *dev, char *cmd, ConsoleHandler *console_handler);
#endif // LIBPM3PP_H

View File

@@ -0,0 +1,10 @@
#ifndef LIBPM3HELPERPP_H
#define LIBPM3HELPERPP_H
class ConsoleHandler {
public:
virtual int handle_output(char *string) = 0;
virtual ~ConsoleHandler() {}
};
#endif // LIBPM3HELPERPP_H