Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Orange Pi Zero Wiring Serial read to array problem

Featured Replies

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

What's the error? Port, empty, null pointer, garbage....

Enviado desde mi Jolla mediante Tapatalk

Is SerialGetChar a blocking function? If not the code will overflow.

Enviado desde mi Jolla mediante Tapatalk

Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.