|
@@ -80,7 +80,7 @@ void substr(char *dest, const char* src, unsigned int start, unsigned int cnt);
|
|
|
|
|
|
char *portName[3] = {"/dev/ttyUSB2", "/dev/ttyUSB2", "/dev/ttyACM2"};
|
|
|
char *valid_Internet[2] = {"8.8.8.8", "180.76.76.76"};
|
|
|
-char *Version_And_Date[2] = {"V0.07","2020-11-26"};
|
|
|
+char *Version_And_Date[2] = {"V0.08","2021-02-23"};
|
|
|
pid_t pid;
|
|
|
|
|
|
struct dongle_info
|
|
@@ -157,16 +157,12 @@ int InitShareMemory()
|
|
|
//creat ShmSysConfigAndInfo
|
|
|
if ((MeterSMId = shmget(ShmSysConfigAndInfoKey, sizeof(struct SysConfigAndInfo), 0777)) < 0)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmget ShmSysConfigAndInfo NG\n");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else if ((ShmSysConfigAndInfo = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmat ShmSysConfigAndInfo NG\n");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else
|
|
@@ -175,16 +171,12 @@ int InitShareMemory()
|
|
|
//creat ShmStatusCodeData
|
|
|
if ((MeterSMId = shmget(ShmStatusCodeKey, sizeof(struct StatusCodeData), 0777)) < 0)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmget ShmStatusCodeData NG\n");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else if ((ShmStatusCodeData = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmat ShmStatusCodeData NG\n");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else
|
|
@@ -193,16 +185,12 @@ int InitShareMemory()
|
|
|
//creat ShmOCPP16Data
|
|
|
if ((MeterSMId = shmget(ShmOcppModuleKey, sizeof(struct OCPP16Data), 0777)) < 0)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmget ShmOCPP16Data NG");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else if ((ShmOCPP16Data = shmat(MeterSMId, NULL, 0)) == (void *) -1)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("shmat ShmOCPP16Data NG");
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
else
|
|
@@ -239,21 +227,15 @@ int Check4GModem(void)
|
|
|
|
|
|
if(result == DONGLE_QUECTEL)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_WARN("Quectel 4G modem be found\n");
|
|
|
- #endif
|
|
|
}
|
|
|
else if(result == DONGLE_UBLOX)
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_WARN("Ublox 4G modem be found\n");
|
|
|
- #endif
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_WARN("No 4G modem be found\n");
|
|
|
- #endif
|
|
|
}
|
|
|
|
|
|
return result;
|
|
@@ -343,7 +325,7 @@ int isReadInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 5, strlen(tmp)-5);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.MANUFACTURER, 0x00, ARRAY_SIZE(Dongle.MANUFACTURER));
|
|
|
strncpy(Dongle.MANUFACTURER, tmp, strlen(tmp));
|
|
|
}
|
|
|
else
|
|
@@ -364,7 +346,7 @@ int isReadInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 5, strlen(tmp)-5);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.MODELNAME, 0x00, ARRAY_SIZE(Dongle.MODELNAME));
|
|
|
strncpy(Dongle.MODELNAME, tmp, strlen(tmp));
|
|
|
}
|
|
|
else
|
|
@@ -385,7 +367,7 @@ int isReadInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 5, strlen(tmp)-5);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.REVISION, 0x00, ARRAY_SIZE(Dongle.REVISION));
|
|
|
strncpy(Dongle.REVISION, tmp, strlen(tmp));
|
|
|
}
|
|
|
else
|
|
@@ -406,7 +388,7 @@ int isReadInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 5, strlen(tmp)-5);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.IMEI, 0x00, ARRAY_SIZE(Dongle.IMEI));
|
|
|
strncpy(Dongle.IMEI, tmp, strlen(tmp));
|
|
|
}
|
|
|
else
|
|
@@ -485,6 +467,7 @@ int isReadInfo(void)
|
|
|
memset(tmp, 0, sizeof tmp);
|
|
|
memcpy(tmp, rx, strcspn(rx,"OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
+ memset(Dongle.MANUFACTURER, 0x00, ARRAY_SIZE(Dongle.MANUFACTURER));
|
|
|
strncpy(Dongle.MANUFACTURER, tmp+2, 6);
|
|
|
}
|
|
|
else
|
|
@@ -499,6 +482,7 @@ int isReadInfo(void)
|
|
|
memset(tmp, 0, sizeof tmp);
|
|
|
memcpy(tmp, rx, strcspn(rx,"OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
+ memset(Dongle.MODELNAME, 0x00, ARRAY_SIZE(Dongle.MODELNAME));
|
|
|
strncpy(Dongle.MODELNAME , tmp+2, 9);
|
|
|
}
|
|
|
else
|
|
@@ -513,6 +497,7 @@ int isReadInfo(void)
|
|
|
memset(tmp, 0, sizeof tmp);
|
|
|
memcpy(tmp, rx, strcspn(rx, "OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
+ memset(Dongle.REVISION, 0x00, ARRAY_SIZE(Dongle.REVISION));
|
|
|
strncpy(Dongle.REVISION, tmp+2, 5);
|
|
|
}
|
|
|
else
|
|
@@ -528,6 +513,7 @@ int isReadInfo(void)
|
|
|
memcpy(tmp, rx, strcspn(rx, "OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
trim_s(tmp,Length);
|
|
|
+ memset(Dongle.IMEI, 0x00, ARRAY_SIZE(Dongle.IMEI));
|
|
|
strncpy(Dongle.IMEI, tmp, strlen(tmp));
|
|
|
}
|
|
|
else
|
|
@@ -618,7 +604,7 @@ int isReadSimInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 6, strlen(tmp)-6);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.IMSI, 0x00, ARRAY_SIZE(Dongle.IMSI));
|
|
|
strncpy(Dongle.IMSI, tmp, strlen(tmp));
|
|
|
}
|
|
|
}
|
|
@@ -641,6 +627,7 @@ int isReadSimInfo(void)
|
|
|
{
|
|
|
memcpy(tmp, rx, strcspn(rx, "OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
+ memset(Dongle.ICCID, 0x00, ARRAY_SIZE(Dongle.ICCID));
|
|
|
strncpy(Dongle.ICCID, tmp + strcspn(tmp, ":") + 2, 20);
|
|
|
}
|
|
|
}
|
|
@@ -687,7 +674,7 @@ int isReadSimInfo(void)
|
|
|
{
|
|
|
substr(tmp, tmp, 6, strlen(tmp)-6);
|
|
|
}
|
|
|
-
|
|
|
+ memset(Dongle.IMSI, 0x00, ARRAY_SIZE(Dongle.IMSI));
|
|
|
strncpy(Dongle.IMSI, tmp, strlen(tmp));
|
|
|
}
|
|
|
}
|
|
@@ -710,6 +697,7 @@ int isReadSimInfo(void)
|
|
|
{
|
|
|
memcpy(tmp, rx, strcspn(rx, "OK"));
|
|
|
memset(rx, 0, sizeof rx);
|
|
|
+ memset(Dongle.ICCID, 0x00, ARRAY_SIZE(Dongle.ICCID));
|
|
|
strncpy(Dongle.ICCID, tmp + strcspn(tmp, ":") + 2, 20);
|
|
|
}
|
|
|
}
|
|
@@ -721,9 +709,7 @@ int isReadSimInfo(void)
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- #ifdef SystemLogMessage
|
|
|
DEBUG_ERROR("%s open fail.\n", portName[Dongle.Model]);
|
|
|
- #endif
|
|
|
result = FAIL;
|
|
|
}
|
|
|
|
|
@@ -1198,10 +1184,22 @@ int main(void)
|
|
|
Dongle.cnt_SearchModuleFail = 0;
|
|
|
if(isReadInfo() == PASS)
|
|
|
{
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName, Dongle.MODELNAME) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName));
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModelName, Dongle.MODELNAME, sizeof Dongle.MODELNAME);
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer, Dongle.REVISION) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer));
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSoftwareVer, Dongle.REVISION, sizeof Dongle.REVISION);
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, Dongle.REVISION) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev));
|
|
|
memcpy(ShmSysConfigAndInfo->SysInfo.TelcomModemFwRev, Dongle.REVISION, sizeof Dongle.REVISION);
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei, Dongle.IMEI) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei));
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemImei, Dongle.IMEI, sizeof Dongle.IMEI);
|
|
|
+
|
|
|
ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomRssi = Dongle.CSQ;
|
|
|
ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomModemMode = Dongle.MODE;
|
|
|
|
|
@@ -1220,7 +1218,13 @@ int main(void)
|
|
|
if(isReadSimInfo() == PASS)
|
|
|
{
|
|
|
ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimStatus = 1;
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid, Dongle.ICCID) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid));
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimIccid, Dongle.ICCID, sizeof Dongle.ICCID);
|
|
|
+
|
|
|
+ if(strcmp((char*)ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi, Dongle.IMSI) != 0)
|
|
|
+ memset(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi, 0x00, ARRAY_SIZE(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi));
|
|
|
memcpy(ShmSysConfigAndInfo->SysConfig.TelecomInterface.TelcomSimImsi, Dongle.IMSI, sizeof Dongle.IMSI);
|
|
|
|
|
|
DEBUG_INFO("========================================\n");
|