Skip to content

Commit

Permalink
Merge pull request #313 from nuccleon/master
Browse files Browse the repository at this point in the history
Issue #285
  • Loading branch information
J-A-U committed May 4, 2017
2 parents ddc24a5 + 99c5a7e commit 0762a93
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
10 changes: 10 additions & 0 deletions etc/vzlogger_generic.schema.json
Expand Up @@ -508,6 +508,11 @@
"enum": ["8n1", "7n1", "7e1", "7o1"],
"default": "8n1",
"description": "parity used for serial communication"
},
"use_local_time": {
"type": "boolean",
"default": false,
"description": "use the local time for reading timestamp?"
}
},
"required": ["protocol", "device", "baudrate", "parity"]
Expand Down Expand Up @@ -545,6 +550,11 @@
"enum": ["8n1", "7n1", "7e1", "7o1"],
"default": "8n1",
"description": "parity used for serial communication"
},
"use_local_time": {
"type": "boolean",
"default": false,
"description": "use the local time for reading timestamp?"
}
},
"required": ["protocol", "host", "baudrate", "parity"]
Expand Down
3 changes: 2 additions & 1 deletion include/protocols/MeterSML.hpp
Expand Up @@ -61,7 +61,8 @@ class MeterSML : public vz::protocol::Protocol {
speed_t _baudrate;
parity_type_t _parity;
std::string _pull;

bool _use_local_time;

int _fd; /* file descriptor of port */
struct termios _old_tio; /* required to reset port */

Expand Down
10 changes: 8 additions & 2 deletions src/protocols/MeterSML.cpp
Expand Up @@ -93,7 +93,13 @@ MeterSML::MeterSML(std::list<Option> options)
/* using default value if not specified */
_pull = "";
}

try {
_use_local_time = optlist.lookup_bool(options, "use_local_time");
}
catch (vz::OptionNotFoundException &e) {
/* using default value if not specified */
_use_local_time = false;
}

/* baudrate */
int baudrate = 9600; /* default to avoid compiler warning */
Expand Down Expand Up @@ -265,7 +271,7 @@ bool MeterSML::_parse(sml_list *entry, Reading *rd) {

// TODO handle SML_TIME_SEC_INDEX or time by SML File/Message
struct timeval tv;
if (entry->val_time) { /* use time from meter */
if (!_use_local_time && entry->val_time) { /* use time from meter */
tv.tv_sec = *entry->val_time->data.timestamp;
tv.tv_usec = 0;
}
Expand Down

0 comments on commit 0762a93

Please sign in to comment.