|
@@ -0,0 +1,96 @@
|
|
|
+#include <QCoreApplication>
|
|
|
+
|
|
|
+#include "ivservice.h"
|
|
|
+#include "ivversion.h"
|
|
|
+#include "xmlparam.h"
|
|
|
+
|
|
|
+#include <QFile>
|
|
|
+
|
|
|
+static std::string gstrVIN;
|
|
|
+static std::string gstrVehicleType;
|
|
|
+static std::string gstrVersion;
|
|
|
+
|
|
|
+void ProcVINReq(std::shared_ptr<char> pstr_req,const int nreqsize,std::shared_ptr<char> & pstr_res,int & nressize)
|
|
|
+{
|
|
|
+ (void)pstr_req;
|
|
|
+ (void)nreqsize;
|
|
|
+ nressize = gstrVIN.size() +1;
|
|
|
+ pstr_res = std::shared_ptr<char>(new char[nressize]);
|
|
|
+ *(pstr_res.get() + nressize) = 0;
|
|
|
+ memcpy(pstr_res.get(),gstrVIN.data(),gstrVIN.size());
|
|
|
+}
|
|
|
+
|
|
|
+void ProcVehicleTypeReq(std::shared_ptr<char> pstr_req,const int nreqsize,std::shared_ptr<char> & pstr_res,int & nressize)
|
|
|
+{
|
|
|
+ (void)pstr_req;
|
|
|
+ (void)nreqsize;
|
|
|
+ nressize = gstrVehicleType.size() +1;
|
|
|
+ pstr_res = std::shared_ptr<char>(new char[nressize]);
|
|
|
+ *(pstr_res.get() + nressize) = 0;
|
|
|
+ memcpy(pstr_res.get(),gstrVehicleType.data(),gstrVehicleType.size());
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void ProcVersionReq(std::shared_ptr<char> pstr_req,const int nreqsize,std::shared_ptr<char> & pstr_res,int & nressize)
|
|
|
+{
|
|
|
+ (void)pstr_req;
|
|
|
+ (void)nreqsize;
|
|
|
+ nressize = gstrVersion.size() +1;
|
|
|
+ pstr_res = std::shared_ptr<char>(new char[nressize]);
|
|
|
+ *(pstr_res.get() + nressize) = 0;
|
|
|
+ memcpy(pstr_res.get(),gstrVersion.data(),gstrVersion.size());
|
|
|
+}
|
|
|
+
|
|
|
+std::string GetVersion()
|
|
|
+{
|
|
|
+ std::string strversion;
|
|
|
+ QFile xFile;
|
|
|
+ xFile.setFileName("version");
|
|
|
+ if(xFile.open(QIODevice::ReadOnly))
|
|
|
+ {
|
|
|
+ QByteArray ba = xFile.readAll();
|
|
|
+ strversion = ba.toStdString();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ strversion = IVVERSION;
|
|
|
+ }
|
|
|
+ return strversion;
|
|
|
+}
|
|
|
+
|
|
|
+std::string GetVIN()
|
|
|
+{
|
|
|
+ std::string strVIN;
|
|
|
+ iv::xmlparam::Xmlparam xp("vin.xml");
|
|
|
+ strVIN = xp.GetParam("VIN","Unknown");
|
|
|
+ return strVIN;
|
|
|
+}
|
|
|
+
|
|
|
+std::string GetVehicleType()
|
|
|
+{
|
|
|
+ std::string strVehicleType = "Unknown";
|
|
|
+ iv::xmlparam::Xmlparam xp("vin.xml");
|
|
|
+ strVehicleType = xp.GetParam("VehicleType","Unknown");
|
|
|
+ return strVehicleType;
|
|
|
+}
|
|
|
+
|
|
|
+int main(int argc, char *argv[])
|
|
|
+{
|
|
|
+ showversion("driver_service_vehicleinfo");
|
|
|
+ QCoreApplication a(argc, argv);
|
|
|
+
|
|
|
+ gstrVersion = GetVersion();
|
|
|
+ gstrVIN = GetVIN();
|
|
|
+ gstrVehicleType = GetVehicleType();
|
|
|
+
|
|
|
+ iv::service::Server serviceVersion("Version",ProcVersionReq);
|
|
|
+ (void)serviceVersion;
|
|
|
+
|
|
|
+ iv::service::Server serviceVIN("VIN",ProcVINReq);
|
|
|
+ (void)serviceVIN;
|
|
|
+
|
|
|
+ iv::service::Server serviceVehicleType("VehicleType",ProcVehicleTypeReq);
|
|
|
+ (void)serviceVehicleType;
|
|
|
+
|
|
|
+ return a.exec();
|
|
|
+}
|