view data-provider.c @ 227:a2f99632a80c

Implement N estimate tacking into account measured beatnote frequency
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Fri, 19 Sep 2014 19:04:47 +0200
parents 97112b45b838
children ec81395bf08d
line wrap: on
line source

#include <ansi_c.h>
#include <userint.h>

#include "logging.h"

/* message buffer */
#define DATA_PROVIDER_MSGLEN 256
#define DATA_PROVIDER_MSGNUM 16
static char messages[DATA_PROVIDER_MSGLEN][DATA_PROVIDER_MSGNUM];
static unsigned int messageid = 0;


/* message callback */
void CVICALLBACK MessageCB (void *msg)
{
	if (msg != NULL)
		logmessage(INFO, msg);
}


void SendMessage(int threadId, const char *frmt, ...)
{
	/* message buffer */
	char *message = messages[messageid++ % DATA_PROVIDER_MSGNUM];
	
	/* format message */
	va_list args;
	va_start(args, frmt);
	vsnprintf(message, DATA_PROVIDER_MSGLEN - 1, frmt, args);
	va_end(args);
	
	/* signal main thread */
	PostDeferredCallToThread(MessageCB, message, threadId);
}