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 extern "C"
00021 int setSerialKey()
00022 {
00023         if (strcmp(SERIAL_KEY, "enter serial key here") == 0)
00024         {
00025                 {
00026                         char serialKey[256];
00027                         FILE* fp;
00028                         memset(serialKey, 0, 256);
00029                         fp = fopen("serial.key", "r");
00030                         if (fp)
00031                         {
00032                                 fread(serialKey, 1, 30, fp);
00033                                 fclose(fp);
00034 
00035                                 if (XsControl::setSerialKey(serialKey))
00036                                         return 1;
00037                         }
00038                 }
00039 
00040                 // ask for serial key
00041                 std::cout << "Please enter valid serial key" << std::endl;
00042                 std::cout << "If you built this example yourself you can enter the key in \"serialkey.h\"" << std::endl;
00043                 char serialKey[256];
00044                 std::cin.getline(serialKey, 256);
00045                 XsString serial(serialKey);
00046                 
00047                 if (XsControl::setSerialKey(serial))
00048                 {
00049                         // store it
00050                         FILE* fp = fopen("serial.key", "w");
00051                         fwrite(serial.c_str(), sizeof(char), serial.size(), fp);
00052                         fclose(fp);
00053                         return 1;
00054                 }
00055                 return 0;
00056         }
00057         return XsControl::setSerialKey(SERIAL_KEY);
00058         
00059         return true;
00060 }


receive_xsens
Author(s): Ji Zhang, Silvio Maeta
autogenerated on Sat Jun 8 2019 19:32:50