Comments (7)
with current volkszaehler/libsml master:
[/tmp/libsml]$ gdb ./examples/sml_server
Reading symbols from ./examples/sml_server...done.
(gdb) run - <EMH_eHZ-IW8E2A5L0EK2P_crash.bin
Starting program: /tmp/libsml/examples/sml_server - <EMH_eHZ-IW8E2A5L0EK2P_crash.bin
SML file (3 SML messages, 344 bytes)
SML message 101
SML message 701
SML message 201
OBIS data
libsml: error: unknown type 0 in sml_value_to_double
libsml: error: unknown type 0 in sml_value_to_double
1-0:1.8.0*255#2795692.7#Wh
1-0:1.8.1*255#2795692.7#Wh
1-0:16.7.0*255#136.7#W
libsml: error: unknown type 0 in sml_value_to_double
Program received signal SIGSEGV, Segmentation fault.
0x0000000000401153 in transport_receiver (buffer=0x7fffffffc430 "\033\033\033\033\001\001\001\001v\a", buffer_len=360)
at sml_server.c:104
104 switch (*entry->unit) {
(gdb) p *entry
$1 = {obj_name = 0x60cd80, status = 0x0, val_time = 0x0, unit = 0x0, scaler = 0x0, value = 0x60cdc0, value_signature = 0x0, next = 0x60ce00}
(gdb)
from libsml.
44 typedef struct sml_list_entry {
45 octet_string *obj_name;
46 sml_status *status; // optional
47 sml_time *val_time; // optional
48 sml_unit *unit; // optional
this seems to indicate this first bug is in sml_server.c, relying on an optional field being present.
but there's more after that...
from libsml.
Program received signal SIGSEGV, Segmentation fault.
0x0000000000402f4a in sml_value_to_double (value=0x0) at src/sml_value.c:113
113 switch (value->type) {
downright silly, the parser returns an entry with a null value
and we pass that to _to_double
...
i do not know if it's sensible for the parser to return such an entry.
from libsml.
after fixing those two (both in sml_server.c), no more crashing.
(instead the program hangs because it ignores EOF)
from libsml.
does not seem worth forking the repo for this:
[/tmp/libsml]$ git diff
diff --git a/examples/sml_server.c b/examples/sml_server.c
index df29996..bbaabdd 100644
--- a/examples/sml_server.c
+++ b/examples/sml_server.c
@@ -37,6 +37,8 @@ int serial_port_open(const char* device) {
struct termios config;
memset(&config, 0, sizeof(config));
+ if (!strcmp(device,"-")) return 0; // read stdin when "-" is given for the device
+
#ifdef O_NONBLOCK
int fd = open(device, O_RDWR | O_NOCTTY | O_NONBLOCK);
#else
@@ -90,6 +92,7 @@ void transport_receiver(unsigned char *buffer, size_t buffer_len) {
sml_get_list_response *body;
body = (sml_get_list_response *) message->message_body->data;
for (entry = body->val_list; entry != NULL; entry = entry->next) {
+ if (!entry->value) continue; // do not crash on null entries
value = sml_value_to_double(entry->value);
if (value != 0) {
int scaler = (entry->scaler) ? *entry->scaler : 1;
@@ -99,7 +102,7 @@ void transport_receiver(unsigned char *buffer, size_t buffer_len) {
entry->obj_name->str[0], entry->obj_name->str[1],
entry->obj_name->str[2], entry->obj_name->str[3],
entry->obj_name->str[4], entry->obj_name->str[5], value);
- switch (*entry->unit) {
+ if (entry->unit) switch (*entry->unit) {
case 0x1B:
printf("W");
break;
@@ -129,15 +132,15 @@ int main(int argc, char *argv[]) {
}
// check for serial port
- if (access(argv[1], F_OK) == -1) {
+ if (strcmp(argv[1],"-")&&access(argv[1], F_OK) == -1) {
printf("Error: no such device (%s)\n", argv[1]);
exit(2);
}
// open serial port
int fd = serial_port_open(argv[1]);
- if (!fd) {
- printf("Error: can''t open device (%s)\n", argv[1]);
+ if (fd<0) {
+ printf("Error: can't open device (%s)\n", argv[1]);
exit(3);
}
from libsml.
here is a PR after all: #34
from libsml.
i would say the libsml code is pretty stable otherwise:
[/tmp/libsml]$ bfr -p </dev/urandom | ./examples/sml_server -
[ ######################################## ][ 760.7k/s->5088.0k->757.6k/s (142292.0k) ]
(we might want to create an input with more valid sml frame headers)
from libsml.
Related Issues (20)
- Unsigned current Power Value HOT 9
- timeout HOT 6
- libsml crc enhancements ? HOT 10
- DZG workaround not necessary anymore HOT 20
- Add support for efr SGM-C4 meter
- sml_server does not decode testfile from eBZ DD3 2R06 HOT 2
- SML-Errors with Holley DTZ541 HOT 2
- hexdump() compatibility issue with newest Arduino / ESP8266 libraries HOT 8
- libsml debian package still points to dailab repo HOT 3
- Cannot Build on Raspberry Debian 11 with gcc version 10.2.1 HOT 2
- sml_server does not decode data from device DZMeteringGmbH_WS_7412.1 (negative values) HOT 15
- sml_server not part of libsml1 debian package HOT 7
- Odd readings from DWSB20.2TH: Display shows power -195W, vzlogger reports 460W HOT 15
- List of projects using libsml HOT 3
- How to use libsml in ESPhome? HOT 3
- deprecate / replace `sml_transport` API
- support arduino?
- DZG - libsml: error: unrecognized sequence HOT 8
- More Examples HOT 6
- Compile Error on Alpine: no member named '__jmpbuf' HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libsml.