GXCommon.cs

2 posts / 0 new
Last post
fbarenghi
GXCommon.cs

Hi.

I am using GXDLMDirector to communicate with a meter.

Reading special days form the meter I found a bug:
the meter sends its table correctly but GXDLMDirector always displays its own default data.

The problem is into the GXCommon.cs module, decoding the "Date" type (from line 705): the decoded data are not written into the returned object.

A solution, in my opinion, is to change the code as for the data type "Time":

else if (type == DataType.Date)
{
if (size {
pos = 0xFF;
return null;
}
DateTimeSkips skip = DateTimeSkips.None;
//Get year.
int year = GXCommon.GetUInt16(buff, ref pos);
if (year == 0xFFFF)
{
skip |= DateTimeSkips.Year;
year = DateTime.MinValue.Year;
}
//Get month
int month = buff[pos++];
if (month == 0xFF || month == 0xFE || month == 0xFD)
{
skip |= DateTimeSkips.Month;
month = 1;
}
int day = buff[pos++];
if (day 31)
{
skip |= DateTimeSkips.Day;
day = 1;
}
//Skip week day
int DayOfWeek = buff[pos++];
//If day of week are not used.
if (DayOfWeek == 0xFF)
{
skip |= DateTimeSkips.DayOfWeek;
DayOfWeek = 1;
}
GXDateTime dt = new GXDateTime(year, month, day, 0, 0, 0, 0);
dt.Skip = skip | DateTimeSkips.Hour | DateTimeSkips.Minute | DateTimeSkips.Second | DateTimeSkips.Ms;
return dt;
}

Best regards

Franco

Kurumi
Kurumi's picture

Hi Franco,

Thank you very much for let us know this issue.
We fixed this and new versions are available at GitHub.

BR,

Mikko

________________________________________
Mikko Kurunsaari
Gurux Ltd
http://www.gurux.fi