15.4. Running jrk2cmd with Windows shortcuts

This section explains how to control the Jrk G2 with Windows shortcuts. A folder of shortcuts can serve as a simple GUI for controlling the Jrk and requires no programming experience to make. This section focuses on shortcuts in Windows, but you should be able to do something similar in Linux or macOS.

A folder with shortcuts to jrk2cmd that could be used for controlling the Jrk G2.

The Jrk G2 Command-line Utility (jrk2cmd) provides many commands for controlling the Jrk G2, and gets installed along with the rest of the Jrk software and drivers. After installing jrk2cmd as described in Section 3.1, you can follow these instructions to make a shortcut to it:

  1. Right-click on the blank area of your desktop or any other folder, open the “New” menu, and select “Shortcut”.
  2. Windows will open a “Create Shortcut” wizard and prompt you for the location of the item you want to make a shortcut to. Type jrk2cmd --clear-errors --target 2248 --pause-on-error or any other command you want to run.
  3. Click “Next”. If Windows says “The file jrk2cmd cannot be found.”, it either means you have not installed the Jrk software, or the folder containing jrk2cmd.exe is not listed in your PATH environment variable (maybe you unchecked the checkbox that adds it your PATH when installing the software). As a solution, you could replace jrk2cmd in the input box with the full path to jrk2cmd.exe in double quotes. However, the easiest solution is probably to reinstall the Jrk software, making sure to leave the “Add the bin directory to the PATH environment variable.” checkbox checked this time. You might also need to restart your computer.
  4. Type an appropriate name for your shortcut and click “Finish”.

Now you should be able to double-click on your shortcut to run the command you entered. You will probably see a black window briefly flash on the screen run the command runs.

At this point, you might get an error message that says:

Error: Failed to open generic handle. Access is denied. Try closing all other programs that are using the device. Windows error code 0x5.

It is best to follow the advice in the error message and close the Jrk G2 Configuration Utility and any other programs that might be using the Jrk. In Windows, only one program can use the Jrk’s native USB interface at a time.

Example commands

Here are some example commands you might want to put into a shortcut, along with information about how the command works:

jrk2cmd --clear-errors --target 1234 --pause-on-error

The command above will clear any latched errors and set the Jrk’s target to 1234. The Jrk’s input mode should be set to “Serial / I²C / USB” for this command to work. The --pause-on-error option means that if there are any errors communicating with the Jrk, then jrk2cmd will keep running until you press Enter or close the window. This prevents the jrk2cmd output window from closing immediately and allows you to read the error message. However, if there are some errors that are still happening on the Jrk and could not be cleared, there will be no notification.

jrk2cmd --stop --pause-on-error

The command above sends a “Stop motor” command. You can find more details about this command in Section 11. As in the previous command, --pause-on-error gives you a chance to see error messages if there is any problem communicating with the Jrk.

jrk2cmd --status --pause

The command above shows status information from the Jrk. This can be useful for seeing what errors are happening on the Jrk or seeing the target and feedback values. You can add the --full option to see more information. The --pause option tells jrk2cmd to always wait for you to press Enter or close the window before terminating, which gives you a chance to see the output. By default, the jrk2cmd console window will not have enough lines to show the full status output all at once. To fix this, you can modify the shortcut to make the console have more lines: right-click on the shortcut, select “Properties”, select the “Layout” tab, and then in the “Window Size” box change the “Height”.

Multiple Jrk G2 devices

If you have multiple Jrk G2 devices connected to the computer via USB, you will need to add the -d option to each shortcut in order to specify the serial number of the device you want to use. For example, a shortcut that gets the status of the Jrk G2 with serial number 12345678 would have a command like jrk2cmd -d 12345678 --status --pause. You can see your Jrk’s serial number in the Jrk G2 Configuration Utility or by running jrk2cmd --list.

Multiple commands in one shortcut

You can specify multiple commands to the Jrk in one shortcut by just adding more options. For example, you could temporarily change the Jrk’s maximum duty cycle and set the target at the same time with a command like jrk2cmd --max-duty-cycle 300 --target 1234 --pause-on-error. The order of the options does not matter; the utility performs the commands in a predetermined order. If you need something a bit more complicated, you might consider writing a Batch or PowerShell script.

Shortcut customizations

In the Properties dialog for a shortcut, you can change its icon or assign a shortcut key. You can add shortcuts to your Start Menu or make a toolbar of shortcuts inside the taskbar for quick access.

Related Products

Jrk G2 18v19 USB Motor Controller with Feedback
Jrk G2 24v13 USB Motor Controller with Feedback
Jrk G2 18v27 USB Motor Controller with Feedback
Jrk G2 24v21 USB Motor Controller with Feedback
Jrk G2 21v3 USB Motor Controller with Feedback
Jrk G2 21v3 USB Motor Controller with Feedback (Connectors Soldered)
Log In
Pololu Robotics & Electronics
Shopping cart
(702) 262-6648
Same-day shipping, worldwide
Menu
Shop Blog Forum Support
My account Comments or questions? About Pololu Contact Ordering information Distributors