-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OLS Improvements #51
base: master
Are you sure you want to change the base?
OLS Improvements #51
Changes from 1 commit
8ea06d6
e5dc9e6
86bf1d5
fd87a59
23f9047
b3ef78e
6621a22
c67f087
f05c040
84d6e00
72fae1a
7fc0db4
3a39f13
05e39c5
1a2437b
e068d80
fadfd5e
e58ecb2
6af1de2
5696a4d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,14 +73,28 @@ static int ols_send_longdata(struct sr_serial_dev_inst *serial, uint8_t command, | |
|
||
SR_PRIV int ols_send_reset(struct sr_serial_dev_inst *serial) | ||
{ | ||
unsigned int i; | ||
int i, ret, delay_ms; | ||
char dummy[16]; | ||
|
||
/* Drain all data so that the remote side is surely listening. */ | ||
while ((ret = serial_read_nonblocking(serial, &dummy, 16)) > 0); | ||
if (ret != SR_OK) | ||
return ret; | ||
Comment on lines
+86
to
+87
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should really bail out of the reset routine? I mean, what should the upper layers do then? It might make sense to try as hard as possible and only present the return value after we tried everything. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re: Re: |
||
|
||
for (i = 0; i < 5; i++) { | ||
if (send_shortcommand(serial, CMD_RESET) != SR_OK) | ||
return SR_ERR; | ||
if ((ret = send_shortcommand(serial, CMD_RESET)) != SR_OK) | ||
return ret; | ||
Comment on lines
+90
to
+91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
} | ||
|
||
return SR_OK; | ||
/* | ||
* Remove all stray output that arrived in between. | ||
* This is likely to happen when RLE is being used because | ||
* the device seems to return a bit more data than we request. | ||
*/ | ||
delay_ms = serial_timeout(serial, 16); | ||
while ((ret = serial_read_blocking(serial, &dummy, 16, delay_ms)) > 0); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ";" to an extra line, please |
||
|
||
return ret; | ||
} | ||
|
||
/* Configures the channel mask based on which channels are enabled. */ | ||
|
@@ -365,13 +379,11 @@ SR_PRIV int ols_set_samplerate(const struct sr_dev_inst *sdi, | |
|
||
SR_PRIV void abort_acquisition(const struct sr_dev_inst *sdi) | ||
{ | ||
struct sr_serial_dev_inst *serial; | ||
struct sr_serial_dev_inst *serial = sdi->conn; | ||
|
||
serial = sdi->conn; | ||
ols_send_reset(serial); | ||
|
||
serial_source_remove(sdi->session, serial); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I like that the new code has less lines. But is has not added reset when acquisition ends like commit message says? Maybe I overlooked something or the commit message needs updating. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, indeed! I removed that part from the commit message – there is no resetting after capture. |
||
std_session_send_df_end(sdi); | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, an endless loop... First, I suggest to put the ';' to a seperate line to make it clear it is an endless loop. Other than that, won't this take a while dumping all the data? I have an OLS clone with 1MB of RAM... Do we really need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed the formatting, on both instances to make it more obvious.
Yes, it might take a while to dump the data. But we need it because we need the device to be in the state we think it is: If it's still dumping data from before we reset it, we're not expecting this after the reset and the whole communication afterwards is messed up. Thus, I introduce this period of quiescence to re-sync the device and the driver.