How to use po-util's library manager


#1

One of po-util's new features is its library manager.

The library manager makes it easy to use Particle libraries when developing with po-util locally. The library manager does this by using git to download Particle libraries hosted on GitHub and save them to a ~/.po-util/lib directory so that they make be linked inside of projects later.

Here are all of the commands for the library manager:

"po library": The Particle Library manager for po-util.
                Libraries are kept in ~/.po-util/lib

Commands:
  get          Download a Particle Library from GitHub and optionally name it.
  install      Example:
                      po lib get https://github.com/user/libraryName libraryName

  add          Add a downloaded library to a po-util project.
  import       Libraries are added in the firmware directory as soft links.
               Example:
                      po lib add libraryName

  remove       Remove a library from a po-util project.
  rm           Just the soft links are deleted.
               Example:
                      po lib rm libraryName

  create       Create a library from C++ files in the project directory.
               Example:
                      po lib create someLibrary

  purge        Uninstall (delete) a library from ~/.po-util/lib
               Example:
                      po lib purge someLibrary

  list         Show all libraries in ~/.po-util/lib

  help         Show this help documentation.

Can I transfer my Web IDE Project?

The library manager makes it easy to download libraries used in the Web IDE. Here is an example showing how to download the official PowerShield library.

Step 1: Finding the GitHub URL

To find the GitHub URL for a library on the Web IDE, simply click on the GitHub Icon.

You will be taken to the library’s GitHub repository. Click on the “Clone or Download” button and copy the URL inside of the box.

Step 2: Downloading the library

Assuming you already have po-util installed, you would simply download a library by doing:

po lib get GITHUB_URL

pasting in the URL you copied from GitHub.

So to get the PowerShield library you would do:

po lib get https://github.com/spark/PowerShield.git

Step 3: Adding the library to a po-util project

To add a library to a project you would run:

po lib add LIBRARY_NAME

So to add the PowerShield library you would run:

po lib add PowerShield

####Step 4: Using the library

To include the library, you would simply add:

#include "LIBRARY_NAME.h"

to your main.cpp file.

Does this make local development easier?

It does. The library manager adds a useful feature to po-util, making po-util an even more handy tool for developing locally. The library manager is included in po-util, which is available for Linux and MacOS for everyone to use for free.

Po-util can be downloaded by doing:

curl -fsSLO https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh
./po-util.sh install

or by following the alternative instructions on po-util.com. Po-util is open source and can be found on GitHub. https://github.com/nrobinson2000/po-util


Po-util: The Ultimate Local Particle Experience for Linux and macOS
Truly offline IDE?
#2

I have made a major update to po-util and its library manager.

First of all, po-util now uses version 6.x of Node.js, which will remain stable for a while.

Second, I have made it so that po-util keeps track of the libraries you are using in a project by storing the URL where you cloned the library from and the name of the library in a libs.txt file in the root of each project folder.

The beauty of this is that po-util maintains a list of dependent libraries for your project, so that when you decide to share your project, other users can simply run po lib setup to automatically download and link all of the dependent libraries listed in your libs.txt.

Another handy command is po lib clean, which essentially removes all of the symlinks in your project, and leaves your libs.txt untouched. This is ideal for when sharing your project, as there will be no dead symlinks.

Here is an example libs.txt:

https://github.com/Adesh/SparkCore-LiquidCrystal-master.git LiquidCrystal
https://github.com/spark/PowerShield.git PowerShield
https://github.com/spark/OneWireLibrary.git OneWire
https://github.com/tomdeboer/SparkCoreDallasTemperature.git spark-dallas-temperature
https://github.com/spark/AssetTracker.git AssetTracker
https://github.com/spark/InternetButton.git InternetButton
https://github.com/spark/RelayShield.git RelayShield

It contains several libraries, each with the GitURL LibName notation.

Here is what po-util outputs when I run po lib setup to download and link all of the requested libraries:

Dowloading library LiquidCrystal...

Cloning into 'LiquidCrystal'...
remote: Counting objects: 20, done.
remote: Total 20 (delta 0), reused 0 (delta 0), pack-reused 20
Unpacking objects: 100% (20/20), done.
Checking connectivity... done.

Adding library LiquidCrystal to this project...

Dowloading library PowerShield...

Cloning into 'PowerShield'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Checking connectivity... done.

Adding library PowerShield to this project...

Dowloading library OneWire...

Cloning into 'OneWire'...
remote: Counting objects: 113, done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 113 (delta 0), reused 0 (delta 0), pack-reused 111
Receiving objects: 100% (113/113), 37.19 KiB | 0 bytes/s, done.
Resolving deltas: 100% (53/53), done.
Checking connectivity... done.

Adding library OneWire to this project...

Dowloading library spark-dallas-temperature...

Cloning into 'spark-dallas-temperature'...
remote: Counting objects: 44, done.
remote: Total 44 (delta 0), reused 0 (delta 0), pack-reused 44
Unpacking objects: 100% (44/44), done.
Checking connectivity... done.

Adding library spark-dallas-temperature to this project...

Dowloading library AssetTracker...

Cloning into 'AssetTracker'...
remote: Counting objects: 39, done.
remote: Total 39 (delta 0), reused 0 (delta 0), pack-reused 39
Unpacking objects: 100% (39/39), done.
Checking connectivity... done.

Adding library AssetTracker to this project...

Dowloading library InternetButton...

Cloning into 'InternetButton'...
remote: Counting objects: 189, done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 189 (delta 7), reused 0 (delta 0), pack-reused 171
Receiving objects: 100% (189/189), 60.04 KiB | 0 bytes/s, done.
Resolving deltas: 100% (107/107), done.
Checking connectivity... done.

Adding library InternetButton to this project...

Dowloading library RelayShield...

Cloning into 'RelayShield'...
remote: Counting objects: 37, done.
remote: Total 37 (delta 0), reused 0 (delta 0), pack-reused 37
Unpacking objects: 100% (37/37), done.
Checking connectivity... done.

Adding library RelayShield to this project...

Po-util’s library manager makes it dead simple to download and manage libraries when developing locally on MacOS and Linux Distributions.

Get po-util today by downloading the script and running the install command:

curl -fsSLO https://raw.githubusercontent.com/nrobinson2000/po-util/master/po-util.sh
./po-util.sh install

#3

Hey Robin
The po-util is really awesome! just perfect!
I was wondering how I could use the library manager for this PN532 Library:
po lib get https://github.com/elechouse/PN532
The Problems are the following:

  1. It creates subdirs like this:
    ~/.po-util/lib/PN532/PN532/PN532.h
    I “remedied” this by just copying them to lib by hand

ls ~/.po-util/lib
NDEF PN532 PN532_HSU PN532_I2C PN532_SPI

But now I am getting compile errors all over the place and really don’t want to copy all library headers into all folders, unless this is the only way?
i.e. I am getting this:

~/someProject/firmware/PN532_SPI/PN532_SPI.cpp:3:25: fatal error: PN532_debug.h: No such file or directory
#include “PN532_debug.h”

PN532_debug.h simply resides in firmware/PN532/ but is not found somehow…

Thanks a lot in advance!


#4

Thank you for choosing po-util!

Po-util expects a library repository to contain only one library and to be at the top level.

Does the project require all the libraries to work? If so you could do:

po lib add NDEF
po lib add PN532

...etc

Update:
The library also looks like it still needs some work being ported from Arduino.

Update 2:

I just reread your post. You should change #include "PN532_debug.h" to #include "PN532/PN532_debug.h" I think.


#5

Thanks Rob

got it to work the “dirty” way by just copying them all in one Folder… Just need the main and the _SPI part, have not tested functionality yet though, only compiling :wink:

What do you mean by it needs work to be ported from arduino?


#6

I just saw a few #include "Arduino.h" laying around but maybe it’s fine.


#7

#include "Arduino.h" should be fine from 0.6.1 on, but better 0.6.2+


#8

@nrobinson2000, I am having an issue where I have libA which is dependent on libB. Both libraries are uploaded and work with the particle web and Atom based IDE, but with po it seems that it doesn’t see that libA is dependent on libB and so I get a compile error. The libraries in question are:
libA: https://github.com/elec3647/HaySense
libB: https://github.com/elec3647/FreqPeriodCounter


#9

It looks like the path that HaySense is using to include FreqPeriodCounter is off.

You should change it to:

#include "../FreqPeriodCounter/FreqPeriodCounter.h"

I’ll improve po-util’s library import capabilities to fix this problem.


#10

Hey Nathan, I’ve been taking a look at your tool, for offline use (since I’m traveling for an extended period of time and internet is sometimes crappy).

I didn’t see any reference to using the project.properties to find the necessary libs, and you seem to use a different folder organisation that the one suggested by Particle (e.g. src/ folder for the code…). Any plan to move to/handle the properties file and standard folder organisation?

Also, having already installed all the necessary tools manually on the mac (using sudo port among others), I fear using your install process may screw things around… Any thoughts?

Cheers
Phil


#11

I created po-util’s project structure long before Particle introduced their structure. I experimented with adding support for Particle’s structure but the branch went stale, and many breaking changes would have been added.

I’d like to add support for Particle’s structure when I have time.

On the other hand, po-util’s library manager works very well, supporting particle libraries 2.0 and any library that can be cloned from GitHub.

Which dependencies in particular do you think would be affected by the install? Po-util uses brew to install dfu-util and gcc-arm, and uses npm to install particle-cli.

Po-util does an excellent job at enabling any Mac or Linux machine to compile particle firmware without any preliminary dependencies needed.


#12

I don’t doubt the utility works great.

I just would like not to have to retrieve the dependencies (and their future updates) from github directly, but rather the tool to analyze project.properties and update as needed.

Also brew on mac puts the files at a different location that macports, and free space on my mac has become a very valuable item (I have less than 30GB left, with little ability to free more than that). Before using po-util I’d rather be certain it won’t reinstall what already works (that is, the whole particle ecosystem).


#13

Well in that case, you could install just po and none of the dependencies using brew, or if you want, just download and run the po script on its own.

I’d suggest running the install process in the script though, but put an exit on line 1037, so that po sets up its environment, downloads the particle toolchain source, and then quits before downloading any dependencies.

You may have to customize po a little bit further, but it will work under your circumstances.