Jump to content

Orange Pi Zero Wiring Serial read to array problem


Hikmet TEKIN

Recommended Posts

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

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

Terms of Use - Privacy Policy - Guidelines