[UnboundedBuffer: readFill] Requested data been pushed out of buffer

Hi

I am capturing the stream of data from the brainbit EEG headband in C code and from there sending it over TCP to python for processing.

After the EEG device have been streaming for a while, I get the following error and only receive 0's:

[UnboundedBuffer: readFill] Requested data been pushed out of buffer

It ruins the entire experiment and I can't figure out how to solve it. I'm not even sure about where the error is coming from, since I can't find the error when searching it in the entire solution (I use visual studio 2019) and I haven't found it online either. Maybe its a headband issue?

This is a snippet of my code from after connecting to headband and socket, where it reads headband EEG and pass it to socket in a while loop:

// Read Data
	advance = false;
	while (!advance)
	{
		size_t t3Length = 0;
		size_t t4Length = 0;
		size_t o1Length = 0;
		size_t o2Length = 0;

		do
		{
			AnyChannel_get_total_length((AnyChannel*)T3Signal, &t3Length);
			AnyChannel_get_total_length((AnyChannel*)T4Signal, &t4Length);
			AnyChannel_get_total_length((AnyChannel*)O1Signal, &o1Length);
			AnyChannel_get_total_length((AnyChannel*)O2Signal, &o2Length);
		} while (t3Length < SIGNAL_SAMPLES_COUNT
			|| t4Length < SIGNAL_SAMPLES_COUNT
			|| o1Length < SIGNAL_SAMPLES_COUNT
			|| o2Length < SIGNAL_SAMPLES_COUNT);

		DoubleChannel_read_data((DoubleChannel*)T3Signal, 0, SIGNAL_SAMPLES_COUNT, t3SignalBuffer, SIGNAL_SAMPLES_COUNT, &t3Length);
		DoubleChannel_read_data((DoubleChannel*)T4Signal, 0, SIGNAL_SAMPLES_COUNT, t4SignalBuffer, SIGNAL_SAMPLES_COUNT, &t4Length);
		DoubleChannel_read_data((DoubleChannel*)O1Signal, 0, SIGNAL_SAMPLES_COUNT, o1SignalBuffer, SIGNAL_SAMPLES_COUNT, &o1Length);
		DoubleChannel_read_data((DoubleChannel*)O2Signal, 0, SIGNAL_SAMPLES_COUNT, o2SignalBuffer, SIGNAL_SAMPLES_COUNT, &o2Length);
		
		// Print signal
		printf("%d signal samples are received.\n", SIGNAL_SAMPLES_COUNT);
		printf("     T3:\t     T4:\t     O1:\t     O2:\n");
		
		for (size_t i = 0; i < SIGNAL_SAMPLES_COUNT; ++i)
		{
			sprintf(buf, "%fuV\t%fuV\t%fuV\t%fuV\t\n",
				t3SignalBuffer[i] * 1e6,
				t4SignalBuffer[i] * 1e6,
				o1SignalBuffer[i] * 1e6,
				o2SignalBuffer[i] * 1e6);

			// Send to Python if Streaming or write to .txt file
			if (streamOrStore == 'p') {
				if (send_buffer(buf) > 0)
					printf("Stream error");
			}
			else if (streamOrStore == 't') {
				fprintf(fp, buf);
			}
		}
		if (GetAsyncKeyState(VK_ESCAPE)) {
			printf("Stream stopped");
			advance = true;
		}
	}

/Jabdi

Assignee Loading
Time tracking Loading