2020-05-28 08:13:21 +08:00
|
|
|
%module pm3
|
|
|
|
%{
|
|
|
|
/* Include the header in the wrapper code */
|
|
|
|
#include "pm3.h"
|
|
|
|
#include "comms.h"
|
|
|
|
%}
|
|
|
|
|
|
|
|
/* Strip "pm3_" from API functions for SWIG */
|
|
|
|
%rename("%(strip:[pm3_])s") "";
|
|
|
|
%feature("immutable","1") pm3_current_dev;
|
|
|
|
typedef struct {
|
|
|
|
%extend {
|
|
|
|
pm3() {
|
2020-11-11 07:03:58 +08:00
|
|
|
// printf("SWIG pm3 constructor, get current pm3\n");
|
2021-08-22 03:41:52 +08:00
|
|
|
pm3_device_t * p = pm3_get_current_dev();
|
2020-05-28 08:13:21 +08:00
|
|
|
p->script_embedded = 1;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
pm3(char *port) {
|
2020-11-11 07:03:58 +08:00
|
|
|
// printf("SWIG pm3 constructor with port, open pm3\n");
|
2021-08-22 03:41:52 +08:00
|
|
|
pm3_device_t * p = pm3_open(port);
|
2020-05-28 08:13:21 +08:00
|
|
|
p->script_embedded = 0;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
~pm3() {
|
|
|
|
if ($self->script_embedded) {
|
2020-11-11 07:03:58 +08:00
|
|
|
// printf("SWIG pm3 destructor, nothing to do\n");
|
2020-05-28 08:13:21 +08:00
|
|
|
} else {
|
2020-11-11 07:03:58 +08:00
|
|
|
// printf("SWIG pm3 destructor, close pm3\n");
|
2020-05-28 08:13:21 +08:00
|
|
|
pm3_close($self);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
int console(char *cmd);
|
|
|
|
char const * const name;
|
|
|
|
}
|
|
|
|
} pm3;
|
|
|
|
//%nodefaultctor device;
|
|
|
|
//%nodefaultdtor device;
|
|
|
|
/* Parse the header file to generate wrappers */
|