As part of my getting fully up to speed, I’ve been working through all the 
Tutorials lately — just got my NRF52 board this am, so those are next up — and 
I’m having a bit of an issue with the Air Quality Sensor one. I’ll update the 
pages a bit once I’m through it successfully, but for now, here’s the issue:

Add CLI commands for testing drivers
While developing the driver, you want to issue operations from console asking 
it to do stuff. The way to do this is to register your command handler with 
shell. Whenever your custom command is issued, you can respond to it.

The way you do this is first adding a dependency to shell package for your 
senseair driver. So you change libs/my_drivers/senseair/pkg.yml to have the 
following:

pkg.name: libs/my_drivers/senseair
pkg.deps:
    - "@apache-mynewt-core/hw/hal"
    - "@apache-mynewt-core/libs/shell"
And then register your shell command in senseair_init().

[user@IsMyLaptop:~/src/air_quality]$ cat libs/my_drivers/senseair/src/senseair.c
 ....
#include <shell/shell.h>
#include <console/console.h>

static int senseair_shell_func(int argc, char **argv);
static struct shell_cmd senseair_cmd = {
    .sc_cmd = "senseair",
    .sc_cmd_func = senseair_shell_func,
};

void
senseair_init(void)
{
    int rc;

    rc = shell_cmd_register(&senseair_cmd);
    assert(rc == 0);
}

static int
senseair_shell_func(int argc, char **argv)
{
    console_printf("Yay! Somebody called!\n");
    return 0;
}
Then you build this, download to target, and start minicom on your console port.


The trouble  arises at this point. No device is ever registered for the USB 
port, so using minicom (or screen, etc.) isn’t an option as there is not 
device. I’ve tried everything I can think of, from removing the STLINK jumpers 
to plugging in both USB (STLINK and USER), etc. but still no joy.

What am I missing?

TIA,
dg
--
David G. Simmons
(919) 534-5099
Web <https://davidgs.com/> • Blog <https://davidgs.com/davidgs_blog> • Linkedin 
<http://linkedin.com/in/davidgsimmons> • Twitter 
<http://twitter.com/TechEvangelist1> • GitHub <http://github.com/davidgs>
/** Message digitally signed for security and authenticity.
* If you cannot read the PGP.sig attachment, please go to
 * http://www.gnupg.com/ <http://www.gnupg.com/> Secure your email!!!
 * Public key available at keyserver.pgp.com <http://keyserver.pgp.com/>
**/
♺ This email uses 100% recycled electrons. Don't blow it by printing!

There are only 2 hard things in computer science: Cache invalidation, naming 
things, and off-by-one errors.


Attachment: signature.asc
Description: Message signed with OpenPGP using GPGMail

Reply via email to