Commit 6f1f5bfd authored by Lucas Russo's avatar Lucas Russo

hal/sm_io/*/acq/*: fix _acq_get_data_block () block return

Now the function only returns valid bytes to the client.

This fixes #45 github issue.
parent e8903661
......@@ -39,6 +39,7 @@ typedef struct _smio_acq_data_block_t smio_acq_data_block_t;
#define ACQ_NOT_COMPLETED 2 /* Acquisition not completed */
#define ACQ_BLOCK_OOR 3 /* Block number out of range */
#define ACQ_NUM_CHAN_OOR 4 /* Channel number out of range */
#define ACQ_REPLY_END 5 /* End marker */
#define ACQ_COULD_NOT_READ 5 /* Channel number out of range */
#define ACQ_REPLY_END 6 /* End marker */
#endif
......@@ -268,12 +268,23 @@ static int _acq_get_data_block (void *owner, void *args, void *ret)
/* Here we must use the "raw" version, as we can't have
* LARGE_MEM_ADDR mangled with the bas address of this SMIO */
data_block->valid_bytes = smio_thsafe_raw_client_read_block (self, LARGE_MEM_ADDR | addr_i,
ssize_t valid_bytes = smio_thsafe_raw_client_read_block (self, LARGE_MEM_ADDR | addr_i,
reply_size, (uint32_t *) data_block->data);
DBE_DEBUG (DBG_SM_IO | DBG_LVL_TRACE, "[sm_io:acq] get_data_block: "
"%u bytes read\n", data_block->valid_bytes);
"%ld bytes read\n", valid_bytes);
return sizeof (*data_block);
/* Check if we could read successfully */
int retf = 0;
if (valid_bytes >= 0) {
data_block->valid_bytes = (uint32_t) valid_bytes;
retf = valid_bytes + (ssize_t) sizeof (data_block->valid_bytes);
}
else {
data_block->valid_bytes = 0;
retf = -ACQ_COULD_NOT_READ;
}
return retf;
}
/* Exported function pointers */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment