@@ -30,12 +30,19 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3030SOFTWARE.
3131*/
3232
33- #include "Python.h"
33+ #ifndef NO_PYTHON
34+ # include "Python.h"
35+ #endif // !NO_PYTHON
36+
3437#include <dirent.h>
38+ #include <errno.h>
39+ #include <glob.h>
40+ #include <stdio.h>
41+ #include <stdlib.h>
42+ #include <string.h>
3543#include <syslog.h>
3644#include <time.h>
37- #include <string.h>
38- #include <glob.h>
45+
3946#include "common.h"
4047
4148#include <linux/version.h>
@@ -165,7 +172,7 @@ pins_t table[] = {
165172 { "DGND" , "P9_44" , 0 , -1 , -1 },
166173 { "DGND" , "P9_45" , 0 , -1 , -1 },
167174 { "DGND" , "P9_46" , 0 , -1 , -1 },
168- { NULL , NULL , 0 }
175+ { NULL , NULL , 0 , 0 , 0 }
169176};
170177
171178typedef struct uart_t {
@@ -182,7 +189,7 @@ uart_t uart_table[] = {
182189 { "UART3" , "/dev/ttyO3" , "ADAFRUIT-UART3" , "P9_42" , "" },
183190 { "UART4" , "/dev/ttyO4" , "ADAFRUIT-UART4" , "P9_11" , "P9_13" },
184191 { "UART5" , "/dev/ttyO5" , "ADAFRUIT-UART5" , "P8_38" , "P8_37" },
185- { NULL , NULL , 0 }
192+ { NULL , NULL , 0 , 0 , 0 }
186193};
187194
188195// Copied from https://github.com/jadonk/bonescript/blob/master/src/bone.js
@@ -453,7 +460,9 @@ BBIO_err load_device_tree(const char *name)
453460
454461 file = fopen (slots , "r+" );
455462 if (!file ) {
463+ #ifndef NO_PYTHON
456464 PyErr_SetFromErrnoWithFilename (PyExc_IOError , slots );
465+ #endif // !NO_PYTHON
457466 return BBIO_CAPE ;
458467 }
459468
@@ -494,7 +503,9 @@ int device_tree_loaded(const char *name)
494503
495504 file = fopen (slots , "r+" );
496505 if (!file ) {
506+ #ifndef NO_PYTHON
497507 PyErr_SetFromErrnoWithFilename (PyExc_IOError , slots );
508+ #endif // !NO_PYTHON
498509 return -1 ;
499510 }
500511
@@ -528,7 +539,9 @@ BBIO_err unload_device_tree(const char *name)
528539 snprintf (slots , sizeof (slots ), "%s/slots" , ctrl_dir );
529540 file = fopen (slots , "r+" );
530541 if (!file ) {
542+ #ifndef NO_PYTHON
531543 PyErr_SetFromErrnoWithFilename (PyExc_IOError , slots );
544+ #endif // !NO_PYTHON
532545 return BBIO_SYSFS ;
533546 }
534547
0 commit comments