Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Gas identifier 0-1:24.2.1 #13

Open
Koepel opened this issue Jun 12, 2019 · 2 comments
Open

Gas identifier 0-1:24.2.1 #13

Koepel opened this issue Jun 12, 2019 · 2 comments

Comments

@Koepel
Copy link

Koepel commented Jun 12, 2019

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.

@Koepel
Copy link
Author

Koepel commented Jun 12, 2019

It has been confirmed that the "0-1:24.2.1" works. I assume that the "0-1:24.3.0" also still works.

@harold65
Copy link
Owner

Thank you for the update.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants