This is a collection of notes as I attempt to get the FRC 2023 software stack to communicate robot->Shuffleboard->PC serial, as would be useful when controlling driver station LEDs in response to robot state changes.
Empirically, at least, the Shuffleboard development environment is that year's WPILib VS Code installation. If you use the WPILib installer, you can use that installation of VS Code to work on Shuffleboard.
Shuffleboard code repo: https://github.com/wpilibsuite/shuffleboard
Just clone, open in VS Code, and the VS Code Terminal can run the Gradle commands described in the docs, like gradlew build.
Shuffleboard has docs around extending it: https://docs.wpilib.org/en/stable/docs/software/dashboards/shuffleboard/custom-widgets/creating-plugins.html
TL;DR: there are a couple of example plugins (/example-plugins/<plugin name>) you can duplicate, rename, and add to the build scripts. Bon appetit!
Shuffleboard's plugin folder is ~/Shuffleboard/plugins or %USERPROFILE%\Shuffleboard\plugins. You can copy the JAR there manually or use Shuffleboard's plugin loader to do it, sometimes using Clear Cache. There's even a nice build target for deploying: gradlew :example-plugins:PLUGIN-NAME:installPluginI needed a little more guidance than that. JavaFX is not my native tongue, and I need cross-plat serial interop on top of it all.
So...
Repo-scale build commands are documented in the repo root readme.
Build private version of the entire application (triggers dependency download): .\gradlew :app:shadowJar
(:api:shadowJar does not seem to exist at the moment)
Building just the plugin jar (?): .\gradlew :example-plugins:xbox-controller-state:jar
Serial
https://stackoverflow.com/questions/900950/how-to-send-data-to-com-port-using-java
suggested
http://fazecast.github.io/jSerialComm/
Trying to figure out how to integrate them.
Gradle references say you can just slap in an 'implementation' clause under 'dependencies', but not only does that not seem to do anything, :example-plugins:PLUGIN-NAME:jar builds a JAR but doesn't register horrific syntax errors in my .java file!
My .java file ended up going in example-plugins\PLUGIN-NAME\src\main\java\com\SOMETHING before syntax errors would break the build.
In my plugin .gradle file, I added
implementation group: 'com.fazecast', name: 'jSerialComm', version: '2.9.3'
This lands it in the Gradle dependency cache, but the build error suggests it's not quite working.
Plugin.java:12: error: cannot find symbol
var foo = new SerialPort.getCommPorts();
^
symbol: class getCommPorts
location: class SerialPort
1 error
Note the 'new' that is, in fact, utterly wrong here.
Now, how do I deploy this jar with my module?
Logging: Fun fact, Shuffleboard uses the bog-standard java.util.logging.Logger framework. One addHandler is to...%USERPROFILE%\Shuffleboard\*.log. Yeah. I've been flying blind with stack traces and logging *right there*. Whoops.
Talking to my brother, I can tweak the Gradle files to make a fat JAR, I can deploy the JAR, or leverage the standard plugin architecture if it's available.
For futher details, see my work-in-progress branch: https://github.com/jkunkee/shuffleboard/tree/jkunkee-stub-extension
No comments:
Post a Comment