Monday, May 1, 2023

[Tech] FIRST Shuffleboard + PC-side Serial

 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:installPlugin

I 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

Sunday, March 12, 2023

hey, don't cry -- recipe

 Expansion of https://www.tumblr.com/thesolarsurfer/710687700479508480

two cloves garlic
a dollop of olive oilve oil
1 can crushed tomatoes
a bit of balsamic vinegar
1/2 tbsp brown sugar
1/2 cup grated paremesan cheese
handful of fresh spinach
cooked pasta of your choice

1. don't cry
2. crush two cloves garlic into a (heated) pot with a dollop of olive oil
3. stir until golden
4. add one can of crushed tomatoes, a bit of balsamic vinegar, 1/2tbsp brown sugar, 1/2c grated parmesan cheese
5. stir for a few minutes
6. add a handful of fresh spinach until wilted
7. mix in pasta of your choice
8. ok?

Notes:

1 lb pasta is too much for this recipe

It is tasty, but the Tumblr post oversells it

Thursday, December 8, 2022

[Technical] WPILib installation on ARM64 Windows

[EDIT: WPILib's installer supports installation on ARM64 as of this PR. ARM64 Windows support is discussed in detail in that thread.]

If you find yourself on a FIRST Robotics team looking to compete in the 2023 season and you're working on the software for the robot, you will probably find yourself attempting to install WPILib.

The standard path is to go to the GitHub releases page, download the relevant ISO, mount it, and run the installer. I was last on a FIRST team in 2006, and I find this system refreshingly simple.

The documentation is clear that ARM64 Windows 10 and 11 are not supported. While I greatly appreciate this candor, ARM64 Windows 11 is easy to support by leveraging x64 emulation. (Disclaimer: I work on the team at Microsoft that implemented and maintains this emulation layer.)

Please note that this is stepping off the supported path, so there may be dragons.

Installation requires enlightening the installer to choose x64 when it sees ARM64.

  1. Install Visual Studio (2019 or 2022; I used 2022 17.5.0 Preview 1.0) with the .NET Desktop Development workload.
  2. Clone the installer repository. git clone https://github.com/wpilibsuite/WPILibInstaller-Avalonia.git
  3. Open the .sln file at the root of the repo with Visual Studio.
  4. Modify WPILibInstaller-Avalonia/Utils/PlatformUtils.cs to map ARM64 to x64.
    1. In commit e4f0039cb, I changed line 50 from
    2. if (currentArch == Architecture.X64)
    3. to
    4. if (currentArch == Architecture.X64 || currentArch == Architecture.Arm64)
  5. Start the Develop Command Prompt for your installation of Visual Studio.
  6. Change to the cloned source directory.
  7. Build the standalone EXE version of the project with dotnet publish. dotnet publish -r win10-x64 -p:PublishSingleFile=true
  8. Unpack the WPILib ISO.
  9. Find WPILibInstaller.exe in the unpacked folder and replace it with <repo root>\WPILibInstaller-Avalonia\bin\Debug\net7.0\win10-x64\publish\WPILibInstaller.exe.
  10. Run the new WPILibInstaller.exe from the unpacked folder.

So far, so good...we'll see how far I get with the rest.

Sunday, July 3, 2022

A Small Note On US Politics

If you are a member of the Church of Jesus Christ of Latter-Day saints and are cheering for the evangelical Christians' ideal of a Christian-run state, please remember that it is an evangelical Christian tenet that Mormons Aren't Christian. As soon as they have enough power, you will be against the wall too.

Tuesday, November 16, 2021

[Technical] SSD1327 OLED Driver on Particle Photon

When trying to use a Particle Photon board to drive a Zio 1.5" monochrome OLED screen using U8G2 as the driver (per Zio's instructions), I hit a few problems.

Sunday, October 25, 2020

[Technical] Frustration with VSCode ESP-IDF extension

It

Just

Refuses

To

Work!

 

When using the Espressif IDF extension in Visual Studio Code, I kept getting squiggles under text even when I thought I had muddled through setup correctly, and when I went to wipe everything out and try again I kept getting

Invalid argument: '\\\\${IDF_PATH}\\tools\\kconfig_new\\esp-windows-curses'

The other messages turned out to be key: pip was positively ancient and Python 3.5 is out of support. All I had to do was upgrade to Python 3.9 and ensure that the Visual Studio C++ workload was installed and the Python requirements installation stage completed successfully.

Saturday, October 17, 2020

DasKunkee.net now live

One time when I was in high school, someone came to physics class with a package of 500 Post-It Notes. That same day, the teacher ended up needing to spend most of the hour away from us--no big deal, they're honors kids, right?

Well, someone got the bright idea to label everything in the room. First was the chalkboard, but "chalkboard" wouldn't do so it was dubbed "das chalkboard". As this group of kids circuited the room, more things were labelled "das <thing>" until they came to me. Being known by my last name, Kunkee, I was thereby dubbed "das Kunkee".

Later in high school, a friend offered to host a website for me. What to call it? DasKunkee.net.

It even had a subdomain served out of my parents' basement. The server and subsequently the subdomain were named for for the less-prosperous side of Terry Pratchett's Ankh-Morpork, Morpork. This was served on port 81 by an Intel 486 DX with, as I recall, 128 MB of RAM that ran Gentoo Linux and two 1GB SCSI-2 drives. (This is what happens when no one wants high-end spare parts from a decade ago.) I learned a lot from setting up and running it. One day I may salvage the files from it and set it up again.

Recently I got the bug to build something, so I resurrected the concept of this website: DasKunkee.net

You may notice that the styling is pretty simple. Back yonder when, the same friend kindly provided a simple set of PHP and CSS pieces that made it look awesome to my starry-eyed teenage self, and I've done my best to base the current design on it.

Of course, nowadays I'm a software engineer so some technical description is warranted. The site is stored in a GitHub repo as .pug files. Every push to main triggers a Github Action that turns the pug files into HTML and uploads them to Azure Storage. The Azure CDN then picks them up and serves them through the Azure Storage Static Website feature. (There are numerous tutorials about how to set this all up; I don't recall which ones I used, sorry.) The root SSL certificate comes from Let's Encrypt courtesy of shibayan's keyvault-acmebot (relevant blog post). ServerFault was decidedly less than helpful. For me it was a case of setting up the Static Website with one tutorial and figuring out that shibayan's work allows layering Let's Encrypt on top of that.