Skip to content

Gas identifier 0-1:24.2.1 #13

@Koepel

Description

@Koepel

On the Dutch arduinoforum.nl there is a thread with a other identifier for the gas.
The library code is now for:

0-1:24.3.0(16100733220000)(00)(60)(1)(0-1:24.2.1)(m3)
(04650.798)

But the other one is:

0-1:24.2.1(181106140010W)(01569.646*m3)

I have choosen not to combine them, because they are so different.
I would like to replace this:

    // gas definition: 0-1:24.3.0
    if (sscanf(buffer,"0-1:24.%d.%d",&i,&j) == 2)
    {
	  if(i == 3 && j == 0) readnextLine = true; // the actual gas counter is found on the next line
    }

with this:

    // gas definition: 0-1:24.3.0    gas value will be on the next line
    //                 0-1:24.2.1    normal gas definition
    //
    // The timeText will be 14 characters (13 + zero terminator).
    // It has the format:
    //   YYMMDDhhmmssX
    //     Year, Month, Day, Hour, Minute, Second, 
    //     and 'S' for DST active or 'W' for DST is not active.
    // It can be retrieved with sscanf with %13s or %13c.
    // The %13s will reads up to 13 characters, stops at space or tab.
    // The %13c will read exactly 13 characters.
    // With %13c a zero terminator has to be added:
    //   timeText[13] = '\0';
    // Reference: http://www.cplusplus.com/reference/cstdio/scanf/
    char timeText[16];

    // The "0-1:24.3.0" is a special case for the gas.
    // There is a "0-1:24.2.1" at the end of that line,
    // but the actual gas value will be on the next line.
    const char gasID2430[] = "0-1:24.3.0";

    if( strncmp( buffer, gasID2430, strlen( gasID2430)) == 0)
    {
      readnextLine = true;
    }
    else if( sscanf(buffer, "0-1:24.2.1(%13s)(%ld.%ld*m3)", timeText, &tl, &tld) == 3)
    {
      GasUsage = (tl * 1000) + tld;
    }

Only tested in a simulation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions