A five-point SOTA day…the hard way

Today was the last day of the first phase of my Christmas vacation. It differs from next week in that I was alone during the weekdays. I figured I should take the opportunity to snag a few more “easy” summits before 2011 rolls over to 2012. I picked up three two-point summits on Monday and Tuesday, and decided to shoot for three more two-pointers today.

While I was in the Tillamook area on Tuesday, I picked up a recent topo map of the Tillamook State Forest from the forestry office. This map has up-to-date information about what roads have gates, regular maintenance, etc. It’s nice because the Topo USA 5.0 software I normally use for planning these trips has some seriously out-of-date (and incorrect) information. Given the lofty goal of a three-summit day, I figured I should study the map closely and plan a route I was sure would be successful.

I set off from home about 0730 for summit W7/NC-071. The planned route paid off and I drove straight to the foot of an ATV trail I planned to use to access the summit. I walked about a mile and a half up to the spot and set up my usual 20 meter station. The weather was extremely foggy and while I expected the view from up there was excellent, I couldn’t see it at all. I had 3G coverage, so I spotted myself on SOTAWatch and before I could put the phone down and pick up my mic to call CQ, N4EX was calling me. He must have been tracking my APRS position and rapidly refreshing the spots page. That kicked off a quick slew of seven contacts in four minutes. After that, I packed up and headed down the mountain. Victory song on the way down was “Native Stepson” by Sonny Landreth.

From here, I drove about 1.5 hours to my planned approach spot for Gobbler’s Knob, W7/NC-012. I snapped this picture from the side of the road as the fog started to recede in the morning sun:

I made it to the top in about thirty minutes, making my second planned summit (along with my first) right on schedule; I sat down to call CQ at exactly 2000Z (1200 local). This summit also offered 3G coverage so I spotted myself and made another seven contacts in a few minutes. Again, I packed things up and headed down to the Jeep. Victory song this time was “So Excited” by Stevie Ray Vaughan.

Unfortunately, the story takes a turn for the worse here. After departing Gobbler’s Knob, I headed about 45 minutes back the way I came to pick up the road that follows the North Fork of the Trask River and take it east to my planned summit of W7/NC-066. I rounded a bend and suddenly found myself staring at a closed gate. I was so mad, given that I had vetted the entire route the night before. I pulled out my nifty map and verified that the gate is indeed marked and I had missed it. Drat! Would you believe that the song on the radio at that very moment was “Signs” (as performed) by Tesla? How appropriate.

Determined to achieve the goal of a summit trifecta, even if the total score had to suffer, I quickly scanned the map and settled on Blind Cabin Ridge, W7/NC-031. This too had a gate preventing vehicular access, but the summit was only about a mile and half past this point. I figured I could drive there and quickly hike up to the summit and round out my day. After lots of driving on the unforgiving bumpy logging roads of the forest, I arrived at the gate, as marked. I pulled up on the bank to avoid blocking the road and set out for the summit. It all went as planned until I reached the trough between the first hill and the summit. The map showed continuing up a road that had been closed by loggers, as well as what looked like having been freshly tilled. After climbing over the slag the logging crew drug into the road to block it off, I had another half mile or so of extremely loose dirt in the bed of the former road. I finally reached a spot where my GPS agreed I could stop and make my contacts.

I climbed up on a bank where there was a flat spot and more packed dirt. There was no 3G saving grace for me here. So, I pulled out my APRS radio and proceeded to transmit a spot beacon in hopes that it would reach an igate and spot me on SOTAWatch. I called CQ only a few times before I got noticed and proceeded to make eight contacts. I later realized that my APRS spot beacon didn’t make it through and KE7FGB had just stumbled upon me by accident! Luckily, he spotted me and things went smoothly from there.

I packed up and headed back to the Jeep. Victory song this time was “Green Onions” (as performed) by Tom Petty. As the sun began to set behind me, I captured this picture from the road down from Blind Cabin Ridge as the fog began to settle in the valley:

Once I made it back to the Jeep, I plotted my course back to Highway 6. The sun had officially set and this point and I drove for two hours in the dark to get out of the woods and back to civilization.

I talked to stations in North Carolina, California, Indiana, Texas, Colorado, Oregon, Maryland, Wyoming, Iowa, New Mexico, as well as Canadian stations in Quebec, and British Columbia.

You might think that this coming week between Christmas an New Years is going to be a quiet calorie-fest at home, right? Not if the things I have up my sleeve come to fruition!

Posted in Radio Tagged

SOTA Roundup

Wow, no updates here since July! The all-consuming activity that has kept me from doing so is the topic of this hiatus-breaking post.
Since about mid-August, I have been playing a game called SOTA, which stands for Summits On The Air. It is something that started in Europe and has recently spread to North America. The idea is that folks called “activators” head up to designated mountain summits with portable radio gear and make at least four contacts. The “chasers” are folks that hunt the activators from home, mobile, or other summits. This is mainly an HF activity, which means the contacts are across state and country lines. Summits are assigned point values based on their prominence, and the participants receive the points once they make at least four contacts.
The first summit I activated was Aubrey Butte in Bend, OR, at the behest of N7HQR. We didn’t really know what we were doing, and thus brought way more gear than we needed to get the job done. We stumbled through it and made the required contacts. Two points for this one.
A few weeks later, we did a weekend trip where we activated Mt. Hebo (two points) on Friday evening, camped, and then did Meares Benchmark (one point) Saturday morning. We still carried too much stuff, but the distance required was short enough that we were able to do it.
We had a couple of friends visit the northwest in late September, with plans to hike a bunch of trails in the Mt. Rainier national forest. Luckily, one of the spots they were planning was High Rock, a six point peak. This was a multi-mile technical and challenging trail, which required me to truly carry the gear I needed, as making multiple trips was not feasible. This was the first one I did where I started throwing out duplicate pieces of equipment and trying to keep things as small as possible. Using my father’s 1970 Kelty D4 external frame pack, I was able to carry the radio gear, batteries, antenna components, tripod and mast to the top. It was a lot of work, but I made it and more than doubled my points in a single trip. As you can see, I clearly had some work to do in order to get the pack even smaller.
The next weekend was a planned trip to Sunriver, Oregon with a couple of friends. Lava Butte is an impressive cinder cone in the middle of the desert with a road nearly to the top and a four-point value. This one was nearly trivial as it just required walking up the paved trail from the parking lot to the overlook. We strapped the tripod and mast to the handrail and made our contacts.
Clearly bitten by the bug and addicted to the game, Taylor and I headed to Saddle Mountain the following weekend. Again, I carried the radio gear plus a full tripod and mast to the top. Some parts of the trail are hard to navigate with such a wide mast strapped across the pack. This hike got me thinking that while the frame pack was great for weight and large objects, it sat too far away from my body to be stable in the wind and varied terrain. Two points for this one.
 
The next weekend, we went to Roger’s Peak, which is a unassuming forested two-point peak, which really just required walking along a forest road to get to the top. This was to be my last trip with a full tripod and mast, as well as the last (so far) with the frame pack.
A week later, we rejoined N7HQR for a trip up to Mary’s Peak, another two pointer with an easy road walk from the parking lot. This was my first trip using the recently-acquired Buddipole shock-corded mast. This eliminated the need to carry the tripod and telescoping mast, about six pounds of weight. Replacing those is a small cordura bag about twelve inches long, which folds out into an eight foot mast. The only gotcha is that you have to guy it completely, but I’ve found that to not be a problem at all, even without help.
The following week, Taylor and I hiked to the top of Lookout Mountain, east of Mt. Hood. This fantastic hike was not overly challenging, and ended at a fantastic 360-degree view of the desert of eastern Oregon, as well as Mt. Hood and the similar peaks to the north and south. The top previously hosted a fire lookout structure, of which only the foundation remains. The temperatures were dropping (this was now the end of October) and the wind on top made it pretty cold. We took a thermos of hot cocoa, which was great after making my contacts and packing things up. Six points for this one, making it one of my two most valuable to date.
Unfortunately, the next weekend was cramped by a previous engagement so I was on my own for this one. I decided to head into the Tillamook State Forest and find one of the (supposedly easy) one-point hills that are mostly covered by fire roads. After hours of driving around and correcting maps with bad info, I finally found Giveout Mountain and made my contacts.
Somehow, my SOTA activities showed up on a friend’s radar this week — a new ham with a lot of experience in the backcountry. We planned and executed a trip up to Barlow Ridge, south of Mt. Hood. This was a four-point peak with a few miles of trudging through 6+ inches of snow and crossing some sketchy ridgelines. It was extremely cold, but we cooked a freeze-dried meal at the top and made our required contacts before heading back safely.

 

The next week, I rejoined K7JDF for a trip back to Giveout Mountain (where he activated and got the point) as well as the unnamed one-point peak “2416”. The latter required a bit of bushwhacking through some steep and dense logging fallout. It was a lot of work for a single point, but was fun nontheless.
Until now, each weekend since High Rock in late September had some sort of SOTA activity associated with it. The weekend of November 20th was, unfortunately, a break in the chain. We planned to head to Trask Mountain in the Oregon coast range on Sunday, which we expected would be an easy two-point peak. The roads there are only open in November (reportedly due to Deer season). As we drove the Jeep up the snow-covered fire roads, we encountered a group of hunters who had managed to slide their large dually pickup truck off the side and into the ditch. We attempted for over an hour to help them out of the ditch, but they were very heavy and very stuck. I managed to throw a tire chain and get it wrapped around my rear brake assembly, bending the brake line and shearing off the bleeder valve. Not sure whether I was in trouble or not, we decided to abort and cautiously head home with zero points.
The weekend after Thanksgiving, we vowed to use the extra time to not only get some additional points, but claim those robbed from us the weekend before. On Friday, we went to Frog Lake Buttes, which is south of Mt. Hood. We climbed 2.8 miles up the road to the butte in snowshoes (a first for us) and activated the four-point summit late in the day. Saturday, we headed back to Trask mountain, where we found almost all of the snow melted and made an easy two points. Although she had hiked to almost all of the summits with me, this day was the first where Taylor decided she might like to jump on the radio and get the points due her.
So, there you go. A roundup of all my SOTA activity to date. With 39 points so far, we have no plans to stop for the winter. As soon as January 1st rolls around, all of the summits we have already done become available for re-activation so that I can get the points for them again. Check out the SOTA website and get involved if you are interested. It’s quite addicting!

Posted in Radio Tagged

Jolly Jeepers Rally 2011

This past weekend, Taylor and I participated in our third “Back to Basics” rally with the Jolly Jeepers club. Unfortunately, Oregon didn’t seem to get the memo about it being the middle of July, because it rained on us the entire time. This made the trails muddy and the camping a little more challenging, but it certainly didn’t stop us from taking a bunch of jeeps into the woods. It did cut down on the amount of picture-taking and video-recording we did, just because it’s hard to do that in the rain.

This year was relatively uneventful compared to the events of the previous one, which is a good thing. There was a little more winching involved due to the wet weather, but that didn’t stop Paul from bringing his matching Jeep trailer:

 

 

Click here to see a playlist of the rest of the video that we captured. I continue to be disappointed by how tame the video makes the trails look. The hill at the end was so steep that you’d be on your hands and knees trying to walk up it.

 

Posted in Miscellaneous Tagged

Field Day 2011

This past weekend was the annual ARRL Field Day event. It’s a contest of sorts where US hams attempt to contact as many other stations as possible in a 24 hour window. It encourages people to get out of their usual home stations, set up portable gear or staff an emergency station, and operate from a different spot with different equipment. I have long wanted to “do it for real” by venturing far out into the woods and setting up a station away from civilization and its “easy power” and RFI.

 

This year, four of us (Dawn, JD, Taylor, and myself) headed out to a pre-scoped spot in the Tillamook State Forest. The picturesque hilltop site we chose was at about 1600′ elevation and had just enough of a flat clearing for two sleeping tents, a food tent, and a radio tent. We arrived Friday afternoon at about 1630 and began our setup procedures. The contest didn’t start until 1100 Saturday morning, so we had a leisurely evening with pork link sausage and baked beans for dinner.

 

A quick 80 meter dipole setup that evening enabled some email contacts over Winlink, through the Pendleton RMS station. We were about 40 miles from the nearest cell phone coverage, and almost ten miles from the nearest civilization (a campground with running water and power). We brought four 100AHr lead acid batteries as our only power source for the weekend.

Saturday morning, we had eggs, bacon, and hash browns for breakfast before beginning the rest of the station setup. We planned to use all Buddipole gear and proceeded to set up 20 meter and 40 meter vertical antennas. We changed the 40 meter antenna to a 15 meter vertical at about noon, which served us very well until that evening. As originally planned, we ran the radios off of Buddipole A123 batteries, charging them in cycles from our lead acid batteries.

 

We each had a laptop with an Ad-Hoc WiFi network between us, running the FDLog software with a few of my own changes to the code. These were powered using DC adapters from the main batteries. We were able to last the entire time on just two of the large batteries, with no-load voltages sitting around 12.2V at the end of operations on Sunday.

Saturday night, we had spaghetti with Taylor’s home-made turkey sauce and garlic bread done on the camp fire. JD and I continued to operate until just after midnight when we had made 100 contacts. Just before that, we caught the 2305 pass of the International Space Station, which was easily visible to the naked eye until it passed far enough east to be eclipsed by the earth.

Sunday morning, we had pancakes and sausage for breakfast and made a couple dozen more contacts before beginning to break camp. In total, we made 122 contacts with 26 different states, including several from British Columbia to the north. Our farthest contact west was Hawaii and Florida to the east.

We all had a blast camping and operating in this heavenly spot and are already making plans for next year. My favorite picture of all was taken Saturday morning when we woke to an amazing blanket of fog down in the valley, probably 900 feet below us:

 

I recorded a video of JD giving a walkthrough of the entire camp, including our antennas. Unfortunately, it was Sunday morning and we had taken out one of the radios in the operating tent just prior to breaking down, but otherwise this is a nice video tour of what we had going:

 

Posted in Radio

A super key for people with real keyboards

How exactly did Microsoft get their logo on a key anyway?

In the Windows world, this is known as the “windows key” or the “win key”.  In Linux, it’s often mapped as the super key.  The new Unity environment (which I still have mixed feelings about) makes heavy use of the super key for window switching and other shortcuts.  Since I use a Model M keyboard from the mid 1980’s on both of my main workstations, I don’t have a windows super key.  Like it or not, Unity will be the default environment in 11.04, so I figure I better at least give it an honest try before I dismiss it.

I set off to figure out how to properly map something else as the super key.  Since I map my control key where the $DEITY intended it to be (i.e. Sun Type 3), the key actually labeled “control” (where most PC users know it to be) is available for this function.  Mapping the super key there would even leave it spatially close to where it is located on 104 key keyboards.

The following in ~/.Xmodmap does what I’m looking for:

! Clear the current control, caps lock, and super bindings
clear control
clear lock
clear mod4
! Make left control be Super_L
keycode 37 = Super_L
add mod4 = Super_L
! Make caps lock be Control_L, and add Control_R back in
keycode 66 = Control_L
add control = Control_L Control_R

Make sure to disable any Gnome layout options (like the Caps/Control swap) before you do this, as it handles the making the incorrectly-labeled caps lock key function as control.  I thought that xinit or Gnome would automatically read this file, but it seemed like that wasn’t happening, so I added the following command to my session:

xmodmap ~/.Xmodmap

If you want to just try it out without making it permanent, you can run the above command at a terminal and make it stick only for the current session.  With this change, I can now use the left control key as super for all the nifty shortcuts.

I do like Unity’s similarity to the NeXTSTEP/WindowMaker environment that I used for many years, but I worry about what it means for regular users who are used to poking around in an Applications (or Start) menu to explore the system and find the tools that they need.  Linux applications aren’t always named according to what they do (Banshee, Vinagre, Firefox, Thunderbird, etc) which makes the search interface not necessarily very appropriate.  I hope that Canonical is not making a fatal mistake with this move, but only time will tell.

Posted in Linux

A custom APRS tracker with a real screen

For those that don’t know, amateur radio operators have had something called the Automatic Packet Reporting System for quite a while now.  Most associate it with vehicular tracking, but it does a lot of other neat stuff like weather, telemetry, and message transfer. Many hams put a device called a “tracker” in their vehicle that periodically reports their position (which comes from an attatched GPS) on the air, which is picked up by other stations as well as internet gateways. That is what makes sites like aprs.fi so useful. For more information on APRS, see the inventor’s site as well as the APRSWiki.

There are typically two “classes” of tracker. The first is a simple transmit-only device, such as the TinyTrack3. The sole purpose is to transmit your position periodically, so that other people can see where you are.  If you want to be able to actually see where other stations are (without going to an internet site) you can use something like the Kenwood TM-D710, which is a radio with a TNC built-in, capable of displaying information on the screen. It looks something like this:

 

While it’s a ton of information if you have no other option, it can sometimes leave a lot to be desired. You can take it a little further and attach a serial GPS, which the radio will load with waypoints of the stations it receives. That’s helpful for seeing where the other stations are, but the display can get cluttered quickly with every station the radio hears over a modest period of time. Other devices like the HamHUD provide a little more powerful interface external to the radio itself, if you prefer.

Recently, I came up with a couple of things I’d like to see in a tracker, to make it more functional and more…let’s say “modern”. Some of the requirements are:

  1. A real display (with colors and graphics)
  2. Telemetry capabilities (specifically car voltage and temperature)
  3. Expandable to do other things, such as control various systems in the vehicle, perhaps at the request of an APRS command message 

I decided to try to build something that met the above requirements for my Jeep. I settled on using a BeagleBoard xM for the core system, which is a 1GHz ARM development board with 512MB of RAM that runs Linux. It’s basically a cell phone on a development board, without the cell radio. I housed it in a DogHouse so that I had a way to mount it in the vehicle. For a display, I found a 3.5″ LCD composite video display on eBay for under $40. This is what it looks like mounted to the windshield next to my larger GPS screen:

APRS Tracker Display

I wrote a very simple display app using GTK that runs full-screen all the time to give a pretty nice display. While GTK and X11 are pretty overkill for something embedded like this, the machine is more than powerful enough to run it and it gives niceties like anti-aliased font rendering for free. It also runs on my desktop just as easily as on the device itself, which is nice for development.

The actual APRS tracking code is a separate module that speaks to the display over a socket.  This means that I can run the APRS bit on the embedded board and the display on my laptop if I’m trying to debug something specific. I used the libfap library for parsing the actual APRS packets, but I think I will end up using something else in the long run. All the other code is mine, including the packet generation, beaconing logic, etc. I implemented intelligent (i.e. speed and turn-sensitive) beaconing logic, although I’m hesitant to call it SmartBeaconing exactly.

APRS tracker transmitting 

External to the BeagleBoard itself, I’m using a simple microcontroller that reads a voltage divider to report the vehicle voltage, and an LM34 sensor for temperature. I plan to add a lot more telemetry sensors to that unit over time, but for now it gives me what I want.

APRS tracker receiving 

Down the road, I plan to see about adding some of these features: 

  1. TIGER maps for displaying the actual positions of received stations. I have code for this already and the maps could be stored on a USB stick for pennies.
  2. Audio alerts for received packets and proximity alarms. The device has stereo audio in and out.
  3. Auto-shutdown of the radio and the tracker if the vehicle voltage drops below a certain point.
  4. APRS messaging
  5. On-board configuration. Right now, there is no way to give input to the device so configuration is done via text file
For many of the above, I need an input device. Right now, the plan is to try a tiny (cellphone-sized) bluetooth keyboard, which will allow configuration, text input, as well as triggering beacons and displaying more information.
 
For a more comprehensive view of how it operates and behaves in real life, see below for a video of me out and about with it today:

 

 

Posted in Radio Tagged

ACPI Events on a Toughbook CF-29

I have a Panasonic Toughbook CF-29 that I use for situations where I don’t want to take my regular office-ish notebook.  I am planning to take and use it at the 2011 Eagle Cap Extreme event for digital communications.  I run Ubuntu on it (10.10 currently) which works mostly out of the box without any trouble.  However, a couple of the ACPI events don’t work; specifically the suspend and hibernate buttons.  I ran acpid in debug mode and it appears that the event IDs are different on the toughbook from what they are on most other manufacturers.

If you look in /etc/acpi/events, you’ll see that there are several per-manufacturer configuration files for catching their uniquely-identified events and plumbing them to the correct scripts.  By copying and modifying two of these, I was able to get my buttons to work.

From a terminal (or Alt+F2 Run prompt), type

gksudo gedit /etc/acpi/events/tb-sleep

and paste the following in the resulting blank editor window:

event=pcc HKEY 00000080 00000007
action=/etc/acpi/sleepbtn.sh

Save and close and then run

gksudo gedit /etc/acpi/events/tb-hibernate

and paste the following:

event=pcc HKEY 00000080 0000000a
action=/etc/acpi/hibernate.sh

Then, either reboot your machine or run sudo service acpid restart to make the changes active.  When you press your (Fn+) suspend or hibernate keys, the system should now react accordingly.

Posted in Linux Tagged

A better way to process binary data in Python

One of my side-projects is CHIRP, which is an application for programming the memory contents of various radios.  Like other projects I’ve done where I want to cater to (or at least, not exclude) people running Windows, it’s written in Python.  Not only is Python my newfangled language of choice for high-level geekiness, but it’s also a language that provides me a substantial amount of platform isolation and I’m comfortable deploying applications based on it to Windows.  I really have no desire to learn how to write “real” Windows applications, so if it weren’t as easy as it is, I wouldn’t do it.

Python is really great for a lot of things, but processing binary data is not what I would consider one of them.  CHIRP needs to download a binary image of a radio over a serial line and twiddle bits before uploading it again.  Since the radios are embedded microprocessors with limited storage, lots of bit packing is performed to be as efficient as possible, which results in a lot of bit whacking on my part to pack and unpack the information I need.  So far, this has been done by combining things like the struct module with the bitwise operators available in Python.  That means that the code looks like this:

tsval = (ord(mmap[POS_TSTEP]) >> 4) & 0x0F
fval = 'x00' + mmap[POS_FREQ_STARTSmilie: :POS_FREQ_END]
freq = ((struct.unpack(">i", fval)[0] * mult) / 1000.0)
val = struct.unpack("B", mmap[POS_DUPX])[0] & 0xC0
if val == 0xC0:
  duplex = "+"
elif val == 0x80:
  duplex = "-"
else:
  duplex = ""

It’s really quite ugly, and the bigger issue is that all the code above requires similar but opposite code to poke new values back into the locations.  This often resulted in code that would extract the values properly, but not insert them back correctly.  Further, common tasks were often done differently in different radio drivers that were written at different times.  An example of such a task is extracting an index into an array of values that was, say, three bits in the middle of a byte (or worse, six bits across two different bytes).  Another one is packing and unpacking BCD frequency values of various widths and endian orientations.  In summary, the major problems with this sort of approach are:

  1. Really ugly, hard-to-read, and hard-to-maintain code
  2. Different code paths for getting and setting a particular bitfield
  3. Multiple different styles and algorithms for getting at commonly-formatted, but differently-arranged bitfields
  4. Stability and correctness issues stemming from all of the above

Recently, I was reading some code by Dean AE7Q that was able to read and write ICOM ICF files.  His code is written in C++, so it has the benefit of using structs to map fields in a given buffer.  However, what really shook me, was the use of bitfield definitions.  Now, it’s not like I don’t write C all day long, and interact with bitfield definitions on a regular basis, I just handn’t even considered how much easier they would make the process.  I decided that there had to be a way I could do something similar in Python to make my life easier.

What I decided to do was write a parser for a simple meta language that looks like C.  It needed to support the following elements:

  1. Structures
  2. Arrays
  3. Bitfield definitions

Additionally, it would be very helpful if it had the following properties:

  1. A native data type for BCD-encoded bytes (many radios store integer values in BCD)
  2. 24-bit integers (Several radios use a three-byte integer to represent a frequency)
  3. A few compiler-directives to help seek within a large data stream to a position before mapping
  4. A pythonic mechanism to read and write the defined fields in the data stream after parsing

What I came up with was a module called bitwise.  It uses the PyPEG, which is somewhat like lex for C-based compiler writers.  The grammar is extremely simple and easy to understand, and the parser/compiler/whatever isn’t too bad either (although it could use quite a bit more cleanup).  The result is a simple, single-call interface that turns a binary data stream into a very usable object tree.  See the following example code:

# Defines a format for parsing some binary data
defn = """
  struct {
    u8 foo;
    u8 highbit:1,
       sixbits:6,
       lowbit:1;
       char string[3];
       bbcd fourdigits[2];
  } mystruct[1];"""
# Some binary data for us to parse
data = "x7Fx81abcx12x34"
tree = parse(defn, data)
print "Foo: %i" % tree.mystruct.foo
print "Highbit: %i" % tree.mystruct.highbit
print "Sixbits: %i" % tree.mystruct.sixbits
print "Lowbit: %i" % tree.mystruct.lowbit
print "String: %s" % tree.mystruct.string
print "Fourdigits: %i" % tree.mystruct.fourdigits

Which prints the following:

Foo: 127
Highbit: 1
Sixbits: 0
Lowbit: 1
String: abc
Fourdigits: 1234

If I wanted to change the sixbits field from all zeros to the value 13 and the string to “xyz”, all I have to do is:

tree.mystruct.sixbits = 13
tree.mystruct.string = "xyz"

I think that’s a clear win in terms of improved syntax and maintainability.  For images where the memory regions I care about are not contiguous from the beginning (which is all of them), the #seek and #seekto directives allow me to apply the definitions that follow to a specific location in the data

Aside from the obvious syntactic and mental health gains, here are a few “lines of code” metrics from before and after converting several drivers to use my “bitwise” module:

 Driver Lines before
Lines after
Change
 IC-2820 704 336 53% smaller
 ID-880 600 360 40% smaller
 VX-8R 375 139 63% smaller

To me, that’s fairly significant, especially given that the code to enable this change is only 721 lines on it’s own.  By the way, all of these numbers include comments and a block of (unchanged) license text at the top, so the actual change of functional lines is even more significant.  In all, before the change CHIRP had almost 6,000 lines of bit-twiddling driver code.  I’ve only converted a few of them so far, but if these initial gains continue to apply, that could cut the total driver codebase by 50%, which is a really good thing. The other aspect of it, which is harder to convey with numbers, is the fact that I know that the driver code is more robust now.  Since I don’t own all the radios that CHIRP supports, being able to make small maintenance tweaks to the code without having to brute-force test the driver against the real device is extremely helpful.  Now that the code is much more symmetric, I think such maintenance tasks will be much smoother in the future.

Posted in Codemonkeying Tagged ,

Q89 Compressor Modification

One of the first things you need when you start into off-roading is a good compressor.  This is because you air down your tires each time before you go, and have to air them back up before you drive home.  A while back, I got a dual-cylinder compressor called the “Q89”.  It’s made in China, of course, and is actually rebadged by several other companies like Smittybuilt.  When I got it, it had a cheesy coiled air hose with an even more cheesy schrader valve chuck on it.  The stock hose would leak if you didn’t hold it perfectly straight, the integrated gauge was useless, and the chuck didn’t really fit into my wheels with their recessed valves.

Last summer, I replaced the hose by getting an appropriately-sized barbed fitting, which had a 1/4″ NPT fitting which I mated with a standard quick-fit adapter.  This allowed me to use a normal air hose and normal accessories from that point on.  The problem with that setup was that it still included the use of the funky (read: flimsy) large diameter air hose exiting the cylinders.  This was so flimsy that it would kink and cut off the air supply really easily when pulling against it to reach a distant tire.  The other problem was that standard air fittings (like a tire chuck) expect to only allow air flow when necessary and not all the time.  This meant that while moving from one tire to the next, the compressor would lug down trying to pressurize the hose, which it’s not designed to do.  Thus, while moving from tire to tire I either had to turn off the compressor or hold my thumb on the valve core part of the tire chuck to allow the pressure to escape.

After getting fairly frustrated with this on my last trip, I decided to get a little more intimate with the thing and fix it for good.  The first thing I did was order a 90-120PSI cut-off switch that is normally closed, and breaks the circuit when the pressure climbs past a certain level.  This needs to be fit into the air line and the electrical feed for the pump.  It’s only rated at 5A, but the inline circuit breaker box actually has a relay already.  I wired it to that relay along with the switch so that it would cut the pump off properly.

If you take off the top housing that runs between the two cylinders, you can see that the output port is actually just a 1/8″ NPT female port of a manifold joining the two cylinders, the same as the cutoff switch.  I got a matching long nipple from the local auto parts store, as well as a tee and the adapters necessary to mate with my 1/4″ NPT female quick fit.

Now, you can turn the pump on normally with no hose attached and the pump will quickly turn off.  When you attach a hose, it will run again to pressurize the hose and then stop.  As you fill your tire, it cycles with you, turning off when the air flow stops.  It’s a much more useful tool now, and I might even add a tank at some point to help it cycle even less and give me the opportunity to power some pneumatic tools.

pump

Posted in Hardware

A DNSBL and Greylisting Hybrid Approach

I have long been a critic of greylisting as a method of reducing spam.  I recently broke down and implemented it on my servers after a couple of back-to-back blacklisting issues.  The problem with DNSBL blacklists is that even the “big boys” get their relays listed which causes mail to bounce for some period of time while they resolve the issue.  Recently, someone for which I host mail was getting frustrated as my server continued to turn away msn.com and google.com due to their presence on a couple of blacklists.  That’s just silly and really hard to explain to someone in a way that doesn’t make it sound like your fault.

So, I nixed the blacklists and moved to using postgrey for greylisting.  This process, which is well-documented elsewhere, relies on some required behaviors of the SMTP protocol to turn away spammers that don’t fully implement the protocol.  It automatically refuses mail from new and unknown servers in a soft way, asking them to “try again later”.  If they do, then their mail is accepted.  Most spammers won’t retry, they just move on to the next person.  It works very well, but it introduces a delay to the delivery of valid email.  Even if you only require that they try again immediately, or after a short period like five minutes, there is no way of communicating that to them.  As a result, many servers will wait an hour or even a day before retrying.  That really destroys the usefulness of instantaneous email and I hate it.

Recently I came across a page by a colleague of mine, Dave Hansen.  He suggested a hybrid approach to the problem, using the best of both systems.  He suggested that you first look up the remote server in a DNSBL.  If they’re not listed, then you accept their mail; if they are, you greylist them and introduce the delay.  This means that most mail (from unlisted servers) flows immediately as expected, and mail from incorrectly-listed machines will get the greylist delay.  He has a hacked up version of greylist.pl to do this.

In searching for a permanent way to do this, I came across postfwd, the postfix firewall daemon.  It allows you to delegate a lot of your policy out to another daemon (like you do with postgrey itself), but with far more control over how those rules are implemented.  What I came up with is a script that implements the hybrid approach, but with a few extra features.  The remote server is checked against seven blacklists.  If it is in two or more of them, then mail is rejected outright, assuming that you wouldn’t be erroneously listed on two at the same time.  If it’s listed on one of them, then the server is greylisted (actually delegated back to postgrey itself, which works very well).  If it’s not listed at all, then the mail is accepted and everyone is happy.  My postfwd config looks like this:

    &&DNSBLS {
             rbl=zen.spamhaus.org ;    \
             rbl=bl.spamcop.net ;      \
             rbl=dnsbl.sorbs.net ;     \
             rbl=ix.dnsbl.manitu.net ; \
             rhsbl=rddn.dnsbl.net.au ; \
             rhsbl=rhsbl.ahbl.org ;    \
             rhsbl=rhsbl.sorbs.net ;   \
    };

# DNSBL checks - lookup
id=RBL_QUERY  ;  &&DNSBLS ;  rhsblcount=all ; rblcount=all ;   \     
    action=set(HIT_dnsbls=$$rhsblcount,HIT_dnsbls+=$$rblcount,DSBL_text=$$dnsbltext)

# DNSBL checks - evaluation
id=RBL_TOOMANY  ;  HIT_dnsbls>=2 ;
    action=554 5.7.1 blocked using $$DSBL_count dnsbls, INFO: [$$DSBL_text]

# Greylist
id=GREYLIST ;  action=ask(127.0.0.1:10041)  ;  HIT_dnsbls>=1

So far, it seems to be working very well and doing exactly what I wanted.  I just configure postfix to use postfwd as an external policy server after all my normal checks have been satisfied.  I may up the count of blacklists that cause mail to be rejected outright to three or more, just to be safe, but I’ll have to see how many false positives I get over the next week or so.

Posted in Miscellaneous Tagged , ,