--- a
+++ b/get_stm8_version.c
@@ -0,0 +1,84 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <signal.h>
+#include <time.h>
+#include <string.h>
+#include <time.h>
+
+#include "rs232.h"
+#include "oggs_app.h"
+
+unsigned char buf[BUFFER_LEN];
+
+void FlushComport()
+{
+	int n;
+	uint32_t startTime = time(NULL);
+	double elapsedTime;
+	
+	do {
+		n = PollComport(COM_PORT,buf,BUFFER_LEN);
+		if(n) startTime = time(NULL);
+		elapsedTime = difftime(time(NULL), startTime);
+	} while((n > 1) || (elapsedTime < 1));
+}
+
+void stm8_reset(int state)
+{
+	if(state)
+		system("cpm -N STM8_RESET -V 1");
+	else 
+		system("cpm -N STM8_RESET -V 0");
+}
+	
+int get_update_info()
+{
+	int n,m;
+	unsigned char b[65];
+	uint32_t startTime = time(NULL);
+	double elapsedTime;
+
+	SendByte(COM_PORT, CMD_GETSTATUS | ARG_GETSTATUS_VERSIONINFO  );
+
+	//read 64 Bytes in 3 s otherwise Timeout
+	m=0;
+	do {
+
+		n = PollComport(COM_PORT,&b[m],1);
+		if(n) m+=n;
+		elapsedTime = difftime(time(NULL), startTime);
+	} while( (m<64) && (elapsedTime < 3) );
+
+	b[64] = 0;
+
+	if( m != 64) return 0; 
+	printf("%s",b);
+	return 1;
+}
+
+
+int main(int argc, char *argv[])
+{
+	int ret;
+	
+	
+
+	if(OpenComport(COM_PORT,BAUD_RATE) != 0)
+	{
+		fprintf(stderr,"Error opening comport!\n");
+		return -1;
+	}
+
+	stm8_reset(1);
+	FlushComport();
+	stm8_reset(0);
+	usleep(WAITTIME_AFTERRESET);
+
+	ret = get_update_info();
+
+	CloseComport(COM_PORT);
+
+	return ret;
+
+}
+