Good Morning Sir,
I am using Arduino client code on ESP32 to read meter in MR mode with LLS. I am able to read the Manufacturer name and Active Energy successfully. But when I read Serial Number with obis code 0.0.96.1.0.255 I get the ASCII string on HPL meter but a Octet String on Secure Meter.
I use the code as under
cosem_init(BASE(ldn), DLMS_OBJECT_TYPE_DATA, "0.0.96.1.0.255"); // OBis for Serial No
com_read(BASE(ldn),2); // Read
obj_toString(BASE(ldn), &data);
How to identify what type of data is received octet string or normal string. ?Accordingly we can call for respective translation code.
Thank You and Best Regards
Technoshell
Hi, You can check the…
Hi,
You can check the variant type like this:
if (ldn.value.vt == DLMS_DATA_TYPE_OCTET_STRING){
...
}
else if (ldn.value.vt == DLMS_DATA_TYPE_STRING){
...
}
BR,
Mikko
I think it was Hex coded. It…
I think it was Hex coded. It showed up when I put in on Hex to ASCII converter. I will check sir. Thank you so much for your help.
Sir , ldn.vt throws error…
Sir ,
ldn.vt throws error. Intellisense shows ldn has only two attributes one is base and other is value. Please advise.
Bet Regards
Hi, My bad. The value is…
Hi,
My bad. The value is missing from the example code. I updated the code.
BR,
Mikko
Thank You Sir. I wanted to…
Thank You Sir.
I wanted to read the serial number so I used the code
int com_readNamePlateSrno()
{
unsigned char i;
int ret;
char* data = NULL;
gxData ldn;
//Initialize connection.
ret = com_initializeConnection();
if (ret != DLMS_ERROR_CODE_OK)
{
GXTRACE_INT(PSTR("F"), ret);
return ret;
}
cosem_init(BASE(ldn), DLMS_OBJECT_TYPE_DATA, "0.0.96.1.0.255"); // OBis for Serial No
com_read(BASE(ldn),2); // Read
obj_toString(BASE(ldn), &data);
Serial2.print(data);
obj_clear(BASE(ldn));
free(data);
}
The result shows
Index: 2 Value: 54308521<CR><LF>
The Serial number is correctly read as 54308521
But soon after printing the above the program hangs and prints continues garbage.
Is there something wrong I am doing?
Thanks and Regards
Hi, You need to close the…
Hi,
You need to close the connection after you have read the data. Now you leave it open and I believe that next com_initializeConnection is failing.
It's also important that you check that com_read is successful. The reading might sometimes fail.
BR,
Mikko
Thank you sir. This worked…
Thank you sir. This worked well on the old version of Arduino code. I then downloaded the latest version to work with Encryption and facing some issues. But I will create a separate topic for this. Thanks once again