|
@@ -3609,67 +3609,82 @@ namespace MOKA_Factory_Tools
|
|
|
MessageBox.Show(LResource.DeviceCodeFormatError + "\r\n" + devicecode);
|
|
|
goto end;
|
|
|
}
|
|
|
- if (CommonMethod.GetFireTVDsn(orderNow, Encoding.ASCII.GetString(data), SN, out string dsn, errorDBNow))
|
|
|
+
|
|
|
+ // 先读取psn的值;
|
|
|
+ byte[] result_psn;
|
|
|
+ byte[] data_psn;
|
|
|
+ string error_psn;
|
|
|
+ if (SerialCMD.ReadFireTVPSN(TVPort, out result_psn, out data_psn, out error_psn, SerailDelay))
|
|
|
{
|
|
|
- keyInfo.DSN = dsn;
|
|
|
- if (!CommonMethod.IsNumberAndWord(keyInfo.DSN))
|
|
|
- {
|
|
|
- Log.WriteErrorLog("DSN format error!\r\n" + keyInfo.DSN);
|
|
|
- MessageBox.Show(LResource.DSNFormatError + "\r\n" + keyInfo.DSN);
|
|
|
- goto end;
|
|
|
- }
|
|
|
- byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN);
|
|
|
- Log.WriteInfoLog("Write DSN...");
|
|
|
- if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
|
|
|
+ string psn = Encoding.ASCII.GetString(data_psn);
|
|
|
+ if (CommonMethod.GetFireTVDsn(orderNow, Encoding.ASCII.GetString(data), SN, psn, out string dsn, errorDBNow))
|
|
|
{
|
|
|
- SetsuccessStatus(m_writeDSN);
|
|
|
- Log.WriteInfoLog("Check DSN...");
|
|
|
- if (writeCheckNow.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
|
|
|
+ keyInfo.DSN = dsn;
|
|
|
+ if (!CommonMethod.IsNumberAndWord(keyInfo.DSN))
|
|
|
{
|
|
|
- SetsuccessStatus(m_checkDSN);
|
|
|
- Log.WriteInfoLog("Read DSN...");
|
|
|
- if (readCheckNow.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
|
|
|
+ Log.WriteErrorLog("DSN format error!\r\n" + keyInfo.DSN);
|
|
|
+ MessageBox.Show(LResource.DSNFormatError + "\r\n" + keyInfo.DSN);
|
|
|
+ goto end;
|
|
|
+ }
|
|
|
+ byte[] DSNData = System.Text.Encoding.ASCII.GetBytes(keyInfo.DSN);
|
|
|
+ Log.WriteInfoLog("Write DSN...");
|
|
|
+ if (SerialCMD.SetFireTVDSN(TVPort, DSNData, out result, out data, out error, SerailDelay))
|
|
|
+ {
|
|
|
+ SetsuccessStatus(m_writeDSN);
|
|
|
+ Log.WriteInfoLog("Check DSN...");
|
|
|
+ if (writeCheckNow.DSNCheckcheck ? SerialCMD.CheckFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
|
|
|
{
|
|
|
- if (SerialInit.BytesCompare_Base64(data, DSNData))
|
|
|
+ SetsuccessStatus(m_checkDSN);
|
|
|
+ Log.WriteInfoLog("Read DSN...");
|
|
|
+ if (readCheckNow.DSNReadcheck ? SerialCMD.GetFireTVDSN(TVPort, out result, out data, out error, SerailDelay) : true)
|
|
|
{
|
|
|
- SetsuccessStatus(m_readDSN);
|
|
|
- //DSN读取别对成功
|
|
|
+ if (SerialInit.BytesCompare_Base64(data, DSNData))
|
|
|
+ {
|
|
|
+ SetsuccessStatus(m_readDSN);
|
|
|
+ //DSN读取别对成功
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.WriteErrorLog(SN + " contrast DSN fail");
|
|
|
+ MessageBox.Show(LResource.ContrastDSNError);
|
|
|
+ goto end;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Log.WriteErrorLog(SN + " contrast DSN fail");
|
|
|
- MessageBox.Show(LResource.ContrastDSNError);
|
|
|
+ SetfailStatus(m_readDSN);
|
|
|
+ Log.WriteErrorLog(SN + " read DSN fail");
|
|
|
+ MessageBox.Show(LResource.ReadDSNError);
|
|
|
goto end;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SetfailStatus(m_readDSN);
|
|
|
- Log.WriteErrorLog(SN + " read DSN fail");
|
|
|
- MessageBox.Show(LResource.ReadDSNError);
|
|
|
+ SetfailStatus(m_checkDSN);
|
|
|
+ Log.WriteErrorLog(SN + " check DSN fail");
|
|
|
+ MessageBox.Show(LResource.CheckDSNError);
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SetfailStatus(m_checkDSN);
|
|
|
- Log.WriteErrorLog(SN + " check DSN fail");
|
|
|
- MessageBox.Show(LResource.CheckDSNError);
|
|
|
+ SetfailStatus(m_writeDSN);
|
|
|
+ Log.WriteErrorLog(SN + " Write DSN fail");
|
|
|
+ MessageBox.Show(LResource.SetDSNError);
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- SetfailStatus(m_writeDSN);
|
|
|
- Log.WriteErrorLog(SN + " Write DSN fail");
|
|
|
- MessageBox.Show(LResource.SetDSNError);
|
|
|
+ MessageBox.Show(LResource.GetDSNError);
|
|
|
goto end;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- MessageBox.Show(LResource.GetDSNError);
|
|
|
+ Log.WriteErrorLog("Failed to read PSN when requesting DSN !\r\n" + devicecode);
|
|
|
+ MessageBox.Show(LResource.ReadPSNError);
|
|
|
goto end;
|
|
|
}
|
|
|
}
|