On 07/09/2014 09:16 PM, Kumar Abhishek wrote:
> From: Kumar Abhishek <[email protected]>

> +/* Hardware options */
> +static const int32_t hwopts[] = {
> +     SR_CONF_CONN,
> +};

This is an option that can get passed to scan(), but that function doesn't
handle options at all. SR_CONF_CONN is used for passing connection info to
the driver in case of multiple instances of a device handled by that driver.
That doesn't apply for this driver though.

> +/* Hardware capabiities */
> +static const int32_t hwcaps[] = {
> +     SR_CONF_LOGIC_ANALYZER,
> +     SR_CONF_SAMPLERATE,
> +     SR_CONF_TRIGGER_MATCH,
> +
> +     SR_CONF_LIMIT_SAMPLES,
> +     SR_CONF_CONTINUOUS,
> +     /* SR_CONF_EXTERNAL_CLOCK, TODO in a future BeagleLogic firmware */

No need for that, put the option in when it's ready. No TODOs in drivers
going in, please.

> +     SR_CONF_NUM_LOGIC_CHANNELS,
> +};
> +
> +/* Trigger matching capabilities */
> +static const int32_t soft_trigger_matches[] = {
> +     SR_TRIGGER_ZERO,
> +     SR_TRIGGER_ONE,
> +     SR_TRIGGER_RISING,
> +     SR_TRIGGER_FALLING,
> +     SR_TRIGGER_EDGE,
> +};
> +
> +/* Channels are numbered 0-13 */
> +SR_PRIV const char *beaglelogic_channel_names[NUM_CHANNELS + 1] = {
> +     "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12",
> +     "13", NULL,
> +};

Probe names should correspond with what the device's vendor calls them, or
what's printed on the enclosure. In this case, the appropriate names would
be P8_27, P8_28 and so on.

> +static struct dev_context * beaglelogic_devc_alloc(void)
> +{
> +     struct dev_context *devc;
> +
> +     /* Allocate the zeroed structure */
> +     if (!(devc = g_try_malloc0(sizeof(*devc)))) {
> +             sr_err("Device context alloc failed.");
> +             return NULL;
> +     }

We don't do checks on small mallocs anymore, though we perhaps didn't
advertize the fact. In this case, just:

        devc = g_try_malloc0(sizeof(*devc));

> @@ -38,8 +100,41 @@ static GSList *scan(GSList *options)

> +     /* Probe for /dev/beaglelogic */
> +     if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS))
> +             return NULL;
> +
> +     sdi = sr_dev_inst_new(0, SR_ST_INACTIVE, NULL, "BeagleLogic", "1.0");
> +     sdi->driver = di;
> +
> +     /* We need to test for number of channels by opening the node */
> +     devc = beaglelogic_devc_alloc();
> +     if (beaglelogic_open_nonblock(devc) != SR_OK) {
> +             g_free(devc);
> +             sr_dev_inst_free(sdi);
> +
> +             return NULL;
> +     }
> +     beaglelogic_get_sampleunit(devc);
> +     beaglelogic_close(devc);
> +
> +     maxch = (devc->sampleunit == BL_SAMPLEUNIT_8_BITS) ? 8 : NUM_CHANNELS;

According to
https://github.com/abhishek-kakkar/BeagleLogic/wiki/sysfs-attributes-Reference
you set the max number of channels -- 8 or 13 -- by echo'ing 0 or 1 into
/sys/devices/virtual/misc/beaglelogic/sampleunit

You need to do this before starting the sigrok client, and do it as root as
well. It would be better if you could set this within the sigrok context.
There is a config key for exactly this: SR_CONF_NUM_LOGIC_CHANNELS.

You already need a writable channel to the beaglelogic kernel driver anyway
(for samplerate etc), so there should be no problem adding to it.


-- 
Bert Vermeulen        [email protected]          email/xmpp

------------------------------------------------------------------------------
Open source business process management suite built on Java and Eclipse
Turn processes into business applications with Bonita BPM Community Edition
Quickly connect people, data, and systems into organized workflows
Winner of BOSSIE, CODIE, OW2 and Gartner awards
http://p.sf.net/sfu/Bonitasoft
_______________________________________________
sigrok-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to