]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/center-3xx/api.c
Add sr_dev_acquisition_start(), factor out SR_ERR_DEV_CLOSED check.
[libsigrok.git] / src / hardware / center-3xx / api.c
index 27c8d7e65e11e8963e9b61c1a086ce75730cca19..e826c59dabfc220fd106fbfa8e3c48fe785db608 100644 (file)
@@ -14,8 +14,7 @@
  * 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include <config.h>
@@ -60,18 +59,14 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
 {
        int i;
        struct sr_dev_inst *sdi;
-       struct drv_context *drvc;
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
-       GSList *devices;
 
        serial = sr_serial_dev_inst_new(conn, serialcomm);
 
        if (serial_open(serial, SERIAL_RDWR) != SR_OK)
                return NULL;
 
-       drvc = center_devs[idx].di->context;
-       devices = NULL;
        serial_flush(serial);
 
        sr_info("Found device on port %s.", conn);
@@ -84,17 +79,13 @@ static GSList *center_scan(const char *conn, const char *serialcomm, int idx)
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;
        sdi->priv = devc;
-       sdi->driver = center_devs[idx].di;
 
        for (i = 0; i < center_devs[idx].num_channels; i++)
                sr_channel_new(sdi, i, SR_CHANNEL_ANALOG, TRUE, channel_names[i]);
 
-       drvc->instances = g_slist_append(drvc->instances, sdi);
-       devices = g_slist_append(devices, sdi);
-
        serial_close(serial);
 
-       return devices;
+       return g_slist_append(NULL, sdi);
 }
 
 static GSList *scan(GSList *options, int idx)
@@ -126,7 +117,7 @@ static GSList *scan(GSList *options, int idx)
                devices = center_scan(conn, center_devs[idx].conn, idx);
        }
 
-       return devices;
+       return std_scan_complete(center_devs[idx].di, devices);
 }
 
 static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sdi,
@@ -174,14 +165,11 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
        struct dev_context *devc;
        struct sr_serial_dev_inst *serial;
 
-       if (sdi->status != SR_ST_ACTIVE)
-               return SR_ERR_DEV_CLOSED;
-
        devc = sdi->priv;
 
        sr_sw_limits_acquisition_start(&devc->sw_limits);
 
-       std_session_send_df_header(sdi, LOG_PREFIX);
+       std_session_send_df_header(sdi);
 
        /* Poll every 500ms, or whenever some data comes in. */
        serial = sdi->conn;
@@ -191,12 +179,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, int idx)
        return SR_OK;
 }
 
-static int dev_acquisition_stop(struct sr_dev_inst *sdi)
-{
-       return std_serial_dev_acquisition_stop(sdi,
-                       std_serial_dev_close, sdi->conn, LOG_PREFIX);
-}
-
 /* Driver-specific API function wrappers */
 #define HW_SCAN(X) \
 static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \
@@ -223,7 +205,7 @@ static struct sr_dev_driver ID##_driver_info = { \
        .dev_open = std_serial_dev_open, \
        .dev_close = std_serial_dev_close, \
        .dev_acquisition_start = dev_acquisition_start_##ID_UPPER, \
-       .dev_acquisition_stop = dev_acquisition_stop, \
+       .dev_acquisition_stop = std_serial_dev_acquisition_stop, \
        .context = NULL, \
 }; \
 SR_REGISTER_DEV_DRIVER(ID##_driver_info);