src/trigger.c \
src/soft-trigger.c \
src/analog.c \
+ src/fallback.c \
src/strutil.c \
src/log.c \
src/version.c \
new Input(shared_from_this(), input), Input::Deleter());
}
+map<string, string> Context::serials(shared_ptr<Driver> driver)
+{
+ GSList *serial_list = sr_serial_list(driver ? driver->_structure : NULL);
+ map<string, string> serials;
+
+ for (GSList *serial = serial_list; serial; serial = serial->next) {
+ struct sr_serial_port *port = (sr_serial_port *) serial->data;
+ serials[string(port->name)] = string(port->description);
+ }
+
+ g_slist_free_full(serial_list, (GDestroyNotify)sr_serial_free);
+ return serials;
+}
+
Driver::Driver(struct sr_dev_driver *structure) :
ParentOwned(structure),
Configurable(structure, NULL, NULL),
/** Open an input stream based on header data.
* @param header Initial data from stream. */
shared_ptr<Input> open_stream(string header);
+ map<string, string> serials(shared_ptr<Driver> driver);
protected:
map<string, Driver *> _drivers;
map<string, InputFormat *> _input_formats;
MAP_COMMON(std::string, std::string, String, String)
+%typemap(jni) std::map<std::string, std::string>
+ "jobject"
+%typemap(jtype) std::map<std::string, std::string>
+ "java.util.Map<String,String>"
+
%typemap(out) std::map<std::string, std::string> {
jclass HashMap = jenv->FindClass("java/util/HashMap");
jmethodID init = jenv->GetMethodID(HashMap, "<init>", "()V");
*/
struct sr_session;
+/** Serial port descriptor. */
+struct sr_serial_port {
+ /** The OS dependent name of the serial port. */
+ char *name;
+ /** An end user friendly description for the serial port. */
+ char *description;
+};
+
#include "proto.h"
#include "version.h"
SR_API int sr_trigger_match_add(struct sr_trigger_stage *stage,
struct sr_channel *ch, int trigger_match, float value);
+/*--- serial.c --------------------------------------------------------------*/
+
+SR_API GSList *sr_serial_list(const struct sr_dev_driver *driver);
+SR_API void sr_serial_free(struct sr_serial_port *serial);
+
/*--- strutil.c -------------------------------------------------------------*/
SR_API char *sr_si_string_u64(uint64_t x, const char *unit);
--- /dev/null
+/*
+ * This file is part of the libsigrok project.
+ *
+ * Copyright (C) 2014 Aurelien Jacobs <aurel@gnuage.org>
+ *
+ * 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
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <glib.h>
+#include "config.h"
+#include "libsigrok.h"
+
+#ifndef HAVE_LIBSERIALPORT
+
+SR_API GSList *sr_serial_list(const struct sr_dev_driver *driver)
+{
+ return NULL;
+}
+
+SR_API void sr_serial_free(struct sr_serial_port *serial)
+{
+}
+
+#endif
return SR_OK;
}
+static struct sr_serial_port *sr_serial_new(const char *name,
+ const char *description)
+{
+ struct sr_serial_port *serial;
+
+ if (!name)
+ return NULL;
+
+ serial = g_malloc(sizeof(*serial));
+ serial->name = g_strdup(name);
+ serial->description = g_strdup(description ? description : "");
+ return serial;
+}
+
+SR_API void sr_serial_free(struct sr_serial_port *serial)
+{
+ if (serial == NULL)
+ return;
+ g_free(serial->name);
+ g_free(serial->description);
+ g_free(serial);
+}
+
+/**
+ * List available serial devices.
+ *
+ * @return A GSList of strings containing the path of the serial devices or
+ * NULL if no serial device is found. The returned list must be freed
+ * by the caller.
+ */
+SR_API GSList *sr_serial_list(const struct sr_dev_driver *driver)
+{
+ GSList *tty_devs = NULL;
+ struct sp_port **ports;
+ int i;
+
+ (void)driver;
+
+ if (sp_list_ports(&ports) != SP_OK)
+ return NULL;
+
+ for (i=0; ports[i]; i++) {
+ struct sr_serial_port *port = sr_serial_new(sp_get_port_name(ports[i]),
+ sp_get_port_description(ports[i]));
+ tty_devs = g_slist_append(tty_devs, port);
+ }
+
+ sp_free_port_list(ports);
+ return tty_devs;
+}
+
/**
* Find USB serial devices via the USB vendor ID and product ID.
*