*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
/* Minimum interval between dispatches coming from this plugin. The RRD
* plugin, at least, complains when written to with sub-second intervals.*/
/* Minimum interval between dispatches coming from this plugin. The RRD
* plugin, at least, complains when written to with sub-second intervals.*/
if (msg_loglevel <= loglevel) {
vsnprintf(s, 512, format, args);
if (msg_loglevel <= loglevel) {
vsnprintf(s, 512, format, args);
return -1;
}
memset(cfdev, 0, sizeof(*cfdev));
if (cf_util_get_string(ci, &cfdev->name)) {
free(cfdev);
return -1;
}
memset(cfdev, 0, sizeof(*cfdev));
if (cf_util_get_string(ci, &cfdev->name)) {
free(cfdev);
return -1;
}
cfdev->min_dispatch_interval = DEFAULT_MIN_DISPATCH_INTERVAL;
for (i = 0; i < ci->children_num; i++) {
oconfig_item_t *item = ci->children + i;
return -1;
}
cfdev->min_dispatch_interval = DEFAULT_MIN_DISPATCH_INTERVAL;
for (i = 0; i < ci->children_num; i++) {
oconfig_item_t *item = ci->children + i;
if (!strcasecmp(item->key, "driver"))
cf_util_get_string(item, &cfdev->driver);
else if (!strcasecmp(item->key, "conn"))
cf_util_get_string(item, &cfdev->conn);
else if (!strcasecmp(item->key, "serialcomm"))
cf_util_get_string(item, &cfdev->serialcomm);
if (!strcasecmp(item->key, "driver"))
cf_util_get_string(item, &cfdev->driver);
else if (!strcasecmp(item->key, "conn"))
cf_util_get_string(item, &cfdev->conn);
else if (!strcasecmp(item->key, "serialcomm"))
cf_util_get_string(item, &cfdev->serialcomm);
- if (!strcasecmp(item->key, "loglevel")) {
- if (cf_util_get_int(item, &tmp) || tmp < 0 || tmp > 5) {
- ERROR("Invalid loglevel");
+ if (strcasecmp("LogLevel", item->key) == 0) {
+ int status;
+ int tmp = -1;
+
+ status = cf_util_get_int (item, &tmp);
+ if (status != 0)
+ continue;
+ else if ((tmp < 0) || (tmp > 5)) {
+ ERROR ("sigrok plugin: The \"LogLevel\" "
+ "configuration option expects "
+ "an integer between 0 and 5 "
+ "(inclusive); you provided %i.",
+ tmp);
continue;
}
loglevel = tmp;
} else if (!strcasecmp(item->key, "Device"))
sigrok_config_device(item);
else
continue;
}
loglevel = tmp;
} else if (!strcasecmp(item->key, "Device"))
sigrok_config_device(item);
else
- ERROR("Unknown device instance in sigrok driver %s.", sdi->driver->name);
+ ERROR("sigrok plugin: Received data from driver \"%s\" but "
+ "can't find a configuration / device matching "
+ "it.", sdi->driver->name);
ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance),
"%s", cfdev->name);
sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type));
ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance),
"%s", cfdev->name);
sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type));
drvopts = g_slist_append(drvopts, src);
}
devlist = sr_driver_scan(drv, drvopts);
drvopts = g_slist_append(drvopts, src);
}
devlist = sr_driver_scan(drv, drvopts);
cfdev->sdi->vendor ? cfdev->sdi->vendor : "",
cfdev->sdi->model ? cfdev->sdi->model : "",
cfdev->sdi->version ? cfdev->sdi->version : "");
cfdev->sdi->vendor ? cfdev->sdi->vendor : "",
cfdev->sdi->model ? cfdev->sdi->model : "",
cfdev->sdi->version ? cfdev->sdi->version : "");
- if ((status = plugin_thread_create(&sr_thread, NULL, sigrok_read_thread,
- NULL)) != 0) {
- ERROR("sigrok: Failed to create thread: %s.", strerror(status));
+ status = plugin_thread_create(&sr_thread, NULL, sigrok_read_thread,
+ NULL);
+ if (status != 0)
+ {
+ char errbuf[1024];
+ ERROR("sigrok plugin: Failed to create thread: %s.",
+ sstrerror (errno, errbuf, sizeof (errbuf)));
plugin_register_complex_config("sigrok", sigrok_config);
plugin_register_init("sigrok", sigrok_init);
plugin_register_shutdown("sigrok", sigrok_shutdown);
plugin_register_complex_config("sigrok", sigrok_config);
plugin_register_init("sigrok", sigrok_init);
plugin_register_shutdown("sigrok", sigrok_shutdown);