You are here

Steven D. Brewer's blog

Launching Simultaneous Processes

A student in my course is looking for a way to launch processes simultaneously on multiple raspberry pi computers. It was not immediately apparent to me how to do this, but the first thing that came to mind was "at" which lets you schedule a process to launch "at" a particular time. To test, I set up two rasberry pis: mahiro and poneo.

I wrote a python script:

----now.py----
#! /usr/bin/python3
import time
ns = time.time_ns()
timestamp = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
print(f'"{timestamp}",{ns}')
file = open("/home/pi/attest/time.txt","a")
file.write(f'"{timestamp}",{ns}\n')
file.close()

a shell script to invoke it:

----now.sh----
#! /bin/sh
/usr/bin/python3 /home/pi/attest/now.py

I put that on two pis, made sure the timezone was set to eastern, then used a script on my laptop to invoke it:

----attest.sh----
#! /bin/bash
ssh pi@mahiro at -f /home/pi/attest/now.sh "$1 today"
ssh pi@poneo at -f /home/pi/attest/now.sh "$1 today"

So, this uses ssh to talk to the pis and runs the "at" command to run the bash script at a particular time today. Then I tell the script what time to run, e.g.
./attest.sh 10:30am

And then the script invokes the processes on the same second on both pis. Here are the results:
----poneo----
"2020-11-10 10:22:00",1605021720479176213
"2020-11-10 10:29:00",1605022140756637058
"2020-11-10 10:30:01",1605022201055563711
"2020-11-10 10:31:00",1605022260561006216
----mahiro----
"2020-11-10 10:22:00",1605021720479176213
"2020-11-10 10:29:00",1605022140295769154
"2020-11-10 10:30:00",1605022200649709852
"2020-11-10 10:31:00",1605022260111136737

The first time, it worked PERFECTLY -- the nanosecond time readings are identical. In the other ones, they're not even always within the same second. But pretty close.

So, now we need to decide whether this is close enough or if we need to find another approach.

Language of Flowers

Language of flowers in Dragon Maid

I've been aware of the Language of Flowers for a while. I probably became aware of it first through Japanese anime. I seem to recall that one of the first episodes of Naruto has a scene about the language of flowers. More recently, I loved the scene in Dragon Maid where Saikawa gives Kanna shepherd's purse, which has the meaning "I'll offer you everything" according to her book.

Recently, we watched the movie Enola in which the Language of Flowers plays a small but significant role. And it turns out that the Language of Flowers was also a thing in Victorian England. Who knew!

Wikipedia, reliably, has a good summary about the Language of Flowers and has a link to a beautifully illustrated book from circa 1900 entitled Language of Flowers. According to Wikipedia, the Japanese language of flowers is called Hanakotoba but it isn't clear whether they're completely independent or not.

I've been writing haiku for years about flowers but had never considered using the Language of Flowers as a source of inspiration. Just recently I wrote a haiku about ferns:

According to the Greenaway, ferns mean "Fascination".

I also recently wrote a haiku about Goldenrod:

Golden Rod (two words) means "Precaution."

I don't know that I'll want to use the English language of flowers or Hanakotoba for haiku. But it's something to think about. And potentially a source of inspiration.

unapologetic

you always stood up tall
the times I chanced to pass this way
your silent eloquence to all
a comfort every day

but now i stand alone
beside the place you used to be
a testament you still provide
to those with eyes to see

Catchphrases

During our morning chat, Phil referenced Johnny Dangerously's catchphrase, "Once!" and so I asked him what his catchphrase is. He didn't reply immediately, so I helpfully suggested a couple of possibilities like "Aclarity" and "We're not just stotting around, here!"

He replied, "Heels touch ground when Slavs squat around!"

I said that sounded like a pretty weird catchphrase to me, but it turns out to be a reference to some offensive video I hadn't seen before about squatting. This is part of Philip's never ending quest to trick me into watch weird movement videos.

In any case, I subsequently asked Lucy what her catchphrase was and, after a moment of reflection she said, "I dunno." Then she brightened and said, "Hey! Maybe *that's* my catchphrase!"

Five minutes later, she asked me, "Hey, hey! So what's your catchphrase?"

Upon a moment of reflection, having completely forgotten what we were talking about five minutes ago, I said, "I dunno." Then I brightened and said, "Hey! We have the *same* catchphrase!"

Animal Crossing Observations

I've always loved computer games. When I was young, I got to play arcade games as they first came out. I remember when Pong was first installed in our local pinball parlor. I spent a lot of time in video arcades in high school. When I became an adult professional, I found that many of my colleagues had basically never played such games. And I played relatively few as I worked to establish my career.

When my children were little, I would often identify a game they were playing and play it with them. In part, this was to have a an excuse to do things with them. I often felt like my dad would let me participate in his world (going for a hike, birdwatching, etc.) but was never willing to engage with me about things I was interested in. I wanted to find something they were doing that I could stand. So I played Pokémon with them (they got Red and Blue while I got Pokémon Yellow — with Pikachu!). And the Zelda games. And a variety of others, along the way.

At the same time, I try to set limits. I generally only play one game at a time: I played Ingress until I decided to try Pocket Camp and played that until I switched to Pokémon Go (at the suggestion of a son). My goal is that playing games remains just a small part of my day.

We got a Gamecube as our first video console game when it was relatively new. And one of the first games we got was Animal Crossing. I was immediately charmed by the game: You arrive in a a new town and buy a house with a gigantic loan that you need to pay off by collecting stuff (fruit, then insects, then fossils, then fish, then art) and selling it to earn "Bells" — the currency. The guy who loans you the money (a suave business-tanuki) also runs the store that you buy and sell stuff at. But the game had a variety of creative touches: in particular there was a museum that would accept donations of one of each of everything to put on display. And some fish and insects could only be found at certain times of day, or certain locations on the map. Or certain seasons.

One of the best features was that it appeared to be intentionally designed to have you to play every day, but to play for only a relatively short amount of time. It gave decreasing rewards the longer you played in a particular session. Although you could "grind", you could do most of the stuff that needed to be done for the day in a half hour. You could pick all the weeds, collect all the fruit, etc, and then there just wasn't much to do. But you might want to check back at various times of day to see if different fish or insects were out.

After the GameCube, the kids moved on, and I hadn't played Animal Crossing for years. I never played "New Leaf" which was released for the Nintendo DS (which I didn't have). Two years ago, Nintendo released a mobile game called "Pocket Camp" which I played for a while.

When they announced the newest version in the franchise, New Horizons, I figured I might try it to see what it was like. But I wasn't particularly excited about it. Then the Coronavirus happened.

Animal Crossing has gotten a huge amount of press worldwide as people cast about for something to do during the quarantine. The best article I've read so far is The Quiet Revolution of Animal Crossing which describes the game as a thought experiment about how life could be organized along a different set of values, that maximizes happiness and freedom over profit.

In my five-person household, four of us are playing Animal Crossing together. My younger son, who is the only one who has a switch, was gracious enough to let the rest of us create houses on "his" island. It's been fascinating to me to watch how each of use apprehends and constructs a completely different reality about how to organize their in-game activity.

He was actually pretty unhappy at having to share his island -- and even volunteered to purchase another switch to avoid this fate. But it was too late: there were no longer any available for love or money. As the primary player, he was the one that had to spend money early in the game for any infrastructure and for the animal residents. And for a while, this added to his passive-aggressive relationship with the rest of us. But when he hit it big in the "stalk market," he became a bit less concerned with money.

My older son has been more interested in large-scale engineering projects to facilitate resource extraction: reshaping the landscape to improve the quality of fish and creating separated spaces for large orchards to grow fruit, or constructing giant fields of flowers to generate crosses to get different colors.

My wife, who was an avid player of pocket-camp, is entirely driven by the gamification. There is a second form of currency (Nook Miles) which you earn by accomplishing tasks. She structures her game play to maximize earning Nook Miles, so she generally sells things or buys things, not due to need or interest, but only when the system offers you a reward for doing so.

I think I understand my own perspective best. I approach the game as play. I am not particularly goal oriented, but enjoy moving through the game with serendipity finding things (like fish and insects) and trying improve the aesthetics of myself, my house, and the island. That said, I'm not above using the gamification features to somewhat restructure what I want to do: sometimes I identify things I want to buy and then wait to purchase them until there is a reward.

A brief digression about gamification: as has been amply documented, rewards undermine the potential for developing intrinsic motivation. A good in-game example is photographs. The game sometimes offers a reward for taking a photograph. So you can get the reward for just randomly clicking the button. And that's what my wife's photographs tended to look like. But the game offers a vast array of resources for taking *interesting* photographs. In fact, its pretty clear that the game designers realized that by enabling people to take photographs and share them via social media, they could give the marketing additional reach.

Looking at the pictures posted online, I notice a further division in the kinds of images posted. Some people share the ordinary events of the game: "Ooh! I caught a coelacanth!" Whereas others show some creative project they undertook: a labyrinth of tarantulas or my archaeological site (see below). Those are the only interesting ones, to me. Everyone experiences the ordinary moments of game play. But seeing something uniquely creative, like these wanted posters where Jolly Redd moors his boat.

I created a little archaeological site that I'm rather pleased with.

Nintendo even set up a place ("Photopia") where you can dress up rooms and characters from your island with all of your furniture and clothes to stage scenes to photograph. I discovered early on that this includes the avatars for other players. There's something deeply unsettling about being able to take another player's character, strip them to their underwear, and then dress them and pose them however you want. I mean, it's not R rated. But it still felt like a violation. (You can find these pictures and more at my Animal Crossing Image Gallery.)

As a further aside, I wish it was easier to get the image files out without posting them to social media. As far as I can tell, the only way to get them out is by removing the MicroSD card and copying the files by hand. I don't really want to give the switch (and anyone who uses it in the household) permission to post as me to social media. That's just not going to happen.

Animal Crossing is like a Rorschach test that causes each player to see different aspects. Some people see Animal Crossing as representing consumerism gone mad: go into more and more debt to expand your house and stick useless stuff in it! At the same time, there's no obligation to do that. The animals live very simply. Players have to opt in to the consumer culture. Nobody makes you take out larger and larger loans -- or even pay off the loans you have. There's no interest. You don't even need to build a house: you can keep just living in a tent, if you want.

I'm also playing as "girl" character which has been interesting. I never took much interest in clothing in the previous games: Your avatar had to wear something, so I'd pick some generic clothes and then basically never change them. As a "girl" however, I have skirts and blouses and sweaters and tights and shoes and am taking great delight in mixing and matching them. I also annoy people by saying things like, "It's not lady-like to run with tools in your hands."

The most difficult aspect, for us, has been reconciling our different perspectives on managing the island. This particularly came to a head when we all got the ability to terraform the island -- to add or remove water features and high ground. Who gets to make those decisions? When should you consult with others? Governance is hard work -- even for a game. We're still struggling with this. We've had a couple of passionate arguments about this, but have been able to work through them so far.

The multiplayer aspects have been particularly interesting to me. One multi-player mechanism is to visit other people's islands or let them visit yours. In this way, you can get things that are rare or not available on your own island. Or, if you're participating in the "stalk market" you can buy or sell turnips at more favorable prices. But there is also a cooperative game-play mode.

While playing, you can "tag in" other players who can share the screen with you while you play. But this means there is the single, shared screen. The camera keeps the main player on screen, but moves to try to keep the second player on screen. If they go too far, they unceremoniously pop back on to the screen. But the loss of sole control of the camera can be pretty frustrating and makes certain activities difficult or impossible without the active collaboration of the second player. For example, you can't reliably see fish to catch them without the connivance of the second player. Having realized this, I've taken this as a challenge, to co-play effectively in a supporting role. It's a unique dimension to game play that I hadn't considered before.

Social Distancing and the Makerspace

Makerspace

I've had a great time during my Professional Improvement Fellowship working in the All-Campus Makerspace. It's a vibrant community of people working on projects they're passionate about. I enjoyed going in every morning, getting a few hours of work before anyone else arrived, and then breathing in the atmosphere as the place filled up. I've made good progress on my project and learned a huge amount about the topics I'm studying. And it's been fun.

I fear the students didn't quite know what to make of me. I wasn't staff and I wasn't student. I was just kind of there. But they were very welcoming and let me be a peripheral participant. I got to help out, in minor ways, with a dozen or more projects going on in the Makerspace. And they were just starting to discover what a weirdo I am. 

On Wednesday, March 11, 2020, it became clear that the University would be taking steps to enable social distancing and the Makerspace made the decision to close operations to give staff Thursday and Friday before spring break to plan and prepare for the changes.I swung by on Wednesday and took home my box of materials and got set up to begin working on my project from home. I had realized, even as the pandemic was in its earliest phases, that working there was probably risky. It's a campus crossroads with students from all over campus coming through. So I had been expecting to step back at some point. It was just a surprise to have it happen so suddenly.

I haven't made much progress since I started working from home. I assume that once the excitement over the pandemic wears off, it will be easier to focus and get stuff done.  But I'm really going to miss working in the Makerspace and all the new friends I've made there.

Raspberry Pi Phone Home Script

For working with headless Raspberry Pis, I thought it was useful to have the Pi report its address(es) when it boots. Originally I wrote it as a one-liner, but I realized that it was useful to grab the MAC address for debugging porpoises. But to get that, you need to know which interface is active. And this was starting to sound less like a one-liner and more like a script. So I hacked one together in bash.

The script just iterates through the interfaces, checks to see if they're up, and then reports the info back to a script on the server.

#! /bin/bash
# rpi phone home script 20200228 sbrewer
for i in $(ls -1 /sys/class/net)
do
  #echo "Working on $i interface..."
  if [ $(cat /sys/class/net/$i/operstate) = "up" ]
  then
     echo "Reporting $i interface..."
     _IP=$(hostname -I) 
     _HW=$(cat /sys/class/net/$i/address)
     _HN=$(hostname)
     /usr/bin/wget -O/dev/null -q https://bcrc.bio.umass.edu/pitrack/?hwaddr=$_HW\&pi=$_HN\&ip=$_IP
     fi
done

Making shimenawa and shide

A staple in Japanese manga and anime are the trappings of shinto practices. Shrines are frequent settings and, although they're rarely discussed directly, you see the architecture, objects, and designs as part of the background. I probably saw a shimenawa first in My Neighbor Totoro, which was perhaps the first anime I really watched. The giant camphor tree is almost a character in the movie and although I saw the shimenawa around it, I didn't know what it was or what it meant.

shimenawa

(image via ecostories)

I also saw a shimenawa in the anime Natsume Yujincho and the Book of Friends. Natsume breaks a shimenawa that releases a dangerous yōkai that ultimately becomes his guardian and tutor. Most recently, I've been reading Nekomusume Michikusa Nikki which includes shrines in the various settings and in which shimenawa feature prominently (if anonymously). There are also end-of-chapter information pages and one of them may have shown shimenawa.

For whatever reason, I realized that I didn't know anything about them, so I googled them. I didn't even know the word when I started, just searching for "japanese shrine tree rope" which helped me find a series of pages about them, including a wikipedia page. And that led me to the wikipedia page for shide. And a number of pages that described how to make them. I resolved to make one for my sakura tree.

In the pictures I had seen, a shimenawa seems to traditionally have a rope, tassels, and shide. So I went out to find the components to make one.

Shimenawa are traditionally made with rice straw, but hemp is also used. I was dubious about finding rice straw in this area. I thought about trying to find raw hemp, as it is increasingly grown in this area. But making rope looked like a lot of complicated work. So, cheating just a bit, I went to the store and found a heavy sisal rope for $1.35/foot and got a dozen feet.

When I got back with the rope, Alisa asked, "Did you measure it first?"

"Guess," I replied. She just smirked. But it turned out that 12 feet was exactly right: just long enough to tie a knot with no extra. OK. Maybe 14 feet would have been better.

For the tassels, I looked online and saw that people often make them with embroidery thread. The bundles of thread are already looped which makes it easy to tie up one end and cut the other to make a pretty tassel. And I considered getting brightly colored thread. But that seemed gaudy and out-of-place given what I had seen online. So I just bought a big ball of thick, jute twine, wrapped it around a large shim (I used an old 18 egg carton) and then tied up one end and cut the other. I also bought a length of thinner hemp string that I used to tie up the tassels -- and the ends of the rope -- and to hang everything.

I also bought a pad of thick drawing paper to make the shide. I had found a page on how to make shide, which explained how to make a series of cuts and then fold the paper up while rotating. It's easy, once you get the hang of it.

I ended up making 8 tassels and 4 shide. Once I had everything in hand, it was simple to tie the rope around the tree and then distribute the tassels and shide at likely spots along the length.

shimenawa on sakura tree

I'm pleased with the results. The total cost in materials was about $30. It took me several hours to purchase everything and then a couple of hours to make the tassels and shide and to hang everything on the tree. But it was a warm winter day with sun and I enjoyed the chance to do something outside and dream of the sakura blossoms to come.

And of course, I had to post a thread on twitter.

made a shimenawa for his beloved sakura tree / faris ŝimenavon por sia amata sakuro https://t.co/GjaW8PSoKr

— Steven D. BREWER (@limako) February 17, 2020

This first time was an experiment. Maybe by next time, I'll be ready to try actually making the rope. Or maybe not. It's fun either way.

BluetoothLE Project

Last spring, a faculty member and student met with me to discuss building an instrument and I agreed as a kind of "dry run" as part of the preparation for my new class.  It sounds like a relatively simple project: a small, wearable device that collects two temperature readings. After a cursory bit of research, I recommended we try using the Adafruit Feather with BluetoothLE and two Onewire temperature sensors. It sounds simple, but trying to get it to work proved way more complicated than I had imagined.

First, we were hampered by trying to connect to the feather using the Windows laptop the student had. She didn't know anything about using serial ports via USB. And the USB cable she had was power only. And the bluetooth interface on her laptop couldn't do BluetoothLE at all. So everything felt like two steps forward and one step back.

Getting first one and then two temperature sensors working over the Onewire interface was not too bad. But then we confronted the fact that her laptop couldn't do BluetoothLE -- and I realized that even if we could, we would end up wanting a data logger that would remain after she completed her project. So I recommended we get a Raspberry Pi.

I had expected BluetoothLE to be relatively straightforward. Boy was I surprised. There were a few examples that were provided with the Adafruit Feather: we tried the heart-rate monitor example to start with. But it turned out to be not a good fit for what we were trying to do. It turned out that the implementation is tied to proprietary protocols and there were complicated twists at every level. The heart rate monitor example uses a predefined set of characteristics that are not readily generalizable. After struggling with it for a long time I was on the point of giving up.

After much experimentation, I decided that a generic uart connection would make more sense. But there were a bunch of tricks to getting it to work at all. It turned out I couldn't connect to the device without first doing a "scan" with the adaptor. The python bindings that came from Adafruit didn't work. Eventually, I found pygatt -- a different set of python libraries that (by using a deprecated set of connection tools) I could get to connect more-or-less reliably, and receive data. But it could only send text, so I multiplied the float by 100, rounded to an integer, transmitted the integer as CSV, parsed the CSV with python, and divided by 100, before rebuilding CSV together with a time stamp.

It reminded me a bit of the Galileos I worked with a couple of years ago. https://blog.bierfaristo.com/content/galileo-wrap As an expert, I could work with them and ultimately get them to roll-over and bark. But it wasn't something that I would expect a novice to be able to take on and get anywhere with.

Overall, the experience was very useful to me for the kinds of projects I'm hoping students will do. And I learned a bunch of useful tricks for working with these tools, although there are still a number of hurdles to overcome.

Pages

Subscribe to RSS - Steven D. Brewer's blog