* 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/>.
*/
-/** @file
- * <em>Manson HCS-3xxx Series</em> power supply driver
- * @internal
- */
-
+#include <config.h>
#include "protocol.h"
#define REQ_TIMEOUT_MS 500
sr_dbg("Sending '%s'.", cmd_esc);
g_free(cmd_esc);
- if ((ret = serial_write_blocking(serial, cmdbuf, strlen(cmdbuf), 0)) < 0) {
+ if ((ret = serial_write_blocking(serial, cmdbuf, strlen(cmdbuf),
+ serial_timeout(serial, strlen(cmdbuf)))) < 0) {
sr_err("Error sending command: %d.", ret);
return ret;
}
/**
* Read data from interface into buffer blocking until @a lines number of \\r chars
* received.
+ *
* @param serial Previously initialized serial port structure.
* @param[in] lines Number of \\r-terminated lines to read (1-n).
- * @param buf Buffer for result. Contents is NUL-terminated on success.
+ * @param buf Buffer for result. Contents is NUL-terminated on success.
* @param[in] buflen Buffer length (>0).
+ *
* @retval SR_OK Lines received and ending with "OK\r" (success).
* @retval SR_ERR Error.
* @retval SR_ERR_ARG Invalid argument.
struct dev_context *devc;
struct sr_datafeed_packet packet;
struct sr_datafeed_analog analog;
+ struct sr_analog_encoding encoding;
+ struct sr_analog_meaning meaning;
+ struct sr_analog_spec spec;
devc = sdi->priv;
+ sr_analog_init(&analog, &encoding, &meaning, &spec, 2);
+
packet.type = SR_DF_ANALOG;
packet.payload = &analog;
- analog.channels = sdi->channels;
+ analog.meaning->channels = sdi->channels;
analog.num_samples = 1;
- analog.mq = SR_MQ_VOLTAGE;
- analog.unit = SR_UNIT_VOLT;
- analog.mqflags = SR_MQFLAG_DC;
+ analog.meaning->mq = SR_MQ_VOLTAGE;
+ analog.meaning->unit = SR_UNIT_VOLT;
+ analog.meaning->mqflags = SR_MQFLAG_DC;
analog.data = &devc->voltage;
sr_session_send(sdi, &packet);
- analog.mq = SR_MQ_CURRENT;
- analog.unit = SR_UNIT_AMPERE;
- analog.mqflags = 0;
+ analog.meaning->mq = SR_MQ_CURRENT;
+ analog.meaning->unit = SR_UNIT_AMPERE;
+ analog.meaning->mqflags = 0;
analog.data = &devc->current;
sr_session_send(sdi, &packet);
- devc->num_samples++;
+
+ sr_sw_limits_update_samples_read(&devc->limits, 1);
}
static int parse_reply(struct sr_dev_inst *sdi)
struct sr_dev_inst *sdi;
struct dev_context *devc;
struct sr_serial_dev_inst *serial;
- int64_t t, elapsed_us;
+ uint64_t elapsed_us;
(void)fd;
/* Timeout. */
}
- if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
- sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
+ if (sr_sw_limits_check(&devc->limits)) {
+ sr_dev_acquisition_stop(sdi);
return TRUE;
}
- if (devc->limit_msec) {
- t = (g_get_monotonic_time() - devc->starttime) / 1000;
- if (t > (int64_t)devc->limit_msec) {
- sr_info("Requested time limit reached.");
- sdi->driver->dev_acquisition_stop(sdi, cb_data);
- return TRUE;
- }
- }
-
/* Request next packet, if required. */
if (sdi->status == SR_ST_ACTIVE) {
if (devc->reply_pending) {