serialkey.cpp
Go to the documentation of this file.
00001 /* Copyright (c) Xsens Technologies B.V., 2006-2012. All rights reserved.
00002  
00003       This source code is provided under the MT SDK Software License Agreement 
00004 and is intended for use only by Xsens Technologies BV and
00005        those that have explicit written permission to use it from
00006        Xsens Technologies BV.
00007  
00008       THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
00009        KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
00010        IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
00011        PARTICULAR PURPOSE.
00012  */
00013 
00014 #include "serialkey.h"
00015 #include <xsens/xsstring.h>
00016 #include <xsens/xscontrol.h>
00017 #include <stdio.h>
00018 #include <iostream>
00019 
00020 #define SERIAL_KEY_SIZE 30
00021 
00022 extern "C"
00023 int setSerialKey()
00024 {
00025         if (strcmp(SERIAL_KEY, "enter serial key here") == 0)
00026         {
00027                 {
00028                         char serialKey[256];
00029                         FILE* fp;
00030                         memset(serialKey, 0, 256);
00031                         fp = fopen("serial.key", "r");
00032                         if (fp)
00033                         {
00034                                 size_t result = fread(serialKey, 1, SERIAL_KEY_SIZE, fp);
00035                                 fclose(fp);
00036 
00037                                 if (result == SERIAL_KEY_SIZE)
00038                                 {           
00039                     if (XsControl::setSerialKey(serialKey))
00040                         return 1;
00041                 }
00042                         }
00043                 }
00044 
00045                 // ask for serial key
00046                 std::cout << "Please enter valid serial key" << std::endl;
00047                 std::cout << "If you built this example yourself you can enter the key in \"serialkey.h\"" << std::endl;
00048                 char serialKey[256];
00049                 std::cin.getline(serialKey, 256);
00050                 XsString serial(serialKey);
00051                 
00052                 if (XsControl::setSerialKey(serial))
00053                 {
00054                         // store it
00055                         FILE* fp = fopen("serial.key", "w");
00056                         fwrite(serial.c_str(), sizeof(char), serial.size(), fp);
00057                         fclose(fp);
00058                         return 1;
00059                 }
00060                 return 0;
00061         }
00062         return XsControl::setSerialKey(SERIAL_KEY);
00063 }
00064 


receive_xsens
Author(s): Ji Zhang, Silvio Maeta
autogenerated on Mon Oct 6 2014 04:05:40