Sometime when communicating with meter I get 269 Checksum Error, and thereafter data didn't parsed in Arduino.
Please help me how can I resolve this Issue.
Thank You
Here is my log:
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
frame Data:7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
Received bytes:
111
Data send failed. Try to resend. 1
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
The client application will re-send the command if the meter doesn't reply. If your app can check that the data is corrupted and rejects the message there should be no problems after the message re-sent.
In Arduino code, If a byte is missed from uart, then it gives error of 269 and then it didn't resend same command. And I tried to send again by some modification in code, but it didn't work, as shown in log.
On 2nd try it gives a small frame which is appended to previous data as shown in log.
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
frame Data:7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
Received bytes:
111
Data send failed. Try to resend. 1
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
You are right. Re-send is not implemented for Arduino. You need to re-send data with this:
if ((ret = Serial.write(data->data, data->size)) != data->size)
I added re-send to the worklist and it will be implemented next week.
Serial transmit is implemented in Arduino as shown:
if ((ret = com_readSerialPort(0x7E)) != 0 )
{
if (ret == DLMS_ERROR_CODE_RECEIVE_FAILED && resend == RESEND_COUNT)
{
return DLMS_ERROR_CODE_SEND_FAILED;
}
++resend;
GXTRACE_INT(PSTR("Data send failed. Try to resend."), resend);
if ((ret = Serial.write(data->data, data->size)) != data->size)
{
//If failed to write all bytes.
GXTRACE(PSTR("Failed to write all data to the serial port.\n"), NULL);
}
}
In my case, Serial data is transmitted twice, but I get two different response from meter.
First I send :
7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
Response:
7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
2nd time send:
7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
Response:
7EA0074103715E667E
So sending again is not working in my case, If I get same response then there is no issue. but I am getting different responses. So I have to call obis again.
Meter's reply is invalid and when you try to read it again the meter can handle it and returns keep alive. I believe that the only way to handle this is to close the connection and read data again.
Hello,
if com_read(pg, 2); fails then I recall com_read(pg, 2) without com_close(), it start from previous fail and I got all data from it.
Is it ok to call com_read() again.
It's great if this will work, but note that this will work only when reply data is coming in one frame. It will not work if you try to read the profile generic buffer.
Thanks for info, I done it in profile generic only, didn't try in Data or register.
It is working, When get 269 error, my code call com_read(0 with same attribute again, and its working since 2 days.
But as you mentioned It will not work. So have to found another solution, as reading blling perioid tooks about 5-6 second of time. So, calling whole profile generic again, is not a proper solution for us.
if a profile generic frame missed a byte, then by resending frame again, meter will send keep live, but if I send it again , Can meter will send actual data again?
We found that our MCU missed
We found that our MCU missed a byte from received data, So is there any method to recover from it. without calling profile generic obis again.
Hi,
Hi,
The client application will re-send the command if the meter doesn't reply. If your app can check that the data is corrupted and rejects the message there should be no problems after the message re-sent.
BR,
Mikko
Hello,
Hello,
In Arduino code, If a byte is missed from uart, then it gives error of 269 and then it didn't resend same command. And I tried to send again by some modification in code, but it didn't work, as shown in log.
On 2nd try it gives a small frame which is appended to previous data as shown in log.
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
frame Data:7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
Received bytes:
111
Data send failed. Try to resend. 1
Serial Write:7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
frame Data:7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
Hi,
Hi,
You are right. Re-send is not implemented for Arduino. You need to re-send data with this:
if ((ret = Serial.write(data->data, data->size)) != data->size)
I added re-send to the worklist and it will be implemented next week.
BR,
Mikko
Hello,
Hello,
Serial transmit is implemented in Arduino as shown:
if ((ret = com_readSerialPort(0x7E)) != 0 )
{
if (ret == DLMS_ERROR_CODE_RECEIVE_FAILED && resend == RESEND_COUNT)
{
return DLMS_ERROR_CODE_SEND_FAILED;
}
++resend;
GXTRACE_INT(PSTR("Data send failed. Try to resend."), resend);
if ((ret = Serial.write(data->data, data->size)) != data->size)
{
//If failed to write all bytes.
GXTRACE(PSTR("Failed to write all data to the serial port.\n"), NULL);
}
}
In my case, Serial data is transmitted twice, but I get two different response from meter.
First I send :
7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
Response:
7EA06E41037C3CDDE6E700C40181000101020F02020FFE162102020FFE162102020FFE162102020FFE162302020FFE162302020FFE162302020F01161E02020F012002020F01162002020F01161F02020F01161E02020F01161F02020FFE16FF02020FFE16FF02020FFE16FF97997E
2nd time send:
7EA0190341D4023FE6E600C00181000701005E5B04FF020078FD7E
Response:
7EA0074103715E667E
So sending again is not working in my case, If I get same response then there is no issue. but I am getting different responses. So I have to call obis again.
Hi,
Hi,
Meter's reply is invalid and when you try to read it again the meter can handle it and returns keep alive. I believe that the only way to handle this is to close the connection and read data again.
BR,
Mikko
Hello,
Hello,
if com_read(pg, 2); fails then I recall com_read(pg, 2) without com_close(), it start from previous fail and I got all data from it.
Is it ok to call com_read() again.
Thank You
Hi,
Hi,
It's great if this will work, but note that this will work only when reply data is coming in one frame. It will not work if you try to read the profile generic buffer.
BR,
Mikko
Hello,
Hello,
Thanks for info, I done it in profile generic only, didn't try in Data or register.
It is working, When get 269 error, my code call com_read(0 with same attribute again, and its working since 2 days.
But as you mentioned It will not work. So have to found another solution, as reading blling perioid tooks about 5-6 second of time. So, calling whole profile generic again, is not a proper solution for us.
if a profile generic frame missed a byte, then by resending frame again, meter will send keep live, but if I send it again , Can meter will send actual data again?
Thank You
Hi,
Hi,
That depends on how it's implemented for the meter. Meters are working differently with this.
BR,
Mikko