Skip to content

Commit

Permalink
Sort channels by type and not only by index.
Browse files Browse the repository at this point in the history
Signed-off-by: Guido Trentalancia <[email protected]>
---
 show.c |   21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)
  • Loading branch information
gtrentalancia committed Dec 13, 2018
1 parent be365fa commit a042227
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion show.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,26 @@ static gint sort_channels(gconstpointer a, gconstpointer b)
{
const struct sr_channel *pa = a, *pb = b;

return pa->index - pb->index;
if (pa->type == pb->type)
return pa->index - pb->index;

/*
* Sort analog channels before digital channels and
* digital channels before special FFT channels.
*/
if (pa->type == SR_CHANNEL_ANALOG)
return -1;

if (pb->type == SR_CHANNEL_ANALOG)
return 1;

if (pa->type == SR_CHANNEL_LOGIC)
return -1;

if (pb->type == SR_CHANNEL_LOGIC)
return 1;

return 0;
}

static void print_dev_line(const struct sr_dev_inst *sdi)
Expand Down

0 comments on commit a042227

Please sign in to comment.