Hikmet TEKIN Posted December 12, 2017 Posted December 12, 2017 Hi everybody, I am trying to read a data on OPI Zero with wiring library. Here is my code. #include <string.h> #include <stdio.h> #include <stdlib.h> #include <wiringPi.h> #include <wiringSerial.h> #include <errno.h> char *datas[15]; char comming_buffer[256]; char command_run[256]; char veri00[10] = "serial"; char veri01[10] = "ntrip"; char veri02[10] = " "; char veri10[10] = "serial"; char veri11[10] = "tcpsvr"; char veri12[10] = "ntrips"; int k = 0; int *pk = &k; int datacount = 0; int *p_datacount=&datacount; int i = 0; int count = 0; int *p_count = &count; int data = 0; int *p_data = &data; int word_array = 0; int *p_word_array = &word_array; int main() { wiringPiSetup(); int fd; if ((fd = serialOpen("/dev/ttyS1", 115200)) < 0) { fprintf(stderr, "unable to open serial device:%s\n", strerror(errno)); return 1; } while (1) { char c = serialGetchar(fd); // read char to c comming_buffer[count] = c; // store c to array comming_buffer[count + 1] = '\0'; // count++; // toplam veri sayısı if (comming_buffer[count-1]=='*') { printf("%s", comming_buffer); count = 0; } } return 0; } I cannot read it to array. What can I do? Thanks
Naguissa Posted December 14, 2017 Posted December 14, 2017 What's the error? Port, empty, null pointer, garbage....Enviado desde mi Jolla mediante Tapatalk
Hikmet TEKIN Posted December 14, 2017 Author Posted December 14, 2017 There is no error and There is no data on terminal.
Naguissa Posted December 14, 2017 Posted December 14, 2017 Is SerialGetChar a blocking function? If not the code will overflow.Enviado desde mi Jolla mediante Tapatalk
Recommended Posts