map = mmap(comedi_stuff) int buffer_size = size_of_comedi_buffer(); int front = 0; int back = 0; int num_channels = number_of_channels; int max_samples; //max number of samples we can ship over earthworm while(true) { front+=comedi_get_buffer_contents(); while(front==back) { sleep; front+=comedi_get_buffer_contents(); } endtime = gettimeofday(); num_samples = (front-back)/(num_channels*sizeof(sample)); begintime = calc_begin_time(endtime, num_samples); int t_chan=0; //lets us know where to put the data for(i=back;i