Skip to content
Sara Damiano edited this page Aug 13, 2024 · 2 revisions

Buffer Setup

The buffer is used to store characters from the SDI-12 data line. Characters are read into the buffer when an interrupt is received on the data line. The buffer uses a circular implementation with pointers to both the head and the tail. There is one buffer per instance of the SDI-12 object. This will consume a good deal of RAM, so be prudent in running multiple instances.

For more information on circular buffers: http://en.wikipedia.org/wiki/Circular_buffer

1.1 - Define a maximum buffer size (in number of characters). Increasing the buffer size will use more RAM. If you exceed 256 characters, be sure to change the data type of the index to support the larger range of addresses.

1.2 - Create a character array of the specified size.

1.3 - Index to buffer head. (unsigned 8-bit integer, can map from 0-255)

1.4 - Index to buffer tail. (unsigned 8-bit integer, can map from 0-255)

// See section 0.			// 1.1 - max buffer size
char _rxBuffer[_BUFFER_SIZE]; 	// 1.2 - buff for incoming
uint8_t _rxBufferHead = 0;		// 1.3 - index of buff head
uint8_t _rxBufferTail = 0;		// 1.4 - index of buff tail