我正在 RaspberryPi 上制作一个程序( C语言)
我的程序通过串行通信<
源代码:
super(A, self).__init__(idn, name)
在我提出之前
#ifdef RaspberryPi
//include system librarys
#include <stdio.h> //for printf
#include <stdint.h> //uint8_t definitions
#include <stdlib.h> //for exit(int);
#include <string.h> //for errno
#include <errno.h> //error output
//wiring Pi
#include <wiringPi.h>
#include <wiringSerial.h>
char device[]= "/dev/ttyACM0";
// filedescriptor
int fd;
unsigned long baud = 9600;
unsigned long time=0;
//prototypes
void loop(void);
void setup(void);
void setup(){
printf("%s \n", "Raspberry Startup!");
fflush(stdout);
//get filedescriptor
if ((fd = serialOpen (device, baud)) < 0){
fprintf (stderr, "Unable to open serial device: %s\n", strerror (errno)) ;
exit(1); //error
}
//setup GPIO in wiringPi mode
if (wiringPiSetup () == -1){
fprintf (stdout, "Unable to start wiringPi: %s\n", strerror (errno)) ;
exit(1); //error
}
}
void loop(){
// Pong every 3 seconds
if(millis()-time>=3000){
serialPuts (fd, "Received\n");
time=millis();
}
// read signal
if(serialDataAvail (fd)){
char newChar = serialGetchar (fd);
printf("%c", newChar);
if((int)newChar >= 1){
system("raspistill -o image.jpg");
system("convert image.jpg -threshold 20% imagebw.jpg");
system("tesseract imagebw.jpg imageocr");
system("cat imageocr.txt");
}
fflush(stdout);
}
}
int main(void){
setup();
while(1) loop();
return 0;
}
#endif //#ifdef RaspberryPi
这段代码,它运作良好
但是,即使我删除它也不起作用
我在编译器上发现了以下错误( GCC )
system("convert image.jpg -threshold 20% imagebw.jpg");
system("tesseract imagebw.jpg imageocr");
system("cat imageocr.txt");
我使用了以下两个命令
/usr/lib/gcc/arm-linux-gneabihf/4.9/../../../arm-linux-gnueabihf/ort1.o:In function '_start':/build/glibc-mqlSLF/glibc-2.19/csu/../ports/sysdeps/arm/start.S:119 : undefined reference to 'main'
collect2: error: ld returned 1 exit sutatus
有人可以帮我解决这个问题吗?