diff --git a/pyserialext/Makefile b/pyserialext/Makefile index e3fc0f3..5099e81 100644 --- a/pyserialext/Makefile +++ b/pyserialext/Makefile @@ -1,7 +1,8 @@ -CFLAGS=-I/opt/bcm2835/include +CFLAGS= +LIBS=-lwiringPi -writec.so: writec.o /opt/bcm2835/lib/libbcm2835.a - $(LD) -shared -o $@ $^ +writec.so: writec.o + $(LD) -shared $(LIBS) -o $@ $^ writec.o: writec.c diff --git a/pyserialext/writec.c b/pyserialext/writec.c index 93f16aa..d51cf7c 100644 --- a/pyserialext/writec.c +++ b/pyserialext/writec.c @@ -6,25 +6,25 @@ #include #include #include -#include +#include -const uint8_t DE_PIN = RPI_V2_GPIO_P1_11; +const uint8_t DE_PIN = 0; int set_rs485_mode(int fd) { - bcm2835_init(); - bcm2835_gpio_fsel(DE_PIN, BCM2835_GPIO_FSEL_OUTP); - bcm2835_gpio_write(DE_PIN, LOW); + wiringPiSetup(); + pinMode(DE_PIN, OUTPUT); + digitalWrite(DE_PIN, HIGH); } ssize_t writec(int fd, char *buf, size_t count) { - bcm2835_gpio_write(DE_PIN, LOW); + digitalWrite(DE_PIN, LOW); ssize_t r = write(fd, buf, count); uint8_t lsr; do { int r = ioctl(fd, TIOCSERGETLSR, &lsr); } while (!(lsr & TIOCSER_TEMT)); - bcm2835_gpio_write(DE_PIN, HIGH); + digitalWrite(DE_PIN, HIGH); return r; } diff --git a/pyserialext/writec.o b/pyserialext/writec.o index 133af69..ae0e3e1 100644 Binary files a/pyserialext/writec.o and b/pyserialext/writec.o differ diff --git a/pyserialext/writec.so b/pyserialext/writec.so index 9fb8f85..70a0f0c 100755 Binary files a/pyserialext/writec.so and b/pyserialext/writec.so differ