|
|
|
|
@ -1413,6 +1413,73 @@ namespace n5coredll |
|
|
|
|
return RequestResult.createRespErrJson("SETTLE_RESP", ERR_STATUS_TIMEOUT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string sendParam() |
|
|
|
|
{ |
|
|
|
|
if (ifBusy) |
|
|
|
|
return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_BUSY); |
|
|
|
|
ifBusy = true; |
|
|
|
|
sendTime = 0; |
|
|
|
|
isSending = false; |
|
|
|
|
mRecvTimes = 0; |
|
|
|
|
isReadyBack = false; |
|
|
|
|
currReqByteArr = null; |
|
|
|
|
currResultJsonStr = null; |
|
|
|
|
RequestResult reqResult = null; |
|
|
|
|
isGetACK = false; |
|
|
|
|
if (openSerialPort()) |
|
|
|
|
{ |
|
|
|
|
currReqByteArr = this.packReqMsg(RequestResult.toJsonParam()); |
|
|
|
|
if (currReqByteArr == null || currReqByteArr.Length == 0) |
|
|
|
|
{ |
|
|
|
|
closeSerialPort(); |
|
|
|
|
ifBusy = false; |
|
|
|
|
return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_PARAM); |
|
|
|
|
//return "Request failed: params error"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Console.WriteLine("currReqByteArr = " + currReqByteArr); |
|
|
|
|
Console.WriteLine("currReqByteArr.Length = " + currReqByteArr.Length); |
|
|
|
|
this.sendReqMsg(); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
ifBusy = false; |
|
|
|
|
closeSerialPort(); |
|
|
|
|
return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_OPENCOM); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int sleepTime = timeOut / 1000; |
|
|
|
|
|
|
|
|
|
DateTime startTime = DateTime.Now; |
|
|
|
|
|
|
|
|
|
Boolean ifEnd = false; |
|
|
|
|
while (!ifEnd) |
|
|
|
|
{ |
|
|
|
|
DateTime nowTime = DateTime.Now; |
|
|
|
|
TimeSpan sp = nowTime - startTime; |
|
|
|
|
if (sp.TotalSeconds > sleepTime) |
|
|
|
|
ifEnd = true; |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
if (!isSending && !isGetACK) |
|
|
|
|
this.resendReqMsg(); |
|
|
|
|
if (isReadyBack) |
|
|
|
|
{ |
|
|
|
|
closeSerialPort(); |
|
|
|
|
if (currResultJsonStr != null && !"".Equals(currResultJsonStr)) |
|
|
|
|
{ |
|
|
|
|
ifBusy = false; |
|
|
|
|
return currResultJsonStr; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Console.WriteLine("Timeout return : " + DateTime.Now.ToString()); |
|
|
|
|
ifBusy = false; |
|
|
|
|
return RequestResult.createRespErrJson("PARAM_RESP", ERR_STATUS_TIMEOUT); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public string requestRetrieval(string txnId, int pTimeOut) |
|
|
|
|
{ |
|
|
|
|
RetrievalResult retrievalResult = null; |
|
|
|
|
@ -2276,8 +2343,8 @@ namespace n5coredll |
|
|
|
|
{ |
|
|
|
|
Console.WriteLine("Check LRC success! LRC is [" + ObjectUtil.desToHex(new byte[] { nlrc }) + "]"); |
|
|
|
|
sendAck(); |
|
|
|
|
string jsonMsg = System.Text.Encoding.Default.GetString(msg); |
|
|
|
|
|
|
|
|
|
//string jsonMsg = System.Text.Encoding.Default.GetString(msg); |
|
|
|
|
string jsonMsg = System.Text.Encoding.UTF8.GetString(msg); |
|
|
|
|
onMsgReceived(jsonMsg); |
|
|
|
|
reset(); |
|
|
|
|
return; |
|
|
|
|
|