-
Notifications
You must be signed in to change notification settings - Fork 397
OLS Improvements #51
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
Draft
v1ne
wants to merge
20
commits into
sigrokproject:master
Choose a base branch
from
v1ne:ols-improvements
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
OLS Improvements #51
Changes from 10 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
8ea06d6
ols: Clean up: Obey code style
v1ne e5dc9e6
ols: Provide sample count in RLE mode
v1ne 86bf1d5
ols: Don't store temporary data in device context
v1ne fd87a59
ols: Don't silently ignore error when setting up the device
v1ne 23f9047
ols: Fix demuxer operation
v1ne b3ef78e
ols: Fix off-by-one when setting up trigger stages
v1ne 6621a22
ols: Adjust pre-trigger delay
v1ne c67f087
ols: Flip samples after reading everything
v1ne f05c040
ols: Use a dynamic sample buffer
v1ne 84d6e00
ols: Be more robust against short reads
v1ne 72fae1a
ols: Make resetting more robust, reset at the end
v1ne 7fc0db4
ols: Clean up: Rename variables, remove misleading counter
v1ne 3a39f13
ols: Clean up: Always keep sample_buf_size up to date
v1ne 05e39c5
ols: Communicate internally that the number of samples is a multiple …
v1ne 1a2437b
ols: Immediately process data after expected sample count
v1ne e068d80
ols: Receive many bytes in a row
v1ne fadfd5e
ols: Capture multiple bytes at once
v1ne e58ecb2
ols: Determine the right trigger point when using RLE
v1ne 6af1de2
ols: Support Demon Core RLE mode 3
v1ne 5696a4d
ols: Add support for advanced triggers
v1ne File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -48,9 +48,9 @@ static const int32_t trigger_matches[] = { | |
| SR_TRIGGER_ONE, | ||
| }; | ||
|
|
||
| static const char* external_clock_edges[] = { | ||
| "rising", // positive edge | ||
| "falling" // negative edge | ||
| static const char *external_clock_edges[] = { | ||
| "rising", /* positive edge */ | ||
| "falling" /* negative edge */ | ||
| }; | ||
|
|
||
| #define STR_PATTERN_NONE "None" | ||
|
|
@@ -146,7 +146,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) | |
| return NULL; | ||
| } | ||
|
|
||
| num_read = serial_read_blocking(serial, buf, 4, serial_timeout(serial, 4)); | ||
| num_read = | ||
| serial_read_blocking(serial, buf, 4, serial_timeout(serial, 4)); | ||
| if (num_read < 0) { | ||
| sr_err("Getting ID reply failed (%d).", num_read); | ||
| return NULL; | ||
|
|
@@ -181,13 +182,13 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) | |
| sdi->version = g_strdup("v1.0"); | ||
| for (i = 0; i < ARRAY_SIZE(ols_channel_names); i++) | ||
| sr_channel_new(sdi, i, SR_CHANNEL_LOGIC, TRUE, | ||
| ols_channel_names[i]); | ||
| ols_channel_names[i]); | ||
| sdi->priv = ols_dev_new(); | ||
| } | ||
| /* Configure samplerate and divider. */ | ||
| if (ols_set_samplerate(sdi, DEFAULT_SAMPLERATE) != SR_OK) | ||
| sr_dbg("Failed to set default samplerate (%"PRIu64").", | ||
| DEFAULT_SAMPLERATE); | ||
| sr_dbg("Failed to set default samplerate (%" PRIu64 ").", | ||
| DEFAULT_SAMPLERATE); | ||
| sdi->inst_type = SR_INST_SERIAL; | ||
| sdi->conn = serial; | ||
|
|
||
|
|
@@ -197,7 +198,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) | |
| } | ||
|
|
||
| static int config_get(uint32_t key, GVariant **data, | ||
| const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | ||
| const struct sr_dev_inst *sdi, | ||
| const struct sr_channel_group *cg) | ||
| { | ||
| struct dev_context *devc; | ||
|
|
||
|
|
@@ -227,15 +229,18 @@ static int config_get(uint32_t key, GVariant **data, | |
| *data = g_variant_new_string(STR_PATTERN_NONE); | ||
| break; | ||
| case SR_CONF_RLE: | ||
| *data = g_variant_new_boolean(devc->capture_flags & CAPTURE_FLAG_RLE ? TRUE : FALSE); | ||
| *data = g_variant_new_boolean( | ||
| devc->capture_flags & CAPTURE_FLAG_RLE ? TRUE : FALSE); | ||
| break; | ||
| case SR_CONF_EXTERNAL_CLOCK: | ||
| *data = g_variant_new_boolean( | ||
| devc->capture_flags & CAPTURE_FLAG_CLOCK_EXTERNAL ? TRUE : FALSE); | ||
| devc->capture_flags & CAPTURE_FLAG_CLOCK_EXTERNAL | ||
| ? TRUE : FALSE); | ||
| break; | ||
| case SR_CONF_CLOCK_EDGE: | ||
| *data = g_variant_new_string(external_clock_edges[ | ||
| devc->capture_flags & CAPTURE_FLAG_INVERT_EXT_CLOCK ? 1 : 0]); | ||
| devc->capture_flags & CAPTURE_FLAG_INVERT_EXT_CLOCK | ||
| ? 1 : 0]); | ||
| break; | ||
| default: | ||
| return SR_ERR_NA; | ||
|
|
@@ -245,7 +250,8 @@ static int config_get(uint32_t key, GVariant **data, | |
| } | ||
|
|
||
| static int config_set(uint32_t key, GVariant *data, | ||
| const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | ||
| const struct sr_dev_inst *sdi, | ||
| const struct sr_channel_group *cg) | ||
| { | ||
| struct dev_context *devc; | ||
| uint16_t flag; | ||
|
|
@@ -334,15 +340,17 @@ static int config_set(uint32_t key, GVariant *data, | |
| } | ||
|
|
||
| static int config_list(uint32_t key, GVariant **data, | ||
| const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) | ||
| const struct sr_dev_inst *sdi, | ||
| const struct sr_channel_group *cg) | ||
| { | ||
| struct dev_context *devc; | ||
| int num_ols_changrp, i; | ||
|
|
||
| switch (key) { | ||
| case SR_CONF_SCAN_OPTIONS: | ||
| case SR_CONF_DEVICE_OPTIONS: | ||
| return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts); | ||
| return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, | ||
| devopts); | ||
| case SR_CONF_SAMPLERATE: | ||
| *data = std_gvar_samplerates_steps(ARRAY_AND_SIZE(samplerates)); | ||
| break; | ||
|
|
@@ -359,8 +367,6 @@ static int config_list(uint32_t key, GVariant **data, | |
| if (!sdi) | ||
| return SR_ERR_ARG; | ||
| devc = sdi->priv; | ||
| if (devc->capture_flags & CAPTURE_FLAG_RLE) | ||
| return SR_ERR_NA; | ||
|
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. Makes sense to me! |
||
| if (devc->max_samples == 0) | ||
| /* Device didn't specify sample memory size in metadata. */ | ||
| return SR_ERR_NA; | ||
|
|
@@ -375,8 +381,8 @@ static int config_list(uint32_t key, GVariant **data, | |
| num_ols_changrp++; | ||
| } | ||
|
|
||
| *data = std_gvar_tuple_u64(MIN_NUM_SAMPLES, | ||
| (num_ols_changrp) ? devc->max_samples / num_ols_changrp : MIN_NUM_SAMPLES); | ||
| *data = std_gvar_tuple_u64(MIN_NUM_SAMPLES, (num_ols_changrp) | ||
| ? devc->max_samples / num_ols_changrp : MIN_NUM_SAMPLES); | ||
| break; | ||
| default: | ||
| return SR_ERR_NA; | ||
|
|
@@ -403,7 +409,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) | |
| return SR_ERR; | ||
|
|
||
| /* Reset all operational states. */ | ||
| devc->rle_count = devc->num_transfers = 0; | ||
| devc->rle_count = devc->raw_sample_buf_size = 0; | ||
| devc->num_samples = devc->num_bytes = 0; | ||
| devc->cnt_bytes = devc->cnt_samples = devc->cnt_samples_rle = 0; | ||
| memset(devc->sample, 0, 4); | ||
|
|
@@ -413,10 +419,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi) | |
| /* If the device stops sending for longer than it takes to send a byte, | ||
| * that means it's finished. But wait at least 100 ms to be safe. | ||
| */ | ||
| serial_source_add(sdi->session, serial, G_IO_IN, 100, | ||
| ols_receive_data, (struct sr_dev_inst *)sdi); | ||
|
|
||
| return SR_OK; | ||
| return serial_source_add(sdi->session, serial, G_IO_IN, 100, | ||
|
||
| ols_receive_data, (struct sr_dev_inst *)sdi); | ||
| } | ||
|
|
||
| static int dev_acquisition_stop(struct sr_dev_inst *sdi) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.