X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=inline;f=src%2Fhardware%2Fmanson-hcs-3xxx%2Fprotocol.c;h=30017d1cdcbaeea092676db753ca31bdab4d8b42;hb=a82490b6f7ea4a65a45d96e1a55c7bd74a4e49c1;hp=5fa53d29ab38d0f5233c085e8c5ec23b3197f1cd;hpb=695dc859c15ba4190f5c1aa2e1a6e2dc6a6e5845;p=libsigrok.git
diff --git a/src/hardware/manson-hcs-3xxx/protocol.c b/src/hardware/manson-hcs-3xxx/protocol.c
index 5fa53d29..30017d1c 100644
--- a/src/hardware/manson-hcs-3xxx/protocol.c
+++ b/src/hardware/manson-hcs-3xxx/protocol.c
@@ -15,15 +15,9 @@
* 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 .
*/
-/** @file
- * Manson HCS-3xxx Series power supply driver
- * @internal
- */
-
#include
#include "protocol.h"
@@ -56,10 +50,12 @@ SR_PRIV int hcs_send_cmd(struct sr_serial_dev_inst *serial, const char *cmd, ...
/**
* 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.
@@ -123,28 +119,34 @@ static void send_sample(struct sr_dev_inst *sdi)
{
struct dev_context *devc;
struct sr_datafeed_packet packet;
- struct sr_datafeed_analog_old analog;
+ struct sr_datafeed_analog analog;
+ struct sr_analog_encoding encoding;
+ struct sr_analog_meaning meaning;
+ struct sr_analog_spec spec;
devc = sdi->priv;
- packet.type = SR_DF_ANALOG_OLD;
+ 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)
@@ -206,7 +208,7 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
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;
@@ -225,21 +227,11 @@ SR_PRIV int hcs_receive_data(int fd, int revents, void *cb_data)
/* Timeout. */
}
- if (devc->limit_samples && (devc->num_samples >= devc->limit_samples)) {
- sr_info("Requested number of samples reached.");
- sdi->driver->dev_acquisition_stop(sdi);
+ 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);
- return TRUE;
- }
- }
-
/* Request next packet, if required. */
if (sdi->status == SR_ST_ACTIVE) {
if (devc->reply_pending) {