A PCRE internal error occured. This might be caused by a faulty plugin

===== Makefile ===== include $(TOPDIR)/rules.mk PKG_NAME:=weather PKG_RELEASE:=1 PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME) include $(INCLUDE_DIR)/package.mk define Package/weather SECTION:=utils CATEGORY:=Utilities TITLE:=sparkfun weather station endef define Package/weather/description Simple program to get serial port data endef define Build/Prepare mkdir -p $(PKG_BUILD_DIR) $(CP) ./src/* $(PKG_BUILD_DIR)/ endef define Package/weather/install $(INSTALL_DIR) $(1)/usr/sbin $(INSTALL_BIN) $(PKG_BUILD_DIR)/weather $(1)/usr/sbin/weather endef $(eval $(call BuildPackage,weather)) ===== src/Makefile ===== OBJ = main.o all: compile %.o: %.c $(CC) $(CFLAGS) -c -o $@ $< compile: $(OBJ) $(CC) -o weather $(LDFLAGS) $(OBJ) clean: rm -f *.o *.so weather ===== src/main.c ===== #include <stdio.h> #include <string.h> #include <unistd.h> #include <fcntl.h> #include <errno.h> #include <termios.h> #include <stdlib.h> int open_port(void) { int fd; fd = open("/dev/ttyUSB0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { perror("open_port: Unable to open /dev/ttyS0 - "); } else fcntl(fd, F_SETFL, 0); struct termios options; tcgetattr(fd, &options); cfsetispeed(&options, B9600); cfsetospeed(&options, B9600); tcsetattr(fd, TCSANOW, &options); return (fd); } main() { unsigned int fd; unsigned int cnt = 0; char buffer[300]; char *bufptr; unsigned int ptr = 0; unsigned int i; bufptr = buffer; fd = open_port(); while(ptr<200) { cnt = read(fd, bufptr + ptr, 50); ptr += cnt; buffer[ptr] = 0; } char *start=NULL, *end=NULL; start = strstr(buffer, "\n"); char *t1_p=NULL, *hum_p=NULL, *pres_p=NULL; double t1=0, hum=0, pres=0; t1_p = strstr(start, "t2:") + 3; hum_p = strstr(start, "hum:") + 4; pres_p = strstr(start, "pres:") + 5; if(t1_p!=NULL) t1 = atof(t1_p); if(hum_p!=NULL) hum = atof(hum_p); if(pres_p!=NULL) pres = atof(pres_p); printf("{\n"); printf(" \"version\":\"1.0.0\",\n"); printf(" \"datastreams\":[\n"); printf(" {\"id\":\"0\", \"current_value\":\"%3.2f\"},\n", t1); printf(" {\"id\":\"1\", \"current_value\":\"%3.2f\"},\n", hum); printf(" {\"id\":\"2\", \"current_value\":\"%6.1f\"}\n", pres); printf(" ]\n"); printf("}\n"); }

Recent changes RSS feed Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki