mirror of
git://soft.sys114.com/WiringPi2-Python
synced 2026-02-09 17:34:22 +09:00
Fixed bindings, typemap for uchar[8]
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
// Generated by generate-bindings.py - do not edit manually!
|
||||||
|
|
||||||
// Header file WiringPi/wiringPi/wiringPi.h
|
// Header file WiringPi/wiringPi/wiringPi.h
|
||||||
extern int wiringPiFailure (int fatal, const char *message, ...) ;
|
extern int wiringPiFailure (int fatal, const char *message, ...) ;
|
||||||
@@ -15,8 +16,6 @@ extern void digitalWrite (int pin, int value) ;
|
|||||||
extern void pwmWrite (int pin, int value) ;
|
extern void pwmWrite (int pin, int value) ;
|
||||||
extern int analogRead (int pin) ;
|
extern int analogRead (int pin) ;
|
||||||
extern void analogWrite (int pin, int value) ;
|
extern void analogWrite (int pin, int value) ;
|
||||||
extern int wiringPiSetupPiFace (void) ;
|
|
||||||
extern int wiringPiSetupPiFaceForGpioProg (void) ; // Don't use this - for gpio program only
|
|
||||||
extern int piBoardRev (void) ;
|
extern int piBoardRev (void) ;
|
||||||
extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ;
|
extern void piBoardId (int *model, int *rev, int *mem, int *maker, int *overVolted) ;
|
||||||
extern int wpiPinToGpio (int wpiPin) ;
|
extern int wpiPinToGpio (int wpiPin) ;
|
||||||
|
|||||||
@@ -40,12 +40,15 @@ HEADERS = [
|
|||||||
"WiringPi/devLib/piNes.h"
|
"WiringPi/devLib/piNes.h"
|
||||||
]
|
]
|
||||||
def is_c_decl(line):
|
def is_c_decl(line):
|
||||||
if "wiringPiISR" in line:
|
for fn in ['wiringPiISR','wiringPiSetupPiFace','wiringPiSetupPiFaceForGpioProg']:
|
||||||
|
if fn in line:
|
||||||
return False
|
return False
|
||||||
for prefix in ['extern','void','int','uint8_t']:
|
for prefix in ['extern','void','int','uint8_t']:
|
||||||
if line.startswith(prefix):
|
if line.startswith(prefix):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
print("// Generated by generate-bindings.py - do not edit manually!")
|
||||||
|
|
||||||
for file in HEADERS:
|
for file in HEADERS:
|
||||||
print("\n// Header file {}".format(file))
|
print("\n// Header file {}".format(file))
|
||||||
h = open(file).read().split('\n')
|
h = open(file).read().split('\n')
|
||||||
|
|||||||
28
wiringpi.i
28
wiringpi.i
@@ -34,7 +34,6 @@
|
|||||||
#include "WiringPi/devLib/lcd128x64.h"
|
#include "WiringPi/devLib/lcd128x64.h"
|
||||||
#include "WiringPi/devLib/lcd.h"
|
#include "WiringPi/devLib/lcd.h"
|
||||||
#include "WiringPi/devLib/maxdetect.h"
|
#include "WiringPi/devLib/maxdetect.h"
|
||||||
#include "WiringPi/devLib/piFace.h"
|
|
||||||
#include "WiringPi/devLib/piGlow.h"
|
#include "WiringPi/devLib/piGlow.h"
|
||||||
#include "WiringPi/devLib/piNes.h"
|
#include "WiringPi/devLib/piNes.h"
|
||||||
%}
|
%}
|
||||||
@@ -238,6 +237,33 @@ static void wiringPiISRWrapper(int pin, int mode, PyObject *PyFunc) {
|
|||||||
%rename("wiringPiISR") wiringPiISRWrapper (int pin, int mode, PyObject *PyFunc);
|
%rename("wiringPiISR") wiringPiISRWrapper (int pin, int mode, PyObject *PyFunc);
|
||||||
static void wiringPiISRWrapper(int pin, int mode, PyObject *PyFunc);
|
static void wiringPiISRWrapper(int pin, int mode, PyObject *PyFunc);
|
||||||
|
|
||||||
|
%typemap(in) unsigned char data [8] {
|
||||||
|
/* Check if is a list */
|
||||||
|
if (PyList_Check($input)) {
|
||||||
|
if(PyList_Size($input) != 8){
|
||||||
|
PyErr_SetString(PyExc_TypeError,"must contain 8 items");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
$1 = (unsigned char *) malloc(8);
|
||||||
|
for (i = 0; i < 8; i++) {
|
||||||
|
PyObject *o = PyList_GetItem($input,i);
|
||||||
|
if (PyInt_Check(o) && PyInt_AsLong(PyList_GetItem($input,i)) <= 255 && PyInt_AsLong(PyList_GetItem($input,i)) >= 0)
|
||||||
|
$1[i] = PyInt_AsLong(PyList_GetItem($input,i));
|
||||||
|
else {
|
||||||
|
PyErr_SetString(PyExc_TypeError,"list must contain integers 0-255");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
PyErr_SetString(PyExc_TypeError,"not a list");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
%typemap(freearg) unsigned char data [8] {
|
||||||
|
free((unsigned char *) $1);
|
||||||
|
}
|
||||||
|
|
||||||
%typemap(in) (unsigned char *data, int len) {
|
%typemap(in) (unsigned char *data, int len) {
|
||||||
$1 = (unsigned char *) PyString_AsString($input);
|
$1 = (unsigned char *) PyString_AsString($input);
|
||||||
|
|||||||
Reference in New Issue
Block a user