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
  • Loading branch information
gtrentalancia committed Jul 15, 2019
1 parent 490c9f4 commit ac9b02c
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 ac9b02c

Please sign in to comment.